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.

173 lines
5.6 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. // since v3, chart can accept data in JSON format
  11. // if your category axis parses dates, you should only
  12. // set date format of your data (dataDateFormat property of AmSerialChart)
  13. var lineChartData = [
  14. {
  15. "date": "2009-10-02",
  16. "value": 5
  17. },
  18. {
  19. "date": "2009-10-03",
  20. "value": 15
  21. },
  22. {
  23. "date": "2009-10-04",
  24. "value": 13
  25. },
  26. {
  27. "date": "2009-10-05",
  28. "value": 17
  29. },
  30. {
  31. "date": "2009-10-06",
  32. "value": 15
  33. },
  34. {
  35. "date": "2009-10-09",
  36. "value": 19
  37. },
  38. {
  39. "date": "2009-10-10",
  40. "value": 21
  41. },
  42. {
  43. "date": "2009-10-11",
  44. "value": 20
  45. },
  46. {
  47. "date": "2009-10-12",
  48. "value": 20
  49. },
  50. {
  51. "date": "2009-10-13",
  52. "value": 19
  53. },
  54. {
  55. "date": "2009-10-16",
  56. "value": 25
  57. },
  58. {
  59. "date": "2009-10-17",
  60. "value": 24
  61. },
  62. {
  63. "date": "2009-10-18",
  64. "value": 26
  65. },
  66. {
  67. "date": "2009-10-19",
  68. "value": 27
  69. },
  70. {
  71. "date": "2009-10-20",
  72. "value": 25
  73. },
  74. {
  75. "date": "2009-10-23",
  76. "value": 29
  77. },
  78. {
  79. "date": "2009-10-24",
  80. "value": 28
  81. },
  82. {
  83. "date": "2009-10-25",
  84. "value": 30
  85. },
  86. {
  87. "date": "2009-10-26",
  88. "value": 72,
  89. "customBullet": "images/redstar.png"
  90. },
  91. {
  92. "date": "2009-10-27",
  93. "value": 43
  94. },
  95. {
  96. "date": "2009-10-30",
  97. "value": 31
  98. },
  99. {
  100. "date": "2009-11-01",
  101. "value": 30
  102. },
  103. {
  104. "date": "2009-11-02",
  105. "value": 29
  106. },
  107. {
  108. "date": "2009-11-03",
  109. "value": 27
  110. },
  111. {
  112. "date": "2009-11-04",
  113. "value": 26
  114. }
  115. ];
  116. AmCharts.ready(function () {
  117. var chart = new AmCharts.AmSerialChart();
  118. chart.dataProvider = lineChartData;
  119. chart.categoryField = "date";
  120. chart.dataDateFormat = "YYYY-MM-DD";
  121. // sometimes we need to set margins manually
  122. // autoMargins should be set to false in order chart to use custom margin values
  123. chart.autoMargins = false;
  124. chart.marginRight = 0;
  125. chart.marginLeft = 0;
  126. chart.marginBottom = 0;
  127. chart.marginTop = 0;
  128. // AXES
  129. // category
  130. var categoryAxis = chart.categoryAxis;
  131. categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
  132. categoryAxis.minPeriod = "DD"; // our data is daily, so we set minPeriod to DD
  133. categoryAxis.inside = true;
  134. categoryAxis.gridAlpha = 0;
  135. categoryAxis.tickLength = 0;
  136. categoryAxis.axisAlpha = 0;
  137. // value
  138. var valueAxis = new AmCharts.ValueAxis();
  139. valueAxis.dashLength = 4;
  140. valueAxis.axisAlpha = 0;
  141. chart.addValueAxis(valueAxis);
  142. // GRAPH
  143. var graph = new AmCharts.AmGraph();
  144. graph.type = "line";
  145. graph.valueField = "value";
  146. graph.lineColor = "#D8E63C";
  147. graph.customBullet = "images/star.png"; // bullet for all data points
  148. graph.bulletSize = 14; // bullet image should be a rectangle (width = height)
  149. graph.customBulletField = "customBullet"; // this will make the graph to display custom bullet (red star)
  150. chart.addGraph(graph);
  151. // CURSOR
  152. var chartCursor = new AmCharts.ChartCursor();
  153. chart.addChartCursor(chartCursor);
  154. // WRITE
  155. chart.write("chartdiv");
  156. });
  157. </script>
  158. </head>
  159. <body>
  160. <div id="chartdiv" style="width:100%; height:400px;"></div>
  161. </body>
  162. </html>