You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

151 lines
4.8 KiB

1 year ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>amCharts examples</title>
  6. <link rel="stylesheet" href="style.css" type="text/css">
  7. <script src="../amcharts/amcharts.js" type="text/javascript"></script>
  8. <script src="../amcharts/serial.js" type="text/javascript"></script>
  9. <script>
  10. var chart;
  11. var chartData = [
  12. {
  13. "date": "2012-03-01",
  14. "price": 20
  15. },
  16. {
  17. "date": "2012-03-02",
  18. "price": 75
  19. },
  20. {
  21. "date": "2012-03-03",
  22. "price": 15
  23. },
  24. {
  25. "date": "2012-03-04",
  26. "price": 75
  27. },
  28. {
  29. "date": "2012-03-05",
  30. "price": 158
  31. },
  32. {
  33. "date": "2012-03-06",
  34. "price": 57
  35. },
  36. {
  37. "date": "2012-03-07",
  38. "price": 107
  39. },
  40. {
  41. "date": "2012-03-08",
  42. "price": 89
  43. },
  44. {
  45. "date": "2012-03-09",
  46. "price": 75
  47. },
  48. {
  49. "date": "2012-03-10",
  50. "price": 132
  51. },
  52. {
  53. "date": "2012-03-11",
  54. "price": 158
  55. },
  56. {
  57. "date": "2012-03-12",
  58. "price": 56
  59. },
  60. {
  61. "date": "2012-03-13",
  62. "price": 169
  63. },
  64. {
  65. "date": "2012-03-14",
  66. "price": 24
  67. },
  68. {
  69. "date": "2012-03-15",
  70. "price": 147
  71. }
  72. ];
  73. var average = 90.4;
  74. AmCharts.ready(function () {
  75. // SERIAL CHART
  76. chart = new AmCharts.AmSerialChart();
  77. chart.dataProvider = chartData;
  78. chart.categoryField = "date";
  79. chart.dataDateFormat = "YYYY-MM-DD";
  80. // AXES
  81. // category
  82. var categoryAxis = chart.categoryAxis;
  83. categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
  84. categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
  85. categoryAxis.dashLength = 1;
  86. categoryAxis.gridAlpha = 0.15;
  87. categoryAxis.axisColor = "#DADADA";
  88. // value
  89. var valueAxis = new AmCharts.ValueAxis();
  90. valueAxis.axisColor = "#DADADA";
  91. valueAxis.dashLength = 1;
  92. valueAxis.logarithmic = true; // this line makes axis logarithmic
  93. chart.addValueAxis(valueAxis);
  94. // GUIDE for average
  95. var guide = new AmCharts.Guide();
  96. guide.value = average;
  97. guide.lineColor = "#CC0000";
  98. guide.dashLength = 4;
  99. guide.label = "average";
  100. guide.inside = true;
  101. guide.lineAlpha = 1;
  102. valueAxis.addGuide(guide);
  103. // GRAPH
  104. var graph = new AmCharts.AmGraph();
  105. graph.type = "smoothedLine";
  106. graph.bullet = "round";
  107. graph.bulletColor = "#FFFFFF";
  108. graph.useLineColorForBulletBorder = true;
  109. graph.bulletBorderAlpha = 1;
  110. graph.bulletBorderThickness = 2;
  111. graph.bulletSize = 7;
  112. graph.title = "Price";
  113. graph.valueField = "price";
  114. graph.lineThickness = 2;
  115. graph.lineColor = "#00BBCC";
  116. chart.addGraph(graph);
  117. // CURSOR
  118. var chartCursor = new AmCharts.ChartCursor();
  119. chartCursor.cursorPosition = "mouse";
  120. chart.addChartCursor(chartCursor);
  121. // SCROLLBAR
  122. var chartScrollbar = new AmCharts.ChartScrollbar();
  123. chartScrollbar.graph = graph;
  124. chartScrollbar.scrollbarHeight = 30;
  125. chart.addChartScrollbar(chartScrollbar);
  126. chart.creditsPosition = "bottom-right";
  127. // WRITE
  128. chart.write("chartdiv");
  129. });
  130. </script>
  131. </head>
  132. <body>
  133. <div id="chartdiv" style="width: 100%; height: 400px;"></div>
  134. </body>
  135. </html>