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.

99 lines
3.2 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. <script src="../amcharts/amcharts.js" type="text/javascript"></script>
  7. <script src="../amcharts/serial.js" type="text/javascript"></script>
  8. <script>
  9. var chart;
  10. var chartData = [
  11. {
  12. "country": "Czech Republic",
  13. "litres": 156.9,
  14. "short": "CZ"
  15. },
  16. {
  17. "country": "Ireland",
  18. "litres": 131.1,
  19. "short": "IR"
  20. },
  21. {
  22. "country": "Germany",
  23. "litres": 115.8,
  24. "short": "DE"
  25. },
  26. {
  27. "country": "Australia",
  28. "litres": 109.9,
  29. "short": "AU"
  30. },
  31. {
  32. "country": "Austria",
  33. "litres": 108.3,
  34. "short": "AT"
  35. },
  36. {
  37. "country": "UK",
  38. "litres": 99,
  39. "short": "UK"
  40. },
  41. {
  42. "country": "Belgium",
  43. "litres": 93,
  44. "short": "BE"
  45. }
  46. ];
  47. AmCharts.ready(function () {
  48. // SERIAL CHART
  49. var chart = new AmCharts.AmSerialChart();
  50. chart.dataProvider = chartData;
  51. chart.categoryField = "country";
  52. chart.startDuration = 2;
  53. // change balloon text color
  54. chart.balloon.color = "#000000";
  55. // AXES
  56. // category
  57. var categoryAxis = chart.categoryAxis;
  58. categoryAxis.gridAlpha = 0;
  59. categoryAxis.axisAlpha = 0;
  60. categoryAxis.labelsEnabled = false;
  61. // value
  62. var valueAxis = new AmCharts.ValueAxis();
  63. valueAxis.gridAlpha = 0;
  64. valueAxis.axisAlpha = 0;
  65. valueAxis.labelsEnabled = false;
  66. valueAxis.minimum = 0;
  67. chart.addValueAxis(valueAxis);
  68. // GRAPH
  69. var graph = new AmCharts.AmGraph();
  70. graph.balloonText = "[[category]]: [[value]]";
  71. graph.valueField = "litres";
  72. graph.descriptionField = "short";
  73. graph.type = "column";
  74. graph.lineAlpha = 0;
  75. graph.fillAlphas = 1;
  76. graph.fillColors = ["#ffe78e", "#bf1c25"];
  77. graph.labelText = "[[description]]";
  78. graph.balloonText = "[[category]]: [[value]] Litres";
  79. chart.addGraph(graph);
  80. chart.creditsPosition = "top-right";
  81. // WRITE
  82. chart.write("chartdiv");
  83. });
  84. </script>
  85. </head>
  86. <body>
  87. <div id="chartdiv" style="width: 520px; height: 400px;"></div>
  88. </body>
  89. </html>