Advertisement
maximus87

chart

Sep 15th, 2024
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.11 KB | None | 0 0
  1. <script>
  2. Highcharts.chart('chart-container', {
  3. chart: {
  4. type: 'spline',
  5. backgroundColor: null, // Remove background color
  6. },
  7. legend: {
  8. enabled: false
  9. },
  10. title: {
  11. text: ''
  12. },
  13. xAxis: {
  14. type: 'datetime',
  15. labels: {
  16. format: '{value:%b-%Y}', // Format as Jan-2015
  17. style: {
  18. color: '#877A55', // Pinkish label color
  19. fontSize: '14px'
  20. },
  21. rotation: -45 // Slant the labels
  22. },
  23. tickPositions: [
  24. Date.UTC(2015, 0, 31), Date.UTC(2016, 0, 31), Date.UTC(2017, 0, 31),
  25. Date.UTC(2018, 0, 31), Date.UTC(2019, 0, 31), Date.UTC(2020, 0, 31),
  26. Date.UTC(2021, 0, 31), Date.UTC(2022, 0, 31), Date.UTC(2023, 0, 31),
  27. Date.UTC(2024, 0, 31), Date.UTC(2024, 5, 30) // Jan-2024 and Jun-2024
  28. ],
  29. gridLineColor: "#A0522D",
  30. gridLineDashStyle: "dot",
  31. plotBands: [{
  32. color: 'rgba(220, 122, 0, 0.25)', // Color of the highlight
  33. from: Date.UTC(2020, 4, 31), // Start date
  34. to: Date.UTC(2024, 4, 31), // End date
  35. label: {
  36. text: '<div class="text-overchart" style="text-align:center;">+21%<span style="font-size:12px; color:white;">(over 4 years)</span></div>',
  37. align: 'center',
  38. x: 0, // Center horizontally within the plot band
  39. y: 150, // Adjust to position the text vertically
  40. style: {
  41. color: '#fff',
  42. fontSize: '25px', // Big text size
  43. fontWeight: 'normal',
  44. fontFamily: 'Assistant' // Font family
  45. },
  46. useHTML: true // Ensure HTML tags are rendered correctly
  47. }
  48. }],
  49. plotLines: [{
  50. color: 'transparent', // Hide the line
  51. width: 0,
  52. value: Date.UTC(2020, 4, 31),
  53. label: {
  54. text: '<strong>$2,018</strong><br />5/31/2020',
  55. align: 'center',
  56. verticalAlign: 'top', // Position above the x-axis
  57. y: 30, // Adjust vertical position to be above the line
  58. x: 0, // Center horizontally
  59. style: {
  60. color: '#606060',
  61. fontSize: '14px', // Font size for start label
  62. fontFamily: 'Assistant', // Font family
  63. textAlign: 'center', // Center the text horizontally
  64. rotation: 0 // Ensure text is not rotated
  65. },
  66. useHTML: true // Ensure HTML tags are rendered correctly
  67. }
  68. }, {
  69. color: 'transparent', // Hide the line
  70. width: 0,
  71. value: Date.UTC(2024, 4, 31),
  72. label: {
  73. text: 'End',
  74. align: 'center',
  75. verticalAlign: 'bottom', // Position above the x-axis
  76. y: -200, // Adjust vertical position to be above the line
  77. x: 0, // Center horizontally
  78. style: {
  79. color: '#606060',
  80. fontSize: '14px', // Font size for end label
  81. fontFamily: 'Assistant', // Font family
  82. textAlign: 'center', // Center the text horizontally
  83. rotation: 0 // Ensure text is not rotated
  84. },
  85. useHTML: true // Ensure HTML tags are rendered correctly
  86. }
  87. }],
  88. },
  89. yAxis: {
  90. title: {
  91. text: ''
  92. },
  93. min: 0,
  94. max: 2500,
  95. tickPositions: [0, 1250, 2500], // Y-axis labels: 0, 1250, 2500
  96. labels: {
  97. format: '${value}',
  98. style: {
  99. color: '#877A55', // Pinkish label color
  100. fontSize: '14px'
  101. },
  102. },
  103. gridLineColor: "#A0522D",
  104. gridLineDashStyle: "dot",
  105. plotOptions: {
  106. spline: {
  107. marker: {
  108. enabled: false,
  109. states: {
  110. hover: {
  111. enabled: true,
  112. radius: 6,
  113. },
  114. },
  115. },
  116. enableMouseTracking: true,
  117. lineWidth: 4, // Line thickness
  118. color: '#DC7A00', // Orange color for the line
  119. },
  120. },
  121. },
  122. series: [{
  123. name: 'Price',
  124. data: [
  125. [Date.UTC(2015, 0, 31), 1778], [Date.UTC(2015, 1, 28), 1784],
  126. [Date.UTC(2015, 2, 31), 1797], [Date.UTC(2015, 3, 30), 1805],
  127. [Date.UTC(2015, 4, 31), 1816], [Date.UTC(2015, 5, 30), 1823],
  128. [Date.UTC(2015, 6, 31), 1827], [Date.UTC(2015, 7, 31), 1824],
  129. [Date.UTC(2015, 8, 30), 1823], [Date.UTC(2015, 9, 31), 1819],
  130. [Date.UTC(2015, 10, 30), 1818], [Date.UTC(2015, 11, 31), 1814],
  131. [Date.UTC(2016, 0, 31), 1818], [Date.UTC(2016, 1, 29), 1821],
  132. [Date.UTC(2016, 2, 31), 1829], [Date.UTC(2016, 3, 30), 1837],
  133. [Date.UTC(2016, 4, 31), 1846], [Date.UTC(2016, 5, 30), 1854],
  134. [Date.UTC(2016, 6, 31), 1858], [Date.UTC(2016, 7, 31), 1859],
  135. [Date.UTC(2016, 8, 30), 1855], [Date.UTC(2016, 9, 31), 1849],
  136. [Date.UTC(2016, 10, 30), 1844], [Date.UTC(2016, 11, 31), 1841],
  137. [Date.UTC(2017, 0, 31), 1846], [Date.UTC(2017, 1, 28), 1858],
  138. [Date.UTC(2017, 2, 31), 1873], [Date.UTC(2017, 3, 30), 1884],
  139. [Date.UTC(2017, 4, 31), 1890], [Date.UTC(2017, 5, 30), 1898],
  140. [Date.UTC(2017, 6, 31), 1901], [Date.UTC(2017, 7, 31), 1900],
  141. [Date.UTC(2017, 8, 30), 1898], [Date.UTC(2017, 9, 31), 1893],
  142. [Date.UTC(2017, 10, 30), 1887], [Date.UTC(2017, 11, 31), 1883],
  143. [Date.UTC(2018, 0, 31), 1886], [Date.UTC(2018, 1, 28), 1893],
  144. [Date.UTC(2018, 2, 31), 1905], [Date.UTC(2018, 3, 30), 1917],
  145. [Date.UTC(2018, 4, 31), 1929], [Date.UTC(2018, 5, 30), 1938],
  146. [Date.UTC(2018, 6, 31), 1944], [Date.UTC(2018, 7, 31), 1948],
  147. [Date.UTC(2018, 8, 30), 1943], [Date.UTC(2018, 9, 31), 1940],
  148. [Date.UTC(2018, 10, 30), 1941], [Date.UTC(2018, 11, 31), 1946],
  149. [Date.UTC(2019, 0, 31), 1951], [Date.UTC(2019, 1, 28), 1957],
  150. [Date.UTC(2019, 2, 31), 1967], [Date.UTC(2019, 3, 30), 1978],
  151. [Date.UTC(2019, 4, 31), 1990], [Date.UTC(2019, 5, 30), 2000],
  152. [Date.UTC(2019, 6, 31), 2006], [Date.UTC(2019, 7, 31), 2007],
  153. [Date.UTC(2019, 8, 30), 2007], [Date.UTC(2019, 9, 31), 2001],
  154. [Date.UTC(2019, 10, 30), 1995], [Date.UTC(2019, 11, 31), 1995],
  155. [Date.UTC(2020, 0, 31), 2004], [Date.UTC(2020, 1, 29), 2013],
  156. [Date.UTC(2020, 2, 31), 2023], [Date.UTC(2020, 3, 30), 2021],
  157. [Date.UTC(2020, 4, 31), 2018], [Date.UTC(2020, 5, 30), 2011],
  158. [Date.UTC(2020, 6, 31), 2009], [Date.UTC(2020, 7, 31), 2005],
  159. [Date.UTC(2020, 8, 30), 1991], [Date.UTC(2020, 9, 31), 1973],
  160. [Date.UTC(2020, 10, 30), 1952], [Date.UTC(2020, 11, 31), 1940],
  161. [Date.UTC(2021, 0, 31), 1942], [Date.UTC(2021, 1, 28), 1950],
  162. [Date.UTC(2021, 2, 31), 1960], [Date.UTC(2021, 3, 30), 1976],
  163. [Date.UTC(2021, 4, 31), 1992], [Date.UTC(2021, 5, 30), 2001],
  164. [Date.UTC(2021, 6, 31), 2005], [Date.UTC(2021, 7, 31), 2008],
  165. [Date.UTC(2021, 8, 30), 2009], [Date.UTC(2021, 9, 31), 2003],
  166. [Date.UTC(2021, 10, 30), 1997], [Date.UTC(2021, 11, 31), 1988],
  167. [Date.UTC(2022, 0, 31), 1993], [Date.UTC(2022, 1, 28), 2002],
  168. [Date.UTC(2022, 2, 31), 2015], [Date.UTC(2022, 3, 30), 2030],
  169. [Date.UTC(2022, 4, 31), 2046], [Date.UTC(2022, 5, 30), 2060],
  170. [Date.UTC(2022, 6, 31), 2071], [Date.UTC(2022, 7, 31), 2081],
  171. [Date.UTC(2022, 8, 30), 2091], [Date.UTC(2022, 9, 31), 2100],
  172. [Date.UTC(2022, 10, 30), 2110], [Date.UTC(2022, 11, 31), 2120],
  173. [Date.UTC(2023, 0, 31), 2130], [Date.UTC(2023, 1, 28), 2140],
  174. [Date.UTC(2023, 2, 31), 2150], [Date.UTC(2023, 3, 30), 2160],
  175. [Date.UTC(2023, 4, 31), 2170], [Date.UTC(2023, 5, 30), 2180],
  176. [Date.UTC(2023, 6, 31), 2190], [Date.UTC(2023, 7, 31), 2200],
  177. [Date.UTC(2023, 8, 30), 2210], [Date.UTC(2023, 9, 31), 2220],
  178. [Date.UTC(2023, 10, 30), 2230], [Date.UTC(2023, 11, 31), 2240],
  179. [Date.UTC(2024, 0, 31), 2250], [Date.UTC(2024, 1, 29), 2260],
  180. [Date.UTC(2024, 2, 31), 2270], [Date.UTC(2024, 3, 30), 2280],
  181. [Date.UTC(2024, 4, 31), 2290], [Date.UTC(2024, 5, 30), 2300]
  182. ],
  183.  
  184. lineWidth: 4, // Line thickness
  185. color: '#DC7A00',
  186. }],
  187. annotations: [{
  188. shapes: [{
  189. type: 'circle',
  190. point: {
  191. xAxis: 0,
  192. yAxis: 0,
  193. x: Date.UTC(2020, 4, 31),
  194. y: null // Adjust if needed
  195. },
  196. radius: 5,
  197. fillColor: '#FF0000', // Red color for the marker
  198. lineWidth: 1,
  199. lineColor: '#FF0000'
  200. }, {
  201. type: 'circle',
  202. point: {
  203. xAxis: 0,
  204. yAxis: 0,
  205. x: Date.UTC(2024, 4, 31),
  206. y: null // Adjust if needed
  207. },
  208. radius: 5,
  209. fillColor: '#FF0000', // Red color for the marker
  210. lineWidth: 1,
  211. lineColor: '#FF0000'
  212. }]
  213. }]
  214. });
  215. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement