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.

117 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": 2009,
  14. "income": 23.5,
  15. "expenses": 18.1
  16. },
  17. {
  18. "year": 2010,
  19. "income": 26.2,
  20. "expenses": 22.8
  21. },
  22. {
  23. "year": 2011,
  24. "income": 30.1,
  25. "expenses": 23.9
  26. },
  27. {
  28. "year": 2012,
  29. "income": 29.5,
  30. "expenses": 25.1
  31. },
  32. {
  33. "year": 2013,
  34. "income": 30.6,
  35. "expenses": 27.2,
  36. "dashLengthLine": 5
  37. },
  38. {
  39. "year": 2014,
  40. "income": 34.1,
  41. "expenses": 29.9,
  42. "dashLengthColumn": 5,
  43. "alpha":0.2,
  44. "additional":"(projection)"
  45. }
  46. ];
  47. AmCharts.ready(function () {
  48. // SERIAL CHART
  49. chart = new AmCharts.AmSerialChart();
  50. chart.dataProvider = chartData;
  51. chart.categoryField = "year";
  52. chart.startDuration = 1;
  53. chart.handDrawn = true;
  54. chart.handDrawnScatter = 3;
  55. // AXES
  56. // category
  57. var categoryAxis = chart.categoryAxis;
  58. categoryAxis.gridPosition = "start";
  59. // value
  60. var valueAxis = new AmCharts.ValueAxis();
  61. valueAxis.axisAlpha = 0;
  62. chart.addValueAxis(valueAxis);
  63. // GRAPHS
  64. // column graph
  65. var graph1 = new AmCharts.AmGraph();
  66. graph1.type = "column";
  67. graph1.title = "Income";
  68. graph1.lineColor = "#a668d5";
  69. graph1.valueField = "income";
  70. graph1.lineAlpha = 1;
  71. graph1.fillAlphas = 1;
  72. graph1.dashLengthField = "dashLengthColumn";
  73. graph1.alphaField = "alpha";
  74. graph1.balloonText = "<span style='font-size:13px;'>[[title]] in [[category]]:<b>[[value]]</b> [[additional]]</span>";
  75. chart.addGraph(graph1);
  76. // line
  77. var graph2 = new AmCharts.AmGraph();
  78. graph2.type = "line";
  79. graph2.title = "Expenses";
  80. graph2.lineColor = "#fcd202";
  81. graph2.valueField = "expenses";
  82. graph2.lineThickness = 3;
  83. graph2.bullet = "round";
  84. graph2.bulletBorderThickness = 3;
  85. graph2.bulletBorderColor = "#fcd202";
  86. graph2.bulletBorderAlpha = 1;
  87. graph2.bulletColor = "#ffffff";
  88. graph2.dashLengthField = "dashLengthLine";
  89. graph2.balloonText = "<span style='font-size:13px;'>[[title]] in [[category]]:<b>[[value]]</b> [[additional]]</span>";
  90. chart.addGraph(graph2);
  91. // LEGEND
  92. var legend = new AmCharts.AmLegend();
  93. legend.useGraphSettings = true;
  94. chart.addLegend(legend);
  95. // WRITE
  96. chart.write("chartdiv");
  97. });
  98. </script>
  99. </head>
  100. <body>
  101. <div id="chartdiv" style="width:50%; height:400px;"></div>
  102. </body>
  103. </html>