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.

94 lines
3.4 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. // note, each data item has "bullet" field.
  11. var columnChartData = [
  12. {
  13. "name": "John",
  14. "points": 35654,
  15. "color": "#7F8DA9",
  16. "bullet": "images/0.gif"
  17. },
  18. {
  19. "name": "Damon",
  20. "points": 65456,
  21. "color": "#FEC514",
  22. "bullet": "images/1.gif"
  23. },
  24. {
  25. "name": "Patrick",
  26. "points": 45724,
  27. "color": "#DB4C3C",
  28. "bullet": "images/2.gif"
  29. },
  30. {
  31. "name": "Mark",
  32. "points": 13654,
  33. "color": "#DAF0FD",
  34. "bullet": "images/3.gif"
  35. }
  36. ];
  37. AmCharts.ready(function () {
  38. // SERIAL CHART
  39. var chart = new AmCharts.AmSerialChart();
  40. chart.dataProvider = columnChartData;
  41. chart.categoryField = "name";
  42. chart.startDuration = 1;
  43. // sometimes we need to set margins manually
  44. // autoMargins should be set to false in order chart to use custom margin values
  45. chart.autoMargins = false;
  46. chart.marginRight = 0;
  47. chart.marginLeft = 0;
  48. chart.marginBottom = 0;
  49. chart.marginTop = 0;
  50. // AXES
  51. // category
  52. var categoryAxis = chart.categoryAxis;
  53. categoryAxis.inside = true;
  54. categoryAxis.axisAlpha = 0;
  55. categoryAxis.gridAlpha = 0;
  56. categoryAxis.tickLength = 0;
  57. // value
  58. var valueAxis = new AmCharts.ValueAxis();
  59. valueAxis.minimum = 0;
  60. valueAxis.axisAlpha = 0;
  61. valueAxis.maximum = 80000;
  62. valueAxis.dashLength = 4;
  63. chart.addValueAxis(valueAxis);
  64. // GRAPH
  65. var graph = new AmCharts.AmGraph();
  66. graph.valueField = "points";
  67. graph.customBulletField = "bullet"; // field of the bullet in data provider
  68. graph.bulletOffset = 16; // distance from the top of the column to the bullet
  69. graph.colorField = "color";
  70. graph.bulletSize = 34; // bullet image should be rectangle (width = height)
  71. graph.type = "column";
  72. graph.fillAlphas = 0.8;
  73. graph.cornerRadiusTop = 8;
  74. graph.lineAlpha = 0;
  75. graph.balloonText = "<span style='font-size:13px;'>[[category]]: <b>[[value]]</b></span>";
  76. chart.addGraph(graph);
  77. // WRITE
  78. chart.write("chartdiv");
  79. });
  80. </script>
  81. </head>
  82. <body>
  83. <div id="chartdiv" style="width: 520px; height: 400px;"></div>
  84. </body>
  85. </html>