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.

165 lines
5.2 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/xy.js" type="text/javascript"></script>
  9. <script>
  10. var chart;
  11. var chartData = [
  12. {
  13. "date": "2015-01-01",
  14. "ay": 0.5,
  15. "by": 2.2
  16. },
  17. {
  18. "date": "2015-01-02",
  19. "ay": 1.3,
  20. "by": 4.9
  21. },
  22. {
  23. "date": "2015-01-03",
  24. "ay": 2.3,
  25. "by": 5.1
  26. },
  27. {
  28. "date": "2015-01-04",
  29. "ay": 2.8,
  30. "by": 5.3
  31. },
  32. {
  33. "date": "2015-01-05",
  34. "ay": 3.5,
  35. "by": 6.1
  36. },
  37. {
  38. "date": "2015-01-06",
  39. "ay": 5.1,
  40. "by": 8.3
  41. },
  42. {
  43. "date": "2015-01-07",
  44. "ay": 6.7,
  45. "by": 10.5
  46. },
  47. {
  48. "date": "2015-01-08",
  49. "ay": 8,
  50. "by": 12.3
  51. },
  52. {
  53. "date": "2015-01-09",
  54. "ay": 8.9,
  55. "by": 14.5
  56. },
  57. {
  58. "date": "2015-01-10",
  59. "ay": 9.7,
  60. "by": 15
  61. },
  62. {
  63. "date": "2015-01-11",
  64. "ay": 10.4,
  65. "by": 18.8
  66. },
  67. {
  68. "date": "2015-01-12",
  69. "ay": 11.7,
  70. "by": 19
  71. }
  72. ];
  73. AmCharts.ready(function () {
  74. // XY CHART
  75. chart = new AmCharts.AmXYChart();
  76. chart.dataDateFormat = "YYYY-MM-DD";
  77. chart.dataProvider = chartData;
  78. chart.startDuration = 1;
  79. // AXES
  80. // X
  81. var xAxis = new AmCharts.ValueAxis();
  82. xAxis.title = "X Axis";
  83. xAxis.position = "bottom";
  84. xAxis.dashLength = 1;
  85. xAxis.axisAlpha = 0;
  86. xAxis.type = "date";
  87. xAxis.autoGridCount = true;
  88. chart.addValueAxis(xAxis);
  89. // Y
  90. var yAxis = new AmCharts.ValueAxis();
  91. yAxis.position = "left";
  92. yAxis.title = "Y Axis";
  93. yAxis.dashLength = 1;
  94. yAxis.axisAlpha = 0;
  95. yAxis.autoGridCount = true;
  96. chart.addValueAxis(yAxis);
  97. // GRAPHS
  98. // triangles up
  99. var graph1 = new AmCharts.AmGraph();
  100. graph1.lineColor = "#FF6600";
  101. graph1.balloonText = "x:[[x]] y:[[y]]";
  102. graph1.xField = "date";
  103. graph1.yField = "ay";
  104. graph1.lineAlpha = 1;
  105. graph1.type = "smoothedLine";
  106. graph1.bullet = "triangleUp";
  107. chart.addGraph(graph1);
  108. // triangles down
  109. var graph2 = new AmCharts.AmGraph();
  110. graph2.lineColor = "#FCD202";
  111. graph2.balloonText = "x:[[x]] y:[[y]]";
  112. graph2.xField = "date";
  113. graph2.yField = "by";
  114. graph2.lineAlpha = 1;
  115. graph2.type = "smoothedLine";
  116. graph2.bullet = "triangleDown";
  117. chart.addGraph(graph2);
  118. // first trend line
  119. var trendLine = new AmCharts.TrendLine();
  120. trendLine.lineColor = "#FF6600";
  121. trendLine.initialXValue = 1;
  122. trendLine.initialValue = 2;
  123. trendLine.finalXValue = 12;
  124. trendLine.finalValue = 11;
  125. chart.addTrendLine(trendLine);
  126. // second trend line
  127. trendLine = new AmCharts.TrendLine();
  128. trendLine.lineColor = "#FCD202";
  129. trendLine.initialXValue = 1;
  130. trendLine.initialValue = 1;
  131. trendLine.finalXValue = 12;
  132. trendLine.finalValue = 19;
  133. chart.addTrendLine(trendLine);
  134. // CURSOR
  135. var chartCursor = new AmCharts.ChartCursor();
  136. chart.addChartCursor(chartCursor);
  137. // SCROLLBAR
  138. var chartScrollbar = new AmCharts.ChartScrollbar();
  139. chart.addChartScrollbar(chartScrollbar);
  140. // WRITE
  141. chart.write("chartdiv");
  142. });
  143. </script>
  144. </head>
  145. <body>
  146. <div id="chartdiv" style="width: 600px; height: 400px;"></div>
  147. </body>
  148. </html>