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.

197 lines
6.5 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-01-01",
  14. "value": 8
  15. },
  16. {
  17. "date": "2012-01-02",
  18. "value": 10
  19. },
  20. {
  21. "date": "2012-01-03",
  22. "value": 12
  23. },
  24. {
  25. "date": "2012-01-04",
  26. "value": 14
  27. },
  28. {
  29. "date": "2012-01-05",
  30. "value": 11
  31. },
  32. {
  33. "date": "2012-01-06",
  34. "value": 6
  35. },
  36. {
  37. "date": "2012-01-07",
  38. "value": 7
  39. },
  40. {
  41. "date": "2012-01-08",
  42. "value": 9
  43. },
  44. {
  45. "date": "2012-01-09",
  46. "value": 13
  47. },
  48. {
  49. "date": "2012-01-10",
  50. "value": 15
  51. },
  52. {
  53. "date": "2012-01-11",
  54. "value": 19
  55. },
  56. {
  57. "date": "2012-01-12",
  58. "value": 21
  59. },
  60. {
  61. "date": "2012-01-13",
  62. "value": 22
  63. },
  64. {
  65. "date": "2012-01-14",
  66. "value": 20
  67. },
  68. {
  69. "date": "2012-01-15",
  70. "value": 18
  71. },
  72. {
  73. "date": "2012-01-16",
  74. "value": 14
  75. },
  76. {
  77. "date": "2012-01-17",
  78. "value": 16
  79. },
  80. {
  81. "date": "2012-01-18",
  82. "value": 18
  83. },
  84. {
  85. "date": "2012-01-19",
  86. "value": 17
  87. },
  88. {
  89. "date": "2012-01-20",
  90. "value": 15
  91. },
  92. {
  93. "date": "2012-01-21",
  94. "value": 12
  95. },
  96. {
  97. "date": "2012-01-22",
  98. "value": 10
  99. },
  100. {
  101. "date": "2012-01-23",
  102. "value": 8
  103. }
  104. ];
  105. AmCharts.ready(function () {
  106. // SERIAL CHART
  107. chart = new AmCharts.AmSerialChart();
  108. chart.dataProvider = chartData;
  109. chart.dataDateFormat = "YYYY-MM-DD";
  110. chart.categoryField = "date";
  111. // AXES
  112. // category
  113. var categoryAxis = chart.categoryAxis;
  114. categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
  115. categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
  116. categoryAxis.gridAlpha = 0.1;
  117. categoryAxis.minorGridAlpha = 0.1;
  118. categoryAxis.axisAlpha = 0;
  119. categoryAxis.minorGridEnabled = true;
  120. categoryAxis.inside = true;
  121. // value
  122. var valueAxis = new AmCharts.ValueAxis();
  123. valueAxis.tickLength = 0;
  124. valueAxis.axisAlpha = 0;
  125. valueAxis.showFirstLabel = false;
  126. valueAxis.showLastLabel = false;
  127. chart.addValueAxis(valueAxis);
  128. // GRAPH
  129. var graph = new AmCharts.AmGraph();
  130. graph.dashLength = 3;
  131. graph.lineColor = "#00CC00";
  132. graph.valueField = "value";
  133. graph.dashLength = 3;
  134. graph.bullet = "round";
  135. graph.balloonText = "[[category]]<br><b><span style='font-size:14px;'>value:[[value]]</span></b>";
  136. chart.addGraph(graph);
  137. // CURSOR
  138. var chartCursor = new AmCharts.ChartCursor();
  139. chartCursor.valueLineEnabled = true;
  140. chartCursor.valueLineBalloonEnabled = true;
  141. chart.addChartCursor(chartCursor);
  142. // SCROLLBAR
  143. var chartScrollbar = new AmCharts.ChartScrollbar();
  144. chart.addChartScrollbar(chartScrollbar);
  145. // HORIZONTAL GREEN RANGE
  146. var guide = new AmCharts.Guide();
  147. guide.value = 10;
  148. guide.toValue = 20;
  149. guide.fillColor = "#00CC00";
  150. guide.inside = true;
  151. guide.fillAlpha = 0.2;
  152. guide.lineAlpha = 0;
  153. valueAxis.addGuide(guide);
  154. // TREND LINES
  155. // first trend line
  156. var trendLine = new AmCharts.TrendLine();
  157. // note,when creating date objects 0 month is January, as months are zero based in JavaScript.
  158. trendLine.initialDate = new Date(2012, 0, 2, 12); // 12 is hour - to start trend line in the middle of the day
  159. trendLine.finalDate = new Date(2012, 0, 11, 12);
  160. trendLine.initialValue = 10;
  161. trendLine.finalValue = 19;
  162. trendLine.lineColor = "#CC0000";
  163. chart.addTrendLine(trendLine);
  164. // second trend line
  165. trendLine = new AmCharts.TrendLine();
  166. trendLine.initialDate = new Date(2012, 0, 17, 12);
  167. trendLine.finalDate = new Date(2012, 0, 22, 12);
  168. trendLine.initialValue = 16;
  169. trendLine.finalValue = 10;
  170. trendLine.lineColor = "#CC0000";
  171. chart.addTrendLine(trendLine);
  172. // WRITE
  173. chart.write("chartdiv");
  174. });
  175. </script>
  176. </head>
  177. <body>
  178. <div id="chartdiv" style="width: 100%; height: 450px;"></div>
  179. </body>
  180. </html>