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.

194 lines
5.6 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. "category": "Evaluation",
  14. "excelent": 20,
  15. "good": 20,
  16. "average": 20,
  17. "poor": 20,
  18. "bad": 20,
  19. "limit": 78,
  20. "full": 100,
  21. "bullet": 65
  22. }
  23. ];
  24. AmCharts.ready(function () {
  25. // FIRST BULLET CHART
  26. // bullet chart is a simple serial chart
  27. chart = new AmCharts.AmSerialChart();
  28. chart.dataProvider = chartData;
  29. chart.categoryField = "category";
  30. chart.rotate = true; // if you want vertical bullet chart, set rotate to false
  31. chart.columnWidth = 1;
  32. chart.startDuration = 1;
  33. // AXES
  34. // category
  35. var categoryAxis = chart.categoryAxis;
  36. categoryAxis.gridAlpha = 0;
  37. // value
  38. var valueAxis = new AmCharts.ValueAxis();
  39. valueAxis.maximum = 100;
  40. valueAxis.axisAlpha = 1;
  41. valueAxis.gridAlpha = 0;
  42. valueAxis.stackType = "regular"; // we use stacked graphs to make color fills
  43. chart.addValueAxis(valueAxis);
  44. // this graph displays the short dash, which usually indicates maximum value reached.
  45. var graph = new AmCharts.AmGraph();
  46. graph.valueField = "limit";
  47. graph.lineColor = "#000000";
  48. // it's a step line with no risers
  49. graph.type = "step";
  50. graph.noStepRisers = true;
  51. graph.lineAlpha = 1;
  52. graph.lineThickness = 3;
  53. graph.columnWidth = 0.5; // change this if you want wider dash
  54. graph.stackable = false; // this graph shouldn't be stacked
  55. chart.addGraph(graph);
  56. // The following graphs produce color bands
  57. graph = new AmCharts.AmGraph();
  58. graph.valueField = "excelent";
  59. graph.lineColor = "#19d228";
  60. graph.showBalloon = false;
  61. graph.type = "column";
  62. graph.fillAlphas = 0.8;
  63. chart.addGraph(graph);
  64. graph = new AmCharts.AmGraph();
  65. graph.valueField = "good";
  66. graph.lineColor = "#b4dd1e";
  67. graph.showBalloon = false;
  68. graph.type = "column";
  69. graph.fillAlphas = 0.8;
  70. chart.addGraph(graph);
  71. graph = new AmCharts.AmGraph();
  72. graph.valueField = "average";
  73. graph.lineColor = "#f4fb16";
  74. graph.showBalloon = false;
  75. graph.type = "column";
  76. graph.fillAlphas = 0.8;
  77. chart.addGraph(graph);
  78. graph = new AmCharts.AmGraph();
  79. graph.valueField = "poor";
  80. graph.lineColor = "#f6d32b";
  81. graph.showBalloon = false;
  82. graph.type = "column";
  83. graph.fillAlphas = 0.8;
  84. chart.addGraph(graph);
  85. graph = new AmCharts.AmGraph();
  86. graph.valueField = "bad";
  87. graph.lineColor = "#fb7116";
  88. graph.showBalloon = false;
  89. graph.type = "column";
  90. graph.fillAlphas = 0.8;
  91. chart.addGraph(graph);
  92. // this is the "bullet" graph - black bar showing current value
  93. graph = new AmCharts.AmGraph();
  94. graph.valueField = "bullet";
  95. graph.lineColor = "#000000";
  96. graph.type = "column";
  97. graph.lineAlpha = 1;
  98. graph.fillAlphas = 1;
  99. graph.columnWidth = 0.3; // this makes it narrower than color graphs
  100. graph.stackable = false; // bullet graph should not stack
  101. graph.clustered = false; // this makes the trick - one column above another
  102. chart.addGraph(graph);
  103. // WRITE
  104. chart.write("chartdiv");
  105. // SECOND BULLET CHART
  106. // bullet chart is a simple serial chart
  107. chart = new AmCharts.AmSerialChart();
  108. chart.dataProvider = chartData;
  109. chart.categoryField = "category";
  110. chart.rotate = false; // if you want horizontal bullet chart, set rotate to true
  111. chart.columnWidth = 1;
  112. chart.startDuration = 1;
  113. // AXES
  114. // category
  115. categoryAxis = chart.categoryAxis;
  116. categoryAxis.gridAlpha = 0;
  117. // value
  118. valueAxis = new AmCharts.ValueAxis();
  119. valueAxis.maximum = 100;
  120. valueAxis.minimum = 0;
  121. valueAxis.axisAlpha = 1;
  122. valueAxis.gridAlpha = 0;
  123. chart.addValueAxis(valueAxis);
  124. // this graph displays the short dash, which usually indicates maximum value reached.
  125. graph = new AmCharts.AmGraph();
  126. graph.valueField = "limit";
  127. graph.lineColor = "#000000";
  128. graph.type = "step";
  129. graph.noStepRisers = true;
  130. graph.lineAlpha = 1;
  131. graph.lineThickness = 3;
  132. graph.columnWidth = 0.5;
  133. graph.stackable = false;
  134. chart.addGraph(graph);
  135. // this is the color range graph.
  136. // we use only one graph here (not like in the first example, and set gradient fill)
  137. graph = new AmCharts.AmGraph();
  138. graph.valueField = "full";
  139. graph.showBalloon = false;
  140. graph.type = "column";
  141. graph.lineAlpha = 0;
  142. graph.fillAlphas = 0.8;
  143. graph.fillColors = ["#19d228", "#f6d32b", "#fb2316"];
  144. graph.gradientOrientation = "vertical";
  145. chart.addGraph(graph);
  146. // this is the "bullet" graph - black bar showing current value
  147. graph = new AmCharts.AmGraph();
  148. graph.valueField = "bullet";
  149. graph.lineColor = "#000000";
  150. graph.type = "column";
  151. graph.lineAlpha = 1;
  152. graph.fillAlphas = 1;
  153. graph.columnWidth = 0.3; // this makes it narrower than color graph
  154. graph.clustered = false; // this makes the trick - one column above another
  155. chart.addGraph(graph);
  156. // WRITE
  157. chart.write("chartdiv2");
  158. });
  159. </script>
  160. </head>
  161. <body>
  162. <div id="chartdiv" style="width: 600px; height: 100px;"></div>
  163. <div id="chartdiv2" style="width: 120px; height: 600px;"></div>
  164. </body>
  165. </html>