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.

112 lines
3.9 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. "year": 2005,
  14. "income": 23.5,
  15. "expenses": 18.1
  16. },
  17. {
  18. "year": 2006,
  19. "income": 26.2,
  20. "expenses": 22.8
  21. },
  22. {
  23. "year": 2007,
  24. "income": 30.1,
  25. "expenses": 23.9
  26. },
  27. {
  28. "year": 2008,
  29. "income": 29.5,
  30. "expenses": 25.1
  31. },
  32. {
  33. "year": 2009,
  34. "income": 24.6,
  35. "expenses": 25
  36. }
  37. ];
  38. AmCharts.ready(function () {
  39. // SERIAL CHART
  40. chart = new AmCharts.AmSerialChart();
  41. chart.dataProvider = chartData;
  42. chart.categoryField = "year";
  43. chart.startDuration = 1;
  44. chart.rotate = true;
  45. // AXES
  46. // category
  47. var categoryAxis = chart.categoryAxis;
  48. categoryAxis.gridPosition = "start";
  49. categoryAxis.axisColor = "#DADADA";
  50. categoryAxis.dashLength = 3;
  51. // value
  52. var valueAxis = new AmCharts.ValueAxis();
  53. valueAxis.dashLength = 3;
  54. valueAxis.axisAlpha = 0.2;
  55. valueAxis.position = "top";
  56. valueAxis.title = "Million USD";
  57. valueAxis.minorGridEnabled = true;
  58. valueAxis.minorGridAlpha = 0.08;
  59. valueAxis.gridAlpha = 0.15;
  60. chart.addValueAxis(valueAxis);
  61. // GRAPHS
  62. // column graph
  63. var graph1 = new AmCharts.AmGraph();
  64. graph1.type = "column";
  65. graph1.title = "Income";
  66. graph1.valueField = "income";
  67. graph1.lineAlpha = 0;
  68. graph1.fillColors = "#ADD981";
  69. graph1.fillAlphas = 0.8;
  70. graph1.balloonText = "<span style='font-size:13px;'>[[title]] in [[category]]:<b>[[value]]</b></span>";
  71. chart.addGraph(graph1);
  72. // line graph
  73. var graph2 = new AmCharts.AmGraph();
  74. graph2.type = "line";
  75. graph2.lineColor = "#27c5ff";
  76. graph2.bulletColor = "#FFFFFF";
  77. graph2.bulletBorderColor = "#27c5ff";
  78. graph2.bulletBorderThickness = 2;
  79. graph2.bulletBorderAlpha = 1;
  80. graph2.title = "Expenses";
  81. graph2.valueField = "expenses";
  82. graph2.lineThickness = 2;
  83. graph2.bullet = "round";
  84. graph2.fillAlphas = 0;
  85. graph2.balloonText = "<span style='font-size:13px;'>[[title]] in [[category]]:<b>[[value]]</b></span>";
  86. chart.addGraph(graph2);
  87. // LEGEND
  88. var legend = new AmCharts.AmLegend();
  89. legend.useGraphSettings = true;
  90. chart.addLegend(legend);
  91. chart.creditsPosition = "top-right";
  92. // WRITE
  93. chart.write("chartdiv");
  94. });
  95. </script>
  96. </head>
  97. <body>
  98. <div id="chartdiv" style="width: 500px; height: 600px;"></div>
  99. </body>
  100. </html>