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.

116 lines
4.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. <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.rotate = true;
  53. chart.color = "#FFFFFF";
  54. chart.handDrawn = true;
  55. chart.handDrawScatter = 4;
  56. // this line makes the chart to show image in the background
  57. chart.backgroundImage = "images/bg.jpg";
  58. // sometimes we need to set margins manually
  59. // autoMargins should be set to false in order chart to use custom margin values
  60. chart.autoMargins = false;
  61. chart.marginTop = 100;
  62. chart.marginLeft = 50;
  63. chart.marginRight = 30;
  64. chart.startDuration = 2;
  65. // AXES
  66. // category
  67. var categoryAxis = chart.categoryAxis;
  68. categoryAxis.gridAlpha = 0;
  69. categoryAxis.axisAlpha = 0;
  70. categoryAxis.labelsEnabled = false;
  71. // value
  72. var valueAxis = new AmCharts.ValueAxis();
  73. valueAxis.gridAlpha = 0;
  74. valueAxis.axisAlpha = 0;
  75. valueAxis.labelsEnabled = false;
  76. valueAxis.minimum = 0;
  77. chart.addValueAxis(valueAxis);
  78. // GRAPH
  79. var graph = new AmCharts.AmGraph();
  80. graph.balloonText = "[[category]]: [[value]]";
  81. graph.valueField = "litres";
  82. graph.type = "column";
  83. graph.lineAlpha = 0;
  84. graph.fillAlphas = 0.5;
  85. // you can pass any number of colors in array to create more fancy gradients
  86. graph.fillColors = ["#000000", "#FF6600"];
  87. graph.gradientOrientation = "horizontal";
  88. graph.labelPosition = "inside";
  89. graph.labelText = "[[category]]: [[value]] Litres";
  90. graph.balloonText = "[[category]]: [[value]] Litres";
  91. chart.addGraph(graph);
  92. // LABEL
  93. chart.addLabel(50, 40, "Beer Consumption by country", "left", 15, "#000000", 0, 1, true);
  94. chart.creditsPosition = "bottom-right";
  95. // WRITE
  96. chart.write("chartdiv");
  97. });
  98. </script>
  99. </head>
  100. <body>
  101. <div id="chartdiv" style="width: 520px; height: 400px;"></div>
  102. </body>
  103. </html>