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.

139 lines
5.1 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. "name": "Income A",
  14. "open": 0,
  15. "close": 11.13,
  16. "color": "#54cb6a",
  17. "balloonValue": 11.13
  18. },
  19. {
  20. "name": "Income B",
  21. "open": 11.13,
  22. "close": 15.81,
  23. "color": "#54cb6a",
  24. "balloonValue": 4.68
  25. },
  26. {
  27. "name": "Total Income",
  28. "open": 0,
  29. "close": 15.81,
  30. "color": "#169b2f",
  31. "balloonValue": 15.81
  32. },
  33. {
  34. "name": "Expenses A",
  35. "open": 12.92,
  36. "close": 15.81,
  37. "color": "#cc4b48",
  38. "balloonValue": 2.89
  39. },
  40. {
  41. "name": "Expenses B",
  42. "open": 8.64,
  43. "close": 12.92,
  44. "color": "#cc4b48",
  45. "balloonValue": 4.24
  46. },
  47. {
  48. "name": "Revenue",
  49. "open": 0,
  50. "close": 8.64,
  51. "color": "#1c8ceb",
  52. "balloonValue": 11.13
  53. }
  54. ];
  55. AmCharts.ready(function () {
  56. // Waterfall chart is a simple serial chart with some specific settings
  57. chart = new AmCharts.AmSerialChart();
  58. chart.dataProvider = chartData;
  59. chart.categoryField = "name";
  60. chart.columnWidth = 0.6;
  61. chart.startDuration = 1;
  62. // AXES
  63. // Category
  64. var categoryAxis = chart.categoryAxis;
  65. categoryAxis.gridAlpha = 0.1;
  66. categoryAxis.axisAlpha = 0;
  67. categoryAxis.gridPosition = "start";
  68. // Value
  69. var valueAxis = new AmCharts.ValueAxis();
  70. valueAxis.gridAlpha = 0.1;
  71. valueAxis.axisAlpha = 0;
  72. chart.addValueAxis(valueAxis);
  73. // GRAPH
  74. var graph = new AmCharts.AmGraph();
  75. graph.valueField = "close";
  76. graph.openField = "open";
  77. graph.type = "column";
  78. graph.lineAlpha = 1;
  79. graph.lineColor = "#BBBBBB";
  80. graph.colorField = "color";
  81. graph.fillAlphas = 0.8;
  82. graph.balloonText = "<span style='color:[[color]]'>[[category]]</span><br><span style='font-size:13px;'><b>$[[balloonValue]] Mln</b></span>";
  83. graph.labelText = "$[[balloonValue]]";
  84. chart.addGraph(graph);
  85. // Trend lines used for connectors
  86. var trendLine = new AmCharts.TrendLine();
  87. trendLine.initialCategory = "Income A";
  88. trendLine.finalCategory = "Income B";
  89. trendLine.initialValue = 11.13;
  90. trendLine.finalValue = 11.13;
  91. trendLine.lineColor = "#888888";
  92. trendLine.dashLength = 3;
  93. chart.addTrendLine(trendLine);
  94. trendLine = new AmCharts.TrendLine();
  95. trendLine.initialCategory = "Income B";
  96. trendLine.finalCategory = "Expenses A";
  97. trendLine.initialValue = 15.81;
  98. trendLine.finalValue = 15.81;
  99. trendLine.lineColor = "#888888";
  100. trendLine.dashLength = 3;
  101. chart.addTrendLine(trendLine);
  102. trendLine = new AmCharts.TrendLine();
  103. trendLine.initialCategory = "Expenses A";
  104. trendLine.finalCategory = "Expenses B";
  105. trendLine.initialValue = 12.92;
  106. trendLine.finalValue = 12.92;
  107. trendLine.lineColor = "#888888";
  108. trendLine.dashLength = 3;
  109. chart.addTrendLine(trendLine);
  110. trendLine = new AmCharts.TrendLine();
  111. trendLine.initialCategory = "Expenses B";
  112. trendLine.finalCategory = "Revenue";
  113. trendLine.initialValue = 8.64;
  114. trendLine.finalValue = 8.64;
  115. trendLine.lineColor = "#888888";
  116. trendLine.dashLength = 3;
  117. chart.addTrendLine(trendLine);
  118. // WRITE
  119. chart.write("chartdiv");
  120. });
  121. </script>
  122. </head>
  123. <body>
  124. <div id="chartdiv" style="width: 600px; height: 400px;"></div>
  125. </body>
  126. </html>