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.

105 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. 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.plotAreaBorderColor = "#DADADA";
  45. chart.plotAreaBorderAlpha = 1;
  46. // this single line makes the chart a bar chart
  47. chart.rotate = true;
  48. // AXES
  49. // Category
  50. var categoryAxis = chart.categoryAxis;
  51. categoryAxis.gridPosition = "start";
  52. categoryAxis.gridAlpha = 0.1;
  53. categoryAxis.axisAlpha = 0;
  54. // Value
  55. var valueAxis = new AmCharts.ValueAxis();
  56. valueAxis.axisAlpha = 0;
  57. valueAxis.gridAlpha = 0.1;
  58. valueAxis.position = "top";
  59. chart.addValueAxis(valueAxis);
  60. // GRAPHS
  61. // first graph
  62. var graph1 = new AmCharts.AmGraph();
  63. graph1.type = "column";
  64. graph1.title = "Income";
  65. graph1.valueField = "income";
  66. graph1.balloonText = "Income:[[value]]";
  67. graph1.lineAlpha = 0;
  68. graph1.fillColors = "#ADD981";
  69. graph1.fillAlphas = 1;
  70. chart.addGraph(graph1);
  71. // second graph
  72. var graph2 = new AmCharts.AmGraph();
  73. graph2.type = "column";
  74. graph2.title = "Expenses";
  75. graph2.valueField = "expenses";
  76. graph2.balloonText = "Expenses:[[value]]";
  77. graph2.lineAlpha = 0;
  78. graph2.fillColors = "#81acd9";
  79. graph2.fillAlphas = 1;
  80. chart.addGraph(graph2);
  81. // LEGEND
  82. var legend = new AmCharts.AmLegend();
  83. chart.addLegend(legend);
  84. chart.creditsPosition = "top-right";
  85. // WRITE
  86. chart.write("chartdiv");
  87. });
  88. </script>
  89. </head>
  90. <body>
  91. <div id="chartdiv" style="width:50%; height:600px;"></div>
  92. </body>
  93. </html>