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.

162 lines
5.3 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. "year": 1930,
  14. "italy": 1,
  15. "germany": 5,
  16. "uk": 3
  17. },
  18. {
  19. "year": 1934,
  20. "italy": 1,
  21. "germany": 2,
  22. "uk": 6
  23. },
  24. {
  25. "year": 1938,
  26. "italy": 2,
  27. "germany": 3,
  28. "uk": 1
  29. },
  30. {
  31. "year": 1950,
  32. "italy": 3,
  33. "germany": 4,
  34. "uk": 1
  35. },
  36. {
  37. "year": 1954,
  38. "italy": 5,
  39. "germany": 1,
  40. "uk": 2
  41. },
  42. {
  43. "year": 1958,
  44. "italy": 3,
  45. "germany": 2,
  46. "uk": 1
  47. },
  48. {
  49. "year": 1962,
  50. "italy": 1,
  51. "germany": 2,
  52. "uk": 3
  53. },
  54. {
  55. "year": 1966,
  56. "italy": 2,
  57. "germany": 1,
  58. "uk": 5
  59. },
  60. {
  61. "year": 1970,
  62. "italy": 3,
  63. "germany": 5,
  64. "uk": 2
  65. },
  66. {
  67. "year": 1974,
  68. "italy": 4,
  69. "germany": 3,
  70. "uk": 6
  71. },
  72. {
  73. "year": 1978,
  74. "italy": 1,
  75. "germany": 2,
  76. "uk": 4
  77. }
  78. ];
  79. AmCharts.ready(function () {
  80. // SERIAL CHART
  81. chart = new AmCharts.AmSerialChart();
  82. chart.dataProvider = chartData;
  83. chart.categoryField = "year";
  84. chart.startDuration = 0.5;
  85. chart.balloon.color = "#000000";
  86. // AXES
  87. // category
  88. var categoryAxis = chart.categoryAxis;
  89. categoryAxis.fillAlpha = 1;
  90. categoryAxis.fillColor = "#FAFAFA";
  91. categoryAxis.gridAlpha = 0;
  92. categoryAxis.axisAlpha = 0;
  93. categoryAxis.gridPosition = "start";
  94. categoryAxis.position = "top";
  95. // value
  96. var valueAxis = new AmCharts.ValueAxis();
  97. valueAxis.title = "Place taken";
  98. valueAxis.dashLength = 5;
  99. valueAxis.axisAlpha = 0;
  100. valueAxis.minimum = 1;
  101. valueAxis.maximum = 6;
  102. valueAxis.integersOnly = true;
  103. valueAxis.gridCount = 10;
  104. valueAxis.reversed = true; // this line makes the value axis reversed
  105. chart.addValueAxis(valueAxis);
  106. // GRAPHS
  107. // Italy graph
  108. var graph = new AmCharts.AmGraph();
  109. graph.title = "Italy";
  110. graph.valueField = "italy";
  111. graph.hidden = true; // this line makes the graph initially hidden
  112. graph.balloonText = "place taken by Italy in [[category]]: [[value]]";
  113. graph.lineAlpha = 1;
  114. graph.bullet = "round";
  115. chart.addGraph(graph);
  116. // Germany graph
  117. var graph = new AmCharts.AmGraph();
  118. graph.title = "Germany";
  119. graph.valueField = "germany";
  120. graph.balloonText = "place taken by Germany in [[category]]: [[value]]";
  121. graph.bullet = "round";
  122. chart.addGraph(graph);
  123. // United Kingdom graph
  124. var graph = new AmCharts.AmGraph();
  125. graph.title = "United Kingdom";
  126. graph.valueField = "uk";
  127. graph.balloonText = "place taken by UK in [[category]]: [[value]]";
  128. graph.bullet = "round";
  129. chart.addGraph(graph);
  130. // CURSOR
  131. var chartCursor = new AmCharts.ChartCursor();
  132. chartCursor.cursorPosition = "mouse";
  133. chartCursor.zoomable = false;
  134. chartCursor.cursorAlpha = 0;
  135. chart.addChartCursor(chartCursor);
  136. // LEGEND
  137. var legend = new AmCharts.AmLegend();
  138. legend.useGraphSettings = true;
  139. chart.addLegend(legend);
  140. // WRITE
  141. chart.write("chartdiv");
  142. });
  143. </script>
  144. </head>
  145. <body>
  146. <div id="chartdiv" style="width: 100%; height: 400px;"></div>
  147. </body>
  148. </html>