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.

130 lines
4.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. "country": "USA",
  14. "year2004": 3.5,
  15. "year2005": 4.2
  16. },
  17. {
  18. "country": "UK",
  19. "year2004": 1.7,
  20. "year2005": 3.1
  21. },
  22. {
  23. "country": "Canada",
  24. "year2004": 2.8,
  25. "year2005": 2.9
  26. },
  27. {
  28. "country": "Japan",
  29. "year2004": 2.6,
  30. "year2005": 2.3
  31. },
  32. {
  33. "country": "France",
  34. "year2004": 1.4,
  35. "year2005": 2.1
  36. },
  37. {
  38. "country": "Brazil",
  39. "year2004": 2.6,
  40. "year2005": 4.9
  41. },
  42. {
  43. "country": "Russia",
  44. "year2004": 6.4,
  45. "year2005": 7.2
  46. },
  47. {
  48. "country": "India",
  49. "year2004": 8,
  50. "year2005": 7.1
  51. },
  52. {
  53. "country": "China",
  54. "year2004": 9.9,
  55. "year2005": 10.1
  56. }
  57. ];
  58. AmCharts.ready(function () {
  59. // SERIAL CHART
  60. chart = new AmCharts.AmSerialChart();
  61. chart.dataProvider = chartData;
  62. chart.categoryField = "country";
  63. chart.color = "#FFFFFF";
  64. chart.fontSize = 14;
  65. chart.startDuration = 1;
  66. chart.plotAreaFillAlphas = 0.2;
  67. // the following two lines makes chart 3D
  68. chart.angle = 30;
  69. chart.depth3D = 60;
  70. // AXES
  71. // category
  72. var categoryAxis = chart.categoryAxis;
  73. categoryAxis.gridAlpha = 0.2;
  74. categoryAxis.gridPosition = "start";
  75. categoryAxis.gridColor = "#FFFFFF";
  76. categoryAxis.axisColor = "#FFFFFF";
  77. categoryAxis.axisAlpha = 0.5;
  78. categoryAxis.dashLength = 5;
  79. // value
  80. var valueAxis = new AmCharts.ValueAxis();
  81. valueAxis.stackType = "3d"; // This line makes chart 3D stacked (columns are placed one behind another)
  82. valueAxis.gridAlpha = 0.2;
  83. valueAxis.gridColor = "#FFFFFF";
  84. valueAxis.axisColor = "#FFFFFF";
  85. valueAxis.axisAlpha = 0.5;
  86. valueAxis.dashLength = 5;
  87. valueAxis.title = "GDP growth rate";
  88. valueAxis.titleColor = "#FFFFFF";
  89. valueAxis.unit = "%";
  90. chart.addValueAxis(valueAxis);
  91. // GRAPHS
  92. // first graph
  93. var graph1 = new AmCharts.AmGraph();
  94. graph1.title = "2004";
  95. graph1.valueField = "year2004";
  96. graph1.type = "column";
  97. graph1.lineAlpha = 0;
  98. graph1.lineColor = "#D2CB00";
  99. graph1.fillAlphas = 1;
  100. graph1.balloonText = "GDP grow in [[category]] (2004): <b>[[value]]</b>";
  101. chart.addGraph(graph1);
  102. // second graph
  103. var graph2 = new AmCharts.AmGraph();
  104. graph2.title = "2005";
  105. graph2.valueField = "year2005";
  106. graph2.type = "column";
  107. graph2.lineAlpha = 0;
  108. graph2.lineColor = "#BEDF66";
  109. graph2.fillAlphas = 1;
  110. graph2.balloonText = "GDP grow in [[category]] (2005): <b>[[value]]</b>";
  111. chart.addGraph(graph2);
  112. chart.write("chartdiv");
  113. });
  114. </script>
  115. </head>
  116. <body style="background-color:#000000;">
  117. <div id="chartdiv" style="width: 100%; height: 400px;"></div>
  118. </body>
  119. </html>