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.

103 lines
3.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. "continent": "North America",
  14. "trucks": 40000,
  15. "SUVs": 180000,
  16. "cars": 90000,
  17. "total": 310000
  18. },
  19. {
  20. "continent": "Asia",
  21. "trucks": 90000,
  22. "SUVs": 40000,
  23. "cars": 110000,
  24. "total": 240000
  25. },
  26. {
  27. "continent": "Europe",
  28. "trucks": 30000,
  29. "SUVs": 50000,
  30. "cars": 110000,
  31. "total": 190000
  32. }
  33. ];
  34. AmCharts.ready(function () {
  35. // SERIAL CHART
  36. chart = new AmCharts.AmSerialChart();
  37. chart.dataProvider = chartData;
  38. chart.categoryField = "continent";
  39. chart.plotAreaBorderAlpha = 0.2;
  40. // AXES
  41. // category
  42. var categoryAxis = chart.categoryAxis;
  43. categoryAxis.gridAlpha = 0.1;
  44. categoryAxis.axisAlpha = 0;
  45. categoryAxis.widthField = "total";
  46. categoryAxis.gridPosition = "start";
  47. // value
  48. var valueAxis = new AmCharts.ValueAxis();
  49. valueAxis.stackType = "100% stacked";
  50. valueAxis.gridAlpha = 0.1;
  51. valueAxis.unit = "%";
  52. valueAxis.axisAlpha = 0;
  53. chart.addValueAxis(valueAxis);
  54. // GRAPHS
  55. // first graph
  56. var graph = new AmCharts.AmGraph();
  57. graph.title = "Trucks";
  58. graph.labelText = "[[value]]";
  59. graph.valueField = "trucks";
  60. graph.type = "column";
  61. graph.fillAlphas = 1;
  62. chart.addGraph(graph);
  63. // second graph
  64. graph = new AmCharts.AmGraph();
  65. graph.title = "SUVs";
  66. graph.labelText = "[[value]]";
  67. graph.valueField = "SUVs";
  68. graph.type = "column";
  69. graph.fillAlphas = 1;
  70. chart.addGraph(graph);
  71. // third graph
  72. graph = new AmCharts.AmGraph();
  73. graph.title = "Cars";
  74. graph.labelText = "[[value]]";
  75. graph.valueField = "cars";
  76. graph.type = "column";
  77. graph.fillAlphas = 1;
  78. chart.addGraph(graph);
  79. chart.legend = new AmCharts.AmLegend();
  80. // WRITE
  81. chart.write("chartdiv");
  82. });
  83. </script>
  84. </head>
  85. <body>
  86. <div id="chartdiv" style="width: 600px; height: 400px;"></div>
  87. </body>
  88. </html>