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.

179 lines
7.0 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": 2003,
  14. "europe": 2.5,
  15. "namerica": 2.5,
  16. "asia": 2.1,
  17. "lamerica": 0.3,
  18. "meast": 0.2,
  19. "africa": 0.1
  20. },
  21. {
  22. "year": 2004,
  23. "europe": 2.6,
  24. "namerica": 2.7,
  25. "asia": 2.2,
  26. "lamerica": 0.3,
  27. "meast": 0.3,
  28. "africa": 0.1
  29. },
  30. {
  31. "year": 2005,
  32. "europe": 2.8,
  33. "namerica": 2.9,
  34. "asia": 2.4,
  35. "lamerica": 0.3,
  36. "meast": 0.3,
  37. "africa": 0.1
  38. }
  39. ];
  40. AmCharts.ready(function () {
  41. // SERIALL CHART
  42. chart = new AmCharts.AmSerialChart();
  43. chart.dataProvider = chartData;
  44. chart.categoryField = "year";
  45. chart.plotAreaBorderAlpha = 0.2;
  46. chart.rotate = true;
  47. // AXES
  48. // Category
  49. var categoryAxis = chart.categoryAxis;
  50. categoryAxis.gridAlpha = 0.1;
  51. categoryAxis.axisAlpha = 0;
  52. categoryAxis.gridPosition = "start";
  53. // value
  54. var valueAxis = new AmCharts.ValueAxis();
  55. valueAxis.stackType = "regular";
  56. valueAxis.gridAlpha = 0.1;
  57. valueAxis.axisAlpha = 0;
  58. chart.addValueAxis(valueAxis);
  59. // GRAPHS
  60. // firstgraph
  61. var graph = new AmCharts.AmGraph();
  62. graph.title = "Europe";
  63. graph.labelText = "[[value]]";
  64. graph.valueField = "europe";
  65. graph.type = "column";
  66. graph.lineAlpha = 0;
  67. graph.fillAlphas = 1;
  68. graph.lineColor = "#C72C95";
  69. graph.balloonText = "<b><span style='color:#C72C95'>[[title]]</b></span><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>";
  70. graph.labelPosition = "middle";
  71. chart.addGraph(graph);
  72. // second graph
  73. graph = new AmCharts.AmGraph();
  74. graph.title = "North America";
  75. graph.labelText = "[[value]]";
  76. graph.valueField = "namerica";
  77. graph.type = "column";
  78. graph.lineAlpha = 0;
  79. graph.fillAlphas = 1;
  80. graph.lineColor = "#D8E0BD";
  81. graph.balloonText = "<b><span style='color:#afbb86'>[[title]]</b></span><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>";
  82. graph.labelPosition = "middle";
  83. chart.addGraph(graph);
  84. // third graph
  85. graph = new AmCharts.AmGraph();
  86. graph.title = "Asia-Pacific";
  87. graph.labelText = "[[value]]";
  88. graph.valueField = "asia";
  89. graph.type = "column";
  90. graph.lineAlpha = 0;
  91. graph.fillAlphas = 1;
  92. graph.lineColor = "#B3DBD4";
  93. graph.balloonText = "<b><span style='color:#74bdb0'>[[title]]</b></span><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>";
  94. graph.labelPosition = "middle";
  95. chart.addGraph(graph);
  96. // fourth graph
  97. graph = new AmCharts.AmGraph();
  98. graph.title = "Latin America";
  99. graph.labelText = "[[value]]";
  100. graph.valueField = "lamerica";
  101. graph.type = "column";
  102. graph.lineAlpha = 0;
  103. graph.fillAlphas = 1;
  104. graph.lineColor = "#69A55C";
  105. graph.balloonText = "<b><span style='color:#69A55C'>[[title]]</b></span><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>";
  106. graph.labelPosition = "middle";
  107. chart.addGraph(graph);
  108. // fifth graph
  109. graph = new AmCharts.AmGraph();
  110. graph.title = "Middle-East";
  111. graph.labelText = "[[value]]";
  112. graph.valueField = "meast";
  113. graph.type = "column";
  114. graph.lineAlpha = 0;
  115. graph.fillAlphas = 1;
  116. graph.lineColor = "#B5B8D3";
  117. graph.balloonText = "<b><span style='color:#7a81be'>[[title]]</b></span><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>";
  118. graph.labelPosition = "middle";
  119. chart.addGraph(graph);
  120. // sixth graph
  121. graph = new AmCharts.AmGraph();
  122. graph.title = "Africa";
  123. graph.labelText = "[[value]]";
  124. graph.valueField = "africa";
  125. graph.type = "column";
  126. graph.lineAlpha = 0;
  127. graph.fillAlphas = 1;
  128. graph.lineColor = "#F4E23B";
  129. graph.balloonText = "<b><span style='color:#c3b218'>[[title]]</b></span><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>";
  130. graph.labelPosition = "middle";
  131. chart.addGraph(graph);
  132. // LEGEND
  133. var legend = new AmCharts.AmLegend();
  134. legend.position = "right";
  135. legend.borderAlpha = 0.3;
  136. legend.horizontalGap = 10;
  137. legend.switchType = "v";
  138. chart.addLegend(legend);
  139. chart.creditsPosition = "top-right";
  140. // WRITE
  141. chart.write("chartdiv");
  142. });
  143. // Make chart 2D/3D
  144. function setDepth() {
  145. if (document.getElementById("rb1").checked) {
  146. chart.depth3D = 0;
  147. chart.angle = 0;
  148. } else {
  149. chart.depth3D = 20;
  150. chart.angle = 30;
  151. }
  152. chart.validateNow();
  153. }
  154. </script>
  155. </head>
  156. <body>
  157. <div id="chartdiv" style="width: 100%; height: 400px;"></div>
  158. <div style="margin-left:40px;">
  159. <input type="radio" checked="true" name="group" id="rb1" onclick="setDepth()">2D
  160. <input type="radio" name="group" id="rb2" onclick="setDepth()">3D
  161. </div>
  162. </body>
  163. </html>