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.

139 lines
4.4 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 graph;
  12. var chartData = [
  13. {
  14. "year": "1950",
  15. "value": 0.22
  16. },
  17. {
  18. "year": "1951",
  19. "value": 0.168
  20. },
  21. {
  22. "year": "1952",
  23. "value": 0.103
  24. },
  25. {
  26. "year": "1953",
  27. "value": 0.067
  28. },
  29. {
  30. "year": "1954",
  31. "value": 0.151
  32. },
  33. {
  34. "year": "1955",
  35. "value": 0.281
  36. },
  37. {
  38. "year": "1956",
  39. "value": 0.348
  40. },
  41. {
  42. "year": "1957",
  43. "value": 0.274
  44. },
  45. {
  46. "year": "1958",
  47. "value": 0.211
  48. },
  49. {
  50. "year": "1959",
  51. "value": 0.174
  52. },
  53. {
  54. "year": "1960",
  55. "value": 0.124
  56. },
  57. {
  58. "year": "1961",
  59. "value": 0.064
  60. },
  61. {
  62. "year": "1962",
  63. "value": 0.032
  64. },
  65. {
  66. "year": "1963",
  67. "value": 0.05
  68. },
  69. {
  70. "year": "1964",
  71. "value": 0.106
  72. }
  73. ];
  74. AmCharts.ready(function () {
  75. // SERIAL CHART
  76. chart = new AmCharts.AmSerialChart();
  77. chart.marginRight = 0;
  78. chart.marginTop = 0;
  79. chart.dataProvider = chartData;
  80. chart.categoryField = "year";
  81. chart.dataDateFormat = "YYYY";
  82. chart.color = "#FFFFFF";
  83. chart.backgroundImage = "images/bgSky.jpg";
  84. // AXES
  85. // Category
  86. var categoryAxis = chart.categoryAxis;
  87. categoryAxis.parseDates = true; // as our data is date-based, we set parseDates to true
  88. categoryAxis.minPeriod = "YYYY"; // our data is yearly, so we set minPeriod to YYYY
  89. categoryAxis.gridCount = 20;
  90. categoryAxis.autoGridCount = false;
  91. categoryAxis.axisAlpha = 0.3;
  92. categoryAxis.axisColor = "#FFFFFF";
  93. categoryAxis.gridAlpha = 0.05;
  94. // VALUE
  95. var valueAxis = new AmCharts.ValueAxis();
  96. valueAxis.gridAlpha = 0;
  97. valueAxis.axisAlpha = 0.3;
  98. valueAxis.axisColor = "#FFFFFF";
  99. valueAxis.showLastLabel = false;
  100. chart.addValueAxis(valueAxis);
  101. // GRAPH
  102. graph = new AmCharts.AmGraph();
  103. graph.type = "step"; // this line makes step graph
  104. graph.noStepRisers = true;
  105. graph.valueField = "value";
  106. graph.lineColor = "#FFFFFF";
  107. graph.lineThickness = 1;
  108. graph.balloonText = "[[category]]<br><b><span style='font-size:14px;'>[[value]]</span></b>";
  109. chart.addGraph(graph);
  110. // CURSOR
  111. var chartCursor = new AmCharts.ChartCursor();
  112. chartCursor.cursorAlpha = 0;
  113. chartCursor.cursorPosition = "mouse";
  114. chartCursor.categoryBalloonDateFormat = "YYYY";
  115. chart.addChartCursor(chartCursor);
  116. chart.creditsPosition = "top-right";
  117. // WRITE
  118. chart.write("chartdiv");
  119. });
  120. </script>
  121. </head>
  122. <body>
  123. <div id="chartdiv" style="width: 800px; height: 500px;"></div>
  124. </body>
  125. </html>