Blame view
samples/bulletChart.html
5.71 KB
eed3c9f67 first file |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>amCharts examples</title> <link rel="stylesheet" href="style.css" type="text/css"> <script src="../amcharts/amcharts.js" type="text/javascript"></script> <script src="../amcharts/serial.js" type="text/javascript"></script> <script type="text/javascript"> var chart; var chartData = [ { "category": "Evaluation", "excelent": 20, "good": 20, "average": 20, "poor": 20, "bad": 20, "limit": 78, "full": 100, "bullet": 65 } ]; AmCharts.ready(function () { // FIRST BULLET CHART // bullet chart is a simple serial chart chart = new AmCharts.AmSerialChart(); chart.dataProvider = chartData; chart.categoryField = "category"; chart.rotate = true; // if you want vertical bullet chart, set rotate to false chart.columnWidth = 1; chart.startDuration = 1; // AXES // category var categoryAxis = chart.categoryAxis; categoryAxis.gridAlpha = 0; // value var valueAxis = new AmCharts.ValueAxis(); valueAxis.maximum = 100; valueAxis.axisAlpha = 1; valueAxis.gridAlpha = 0; valueAxis.stackType = "regular"; // we use stacked graphs to make color fills chart.addValueAxis(valueAxis); // this graph displays the short dash, which usually indicates maximum value reached. var graph = new AmCharts.AmGraph(); graph.valueField = "limit"; graph.lineColor = "#000000"; // it's a step line with no risers graph.type = "step"; graph.noStepRisers = true; graph.lineAlpha = 1; graph.lineThickness = 3; graph.columnWidth = 0.5; // change this if you want wider dash graph.stackable = false; // this graph shouldn't be stacked chart.addGraph(graph); // The following graphs produce color bands graph = new AmCharts.AmGraph(); graph.valueField = "excelent"; graph.lineColor = "#19d228"; graph.showBalloon = false; graph.type = "column"; graph.fillAlphas = 0.8; chart.addGraph(graph); graph = new AmCharts.AmGraph(); graph.valueField = "good"; graph.lineColor = "#b4dd1e"; graph.showBalloon = false; graph.type = "column"; graph.fillAlphas = 0.8; chart.addGraph(graph); graph = new AmCharts.AmGraph(); graph.valueField = "average"; graph.lineColor = "#f4fb16"; graph.showBalloon = false; graph.type = "column"; graph.fillAlphas = 0.8; chart.addGraph(graph); graph = new AmCharts.AmGraph(); graph.valueField = "poor"; graph.lineColor = "#f6d32b"; graph.showBalloon = false; graph.type = "column"; graph.fillAlphas = 0.8; chart.addGraph(graph); graph = new AmCharts.AmGraph(); graph.valueField = "bad"; graph.lineColor = "#fb7116"; graph.showBalloon = false; graph.type = "column"; graph.fillAlphas = 0.8; chart.addGraph(graph); // this is the "bullet" graph - black bar showing current value graph = new AmCharts.AmGraph(); graph.valueField = "bullet"; graph.lineColor = "#000000"; graph.type = "column"; graph.lineAlpha = 1; graph.fillAlphas = 1; graph.columnWidth = 0.3; // this makes it narrower than color graphs graph.stackable = false; // bullet graph should not stack graph.clustered = false; // this makes the trick - one column above another chart.addGraph(graph); // WRITE chart.write("chartdiv"); // SECOND BULLET CHART // bullet chart is a simple serial chart chart = new AmCharts.AmSerialChart(); chart.dataProvider = chartData; chart.categoryField = "category"; chart.rotate = false; // if you want horizontal bullet chart, set rotate to true chart.columnWidth = 1; chart.startDuration = 1; // AXES // category categoryAxis = chart.categoryAxis; categoryAxis.gridAlpha = 0; // value valueAxis = new AmCharts.ValueAxis(); valueAxis.maximum = 100; valueAxis.minimum = 0; valueAxis.axisAlpha = 1; valueAxis.gridAlpha = 0; chart.addValueAxis(valueAxis); // this graph displays the short dash, which usually indicates maximum value reached. graph = new AmCharts.AmGraph(); graph.valueField = "limit"; graph.lineColor = "#000000"; graph.type = "step"; graph.noStepRisers = true; graph.lineAlpha = 1; graph.lineThickness = 3; graph.columnWidth = 0.5; graph.stackable = false; chart.addGraph(graph); // this is the color range graph. // we use only one graph here (not like in the first example, and set gradient fill) graph = new AmCharts.AmGraph(); graph.valueField = "full"; graph.showBalloon = false; graph.type = "column"; graph.lineAlpha = 0; graph.fillAlphas = 0.8; graph.fillColors = ["#19d228", "#f6d32b", "#fb2316"]; graph.gradientOrientation = "vertical"; chart.addGraph(graph); // this is the "bullet" graph - black bar showing current value graph = new AmCharts.AmGraph(); graph.valueField = "bullet"; graph.lineColor = "#000000"; graph.type = "column"; graph.lineAlpha = 1; graph.fillAlphas = 1; graph.columnWidth = 0.3; // this makes it narrower than color graph graph.clustered = false; // this makes the trick - one column above another chart.addGraph(graph); // WRITE chart.write("chartdiv2"); }); </script> </head> <body> <div id="chartdiv" style="width: 600px; height: 100px;"></div> <div id="chartdiv2" style="width: 120px; height: 600px;"></div> </body> </html> |