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.

134 lines
4.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. "country": "USA",
  14. "visits": 3025,
  15. "color": "#FF0F00"
  16. },
  17. {
  18. "country": "China",
  19. "visits": 1882,
  20. "color": "#FF6600"
  21. },
  22. {
  23. "country": "Japan",
  24. "visits": 1809,
  25. "color": "#FF9E01"
  26. },
  27. {
  28. "country": "Germany",
  29. "visits": 1322,
  30. "color": "#FCD202"
  31. },
  32. {
  33. "country": "UK",
  34. "visits": 1122,
  35. "color": "#F8FF01"
  36. },
  37. {
  38. "country": "France",
  39. "visits": 1114,
  40. "color": "#B0DE09"
  41. },
  42. {
  43. "country": "India",
  44. "visits": 984,
  45. "color": "#04D215"
  46. },
  47. {
  48. "country": "Spain",
  49. "visits": 711,
  50. "color": "#0D8ECF"
  51. },
  52. {
  53. "country": "Netherlands",
  54. "visits": 665,
  55. "color": "#0D52D1"
  56. },
  57. {
  58. "country": "Russia",
  59. "visits": 580,
  60. "color": "#2A0CD0"
  61. },
  62. {
  63. "country": "South Korea",
  64. "visits": 443,
  65. "color": "#8A0CCF"
  66. },
  67. {
  68. "country": "Canada",
  69. "visits": 441,
  70. "color": "#CD0D74"
  71. }
  72. ];
  73. AmCharts.ready(function () {
  74. // SERIAL CHART
  75. chart = new AmCharts.AmSerialChart();
  76. chart.dataProvider = chartData;
  77. chart.categoryField = "country";
  78. chart.startDuration = 1;
  79. chart.depth3D = 50;
  80. chart.angle = 30;
  81. chart.marginRight = -45;
  82. // AXES
  83. // category
  84. var categoryAxis = chart.categoryAxis;
  85. categoryAxis.gridAlpha = 0;
  86. categoryAxis.axisAlpha = 0;
  87. categoryAxis.gridPosition = "start";
  88. // value
  89. var valueAxis = new AmCharts.ValueAxis();
  90. valueAxis.axisAlpha = 0;
  91. valueAxis.gridAlpha = 0;
  92. chart.addValueAxis(valueAxis);
  93. // GRAPH
  94. var graph = new AmCharts.AmGraph();
  95. graph.valueField = "visits";
  96. graph.colorField = "color";
  97. graph.balloonText = "<b>[[category]]: [[value]]</b>";
  98. graph.type = "column";
  99. graph.lineAlpha = 0.5;
  100. graph.lineColor = "#FFFFFF";
  101. graph.topRadius = 1;
  102. graph.fillAlphas = 0.9;
  103. chart.addGraph(graph);
  104. // CURSOR
  105. var chartCursor = new AmCharts.ChartCursor();
  106. chartCursor.cursorAlpha = 0;
  107. chartCursor.zoomable = false;
  108. chartCursor.categoryBalloonEnabled = false;
  109. chartCursor.valueLineEnabled = true;
  110. chartCursor.valueLineBalloonEnabled = true;
  111. chartCursor.valueLineAlpha = 1;
  112. chart.addChartCursor(chartCursor);
  113. chart.creditsPosition = "top-right";
  114. // WRITE
  115. chart.write("chartdiv");
  116. });
  117. </script>
  118. </head>
  119. <body>
  120. <div id="chartdiv" style="width: 100%; height: 400px;"></div>
  121. </body>
  122. </html>