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.

521 lines
15 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 src="../amcharts/pie.js" type="text/javascript"></script>
  10. <script>
  11. AmCharts.ready(function () {
  12. // line chart, with a bullet at the end
  13. var chart = new AmCharts.AmSerialChart();
  14. chart.dataProvider = [{
  15. "day": 1,
  16. "value": 120
  17. }, {
  18. "day": 2,
  19. "value": 124
  20. }, {
  21. "day": 3,
  22. "value": 127
  23. }, {
  24. "day": 4,
  25. "value": 122
  26. }, {
  27. "day": 5,
  28. "value": 121
  29. }, {
  30. "day": 6,
  31. "value": 123
  32. }, {
  33. "day": 7,
  34. "value": 118
  35. }, {
  36. "day": 8,
  37. "value": 113
  38. }, {
  39. "day": 9,
  40. "value": 122
  41. }, {
  42. "day": 10,
  43. "value": 125,
  44. bullet: "round"
  45. }];
  46. chart.categoryField = "day";
  47. chart.autoMargins = false;
  48. chart.marginLeft = 0;
  49. chart.marginRight = 5;
  50. chart.marginTop = 0;
  51. chart.marginBottom = 0;
  52. var graph = new AmCharts.AmGraph();
  53. graph.valueField = "value";
  54. graph.bulletField = "bullet";
  55. graph.showBalloon = false;
  56. graph.lineColor = "#a9ec49";
  57. chart.addGraph(graph);
  58. var valueAxis = new AmCharts.ValueAxis();
  59. valueAxis.gridAlpha = 0;
  60. valueAxis.axisAlpha = 0;
  61. chart.addValueAxis(valueAxis);
  62. var categoryAxis = chart.categoryAxis;
  63. categoryAxis.gridAlpha = 0;
  64. categoryAxis.axisAlpha = 0;
  65. categoryAxis.startOnAxis = true;
  66. chart.write("line1");
  67. // small column chart
  68. chart = new AmCharts.AmSerialChart();
  69. chart.dataProvider = [{
  70. "day": 1,
  71. "value": -5
  72. }, {
  73. "day": 2,
  74. "value": 3
  75. }, {
  76. "day": 3,
  77. "value": 7
  78. }, {
  79. "day": 4,
  80. "value": -3
  81. }, {
  82. "day": 5,
  83. "value": 3
  84. }, {
  85. "day": 6,
  86. "value": 4
  87. }, {
  88. "day": 7,
  89. "value": 6
  90. }, {
  91. "day": 8,
  92. "value": -3
  93. }, {
  94. "day": 9,
  95. "value": -2
  96. }, {
  97. "day": 10,
  98. "value": 6
  99. }];
  100. chart.categoryField = "day";
  101. chart.autoMargins = false;
  102. chart.marginLeft = 0;
  103. chart.marginRight = 0;
  104. chart.marginTop = 0;
  105. chart.marginBottom = 0;
  106. graph = new AmCharts.AmGraph();
  107. graph.valueField = "value";
  108. graph.type = "column";
  109. graph.fillAlphas = 1;
  110. graph.lineColor = "#a9ec49";
  111. graph.showBalloon = false;
  112. chart.addGraph(graph);
  113. valueAxis = new AmCharts.ValueAxis();
  114. valueAxis.gridAlpha = 0;
  115. valueAxis.axisAlpha = 0;
  116. chart.addValueAxis(valueAxis);
  117. categoryAxis = chart.categoryAxis;
  118. categoryAxis.gridAlpha = 0;
  119. categoryAxis.axisAlpha = 0;
  120. chart.write("column1");
  121. // line chart, with different line color below zero
  122. chart = new AmCharts.AmSerialChart();
  123. chart.dataProvider = [{
  124. "day": 1,
  125. "value": 120
  126. }, {
  127. "day": 2,
  128. "value": 54
  129. }, {
  130. "day": 3,
  131. "value": -18
  132. }, {
  133. "day": 4,
  134. "value": -12
  135. }, {
  136. "day": 5,
  137. "value": -51
  138. }, {
  139. "day": 6,
  140. "value": 12
  141. }, {
  142. "day": 7,
  143. "value": 56
  144. }, {
  145. "day": 8,
  146. "value": 113
  147. }, {
  148. "day": 9,
  149. "value": 142
  150. }, {
  151. "day": 10,
  152. "value": 125
  153. }];
  154. chart.categoryField = "day";
  155. chart.autoMargins = false;
  156. chart.marginLeft = 0;
  157. chart.marginRight = 5;
  158. chart.marginTop = 0;
  159. chart.marginBottom = 0;
  160. graph = new AmCharts.AmGraph();
  161. graph.valueField = "value";
  162. graph.showBalloon = false;
  163. graph.lineColor = "#ffbf63";
  164. graph.negativeLineColor = "#289eaf";
  165. chart.addGraph(graph);
  166. valueAxis = new AmCharts.ValueAxis();
  167. valueAxis.gridAlpha = 0;
  168. valueAxis.axisAlpha = 0;
  169. chart.addValueAxis(valueAxis);
  170. categoryAxis = chart.categoryAxis;
  171. categoryAxis.gridAlpha = 0;
  172. categoryAxis.axisAlpha = 0;
  173. categoryAxis.startOnAxis = true;
  174. // using guide to show 0 grid
  175. var guide = new AmCharts.Guide();
  176. guide.value = 0;
  177. guide.lineAlpha = 0.1;
  178. valueAxis.addGuide(guide);
  179. chart.write("line2");
  180. // column chart with different negative colors
  181. chart = new AmCharts.AmSerialChart();
  182. chart.dataProvider = [{
  183. "day": 1,
  184. "value": -5
  185. }, {
  186. "day": 2,
  187. "value": 3
  188. }, {
  189. "day": 3,
  190. "value": 7
  191. }, {
  192. "day": 4,
  193. "value": -3
  194. }, {
  195. "day": 5,
  196. "value": 3
  197. }, {
  198. "day": 6,
  199. "value": 4
  200. }, {
  201. "day": 7,
  202. "value": 6
  203. }, {
  204. "day": 8,
  205. "value": -3
  206. }, {
  207. "day": 9,
  208. "value": -2
  209. }, {
  210. "day": 10,
  211. "value": 6
  212. }];
  213. chart.categoryField = "day";
  214. chart.autoMargins = false;
  215. chart.marginLeft = 0;
  216. chart.marginRight = 0;
  217. chart.marginTop = 0;
  218. chart.marginBottom = 0;
  219. graph = new AmCharts.AmGraph();
  220. graph.valueField = "value";
  221. graph.type = "column";
  222. graph.fillAlphas = 1;
  223. graph.showBalloon = false;
  224. graph.lineColor = "#ffbf63";
  225. graph.negativeFillColors = "#289eaf";
  226. graph.negativeLineColor = "#289eaf";
  227. chart.addGraph(graph);
  228. valueAxis = new AmCharts.ValueAxis();
  229. valueAxis.gridAlpha = 0;
  230. valueAxis.axisAlpha = 0;
  231. chart.addValueAxis(valueAxis);
  232. categoryAxis = chart.categoryAxis;
  233. categoryAxis.gridAlpha = 0;
  234. categoryAxis.axisAlpha = 0;
  235. chart.write("column2");
  236. // column chart (thermometer)
  237. chart = new AmCharts.AmSerialChart();
  238. chart.dataProvider = [{
  239. x: 1,
  240. y: 100
  241. }];
  242. chart.categoryField = "x";
  243. chart.rotate = true;
  244. chart.autoMargins = false;
  245. chart.marginLeft = 0;
  246. chart.marginRight = 0;
  247. chart.marginTop = 0;
  248. chart.marginBottom = 0;
  249. graph = new AmCharts.AmGraph();
  250. graph.valueField = "y";
  251. graph.type = "column";
  252. graph.fillAlphas = 1;
  253. graph.fillColors = ["#49cbec", "#f73838"];
  254. graph.gradientOrientation = "horizontal";
  255. graph.lineColor = "#FFFFFF";
  256. graph.showBalloon = false;
  257. chart.addGraph(graph);
  258. valueAxis = new AmCharts.ValueAxis();
  259. valueAxis.gridAlpha = 0;
  260. valueAxis.axisAlpha = 0;
  261. valueAxis.stackType = "100%"; // this is set to achieve that column would occupie 100% of the chart area
  262. chart.addValueAxis(valueAxis);
  263. categoryAxis = chart.categoryAxis;
  264. categoryAxis.gridAlpha = 0;
  265. categoryAxis.axisAlpha = 0;
  266. // guide to show position
  267. guide = new AmCharts.Guide();
  268. guide.value = 66;
  269. guide.lineAlpha = 1;
  270. guide.above = true;
  271. valueAxis.addGuide(guide);
  272. chart.write("thermometer1");
  273. // column chart (thermometer)
  274. chart = new AmCharts.AmSerialChart();
  275. chart.dataProvider = [{
  276. "x": 1,
  277. "y": 100
  278. }];
  279. chart.categoryField = "x";
  280. chart.rotate = true;
  281. chart.autoMargins = false;
  282. chart.marginLeft = 0;
  283. chart.marginRight = 0;
  284. chart.marginTop = 0;
  285. chart.marginBottom = 0;
  286. graph = new AmCharts.AmGraph();
  287. graph.valueField = "y";
  288. graph.type = "column";
  289. graph.fillAlphas = 1;
  290. graph.fillColors = ["#49cbec", "#f73838"];
  291. graph.gradientOrientation = "horizontal";
  292. graph.lineColor = "#FFFFFF";
  293. graph.showBalloon = false;
  294. chart.addGraph(graph);
  295. valueAxis = new AmCharts.ValueAxis();
  296. valueAxis.gridAlpha = 0;
  297. valueAxis.axisAlpha = 0;
  298. valueAxis.stackType = "100%"; // this is set to achieve that column would occupie 100% of the chart area
  299. chart.addValueAxis(valueAxis);
  300. categoryAxis = chart.categoryAxis;
  301. categoryAxis.gridAlpha = 0;
  302. categoryAxis.axisAlpha = 0;
  303. // guide to show position
  304. guide = new AmCharts.Guide();
  305. guide.value = 29;
  306. guide.lineAlpha = 1;
  307. guide.above = true;
  308. valueAxis.addGuide(guide);
  309. chart.write("thermometer2");
  310. // percent chart
  311. chart = new AmCharts.AmSerialChart();
  312. chart.dataProvider = [{
  313. "x": 1,
  314. "y1": 66,
  315. "y2": 34
  316. }];
  317. chart.categoryField = "x";
  318. chart.rotate = true;
  319. chart.autoMargins = false;
  320. chart.marginLeft = 0;
  321. chart.marginRight = 0;
  322. chart.marginTop = 0;
  323. chart.marginBottom = 0;
  324. graph = new AmCharts.AmGraph();
  325. graph.valueField = "y1";
  326. graph.type = "column";
  327. graph.fillAlphas = 0.6;
  328. graph.fillColors = "#000000";
  329. graph.gradientOrientation = "horizontal";
  330. graph.lineColor = "#FFFFFF";
  331. graph.showBalloon = false;
  332. chart.addGraph(graph);
  333. var graph2 = new AmCharts.AmGraph();
  334. graph2.valueField = "y2";
  335. graph2.type = "column";
  336. graph2.fillAlphas = 0.2;
  337. graph2.fillColors = "#000000";
  338. graph2.lineColor = "#FFFFFF";
  339. graph2.showBalloon = false;
  340. chart.addGraph(graph2);
  341. valueAxis = new AmCharts.ValueAxis();
  342. valueAxis.gridAlpha = 0;
  343. valueAxis.axisAlpha = 0;
  344. valueAxis.stackType = "100%"; // this is set to achieve that column would occupie 100% of the chart area
  345. chart.addValueAxis(valueAxis);
  346. categoryAxis = chart.categoryAxis;
  347. categoryAxis.gridAlpha = 0;
  348. categoryAxis.axisAlpha = 0;
  349. chart.write("percent1");
  350. // percent chart
  351. chart = new AmCharts.AmSerialChart();
  352. chart.dataProvider = [{
  353. "x": 1,
  354. "y1": 29,
  355. "y2": 71
  356. }];
  357. chart.categoryField = "x";
  358. chart.rotate = true;
  359. chart.autoMargins = false;
  360. chart.marginLeft = 0;
  361. chart.marginRight = 0;
  362. chart.marginTop = 0;
  363. chart.marginBottom = 0;
  364. graph = new AmCharts.AmGraph();
  365. graph.valueField = "y1";
  366. graph.type = "column";
  367. graph.fillAlphas = 0.6;
  368. graph.fillColors = "#000000";
  369. graph.gradientOrientation = "horizontal";
  370. graph.lineColor = "#FFFFFF";
  371. graph.showBalloon = false;
  372. chart.addGraph(graph);
  373. graph2 = new AmCharts.AmGraph();
  374. graph2.valueField = "y2";
  375. graph2.type = "column";
  376. graph2.fillAlphas = 0.2;
  377. graph2.fillColors = "#000000";
  378. graph2.lineColor = "#FFFFFF";
  379. graph2.showBalloon = false;
  380. chart.addGraph(graph2);
  381. valueAxis = new AmCharts.ValueAxis();
  382. valueAxis.gridAlpha = 0;
  383. valueAxis.axisAlpha = 0;
  384. valueAxis.stackType = "100%"; // this is set to achieve that column would occupie 100% of the chart area
  385. chart.addValueAxis(valueAxis);
  386. categoryAxis = chart.categoryAxis;
  387. categoryAxis.gridAlpha = 0;
  388. categoryAxis.axisAlpha = 0;
  389. chart.write("percent2");
  390. // small pie chart
  391. chart = new AmCharts.AmPieChart();
  392. chart.dataProvider = [{
  393. "x": 1,
  394. "value": 29
  395. }, {
  396. "x": 2,
  397. "value": 71
  398. }];
  399. chart.labelField = "x";
  400. chart.valueField = "value";
  401. chart.labelsEnabled = false;
  402. chart.balloonText = undefined;
  403. chart.valueText = undefined;
  404. chart.radius = 10; // half of a width of a div
  405. chart.colors = ["#DADADA", "#777777"];
  406. chart.startDuration = 0;
  407. chart.write("pie1");
  408. // small pie chart
  409. chart = new AmCharts.AmPieChart();
  410. chart.dataProvider = [{
  411. "x": 1,
  412. "value": 45
  413. }, {
  414. "x": 2,
  415. "value": 55
  416. }];
  417. chart.labelField = "x";
  418. chart.balloonText = undefined;
  419. chart.valueField = "value";
  420. chart.labelsEnabled = false;
  421. chart.valueText = undefined;
  422. chart.radius = 10;
  423. chart.colors = ["#DADADA", "#777777"];
  424. chart.startDuration = 0;
  425. chart.write("pie2");
  426. });
  427. </script>
  428. </head>
  429. <body>
  430. <!-- first chart group -->
  431. <div class="chart-block">
  432. <p><b>Some simple sparklines and micro column chart:</b></p>
  433. Alaska, 120 <div id="line1" style="vertical-align: middle; display: inline-block; width: 100px; height: 30px;"></div> 6% <div id="column1" style="vertical-align: middle;display: inline-block; width: 110px; height: 30px;"></div>
  434. </div>
  435. <!-- second chart group -->
  436. <div class="chart-block">
  437. <p><b>More advanced, with different line and fill colors:</b></p>
  438. Alaska, 120 <div id="line2" style="vertical-align: middle; display: inline-block; width: 100px; height: 30px;"></div> 6% <div id="column2" style="vertical-align: middle;display: inline-block; width: 110px; height: 30px;"></div>
  439. </div>
  440. <!-- third chart group -->
  441. <div class="chart-block">
  442. <p><b>Thermometer example:</b></p>
  443. Alaska, 66% <div id="thermometer1" style="vertical-align: middle; display: inline-block; width: 100px; height: 20px;"></div><br />
  444. Alabama, 39% <div id="thermometer2" style="vertical-align: middle;display: inline-block; width: 100px; height: 20px"></div>
  445. </div>
  446. <!-- fourth chart group -->
  447. <div class="chart-block">
  448. <p><b>Simple percent chart example:</b></p>
  449. Alaska, 66% <div id="percent1" style="vertical-align: middle; display: inline-block; width: 100px; height: 20px;"></div><br />
  450. Alabama, 39% <div id="percent2" style="vertical-align: middle;display: inline-block; width: 100px; height: 20px;"></div>
  451. </div>
  452. <!-- fifth chart group -->
  453. <div class="chart-block">
  454. <p><b>Simple percent chart example:</b></p>
  455. Alaska, 71% <div id="pie1" style="vertical-align: middle; display: inline-block; width: 20px; height: 20px;"></div><br />
  456. Alabama, 45% <div id="pie2" style="vertical-align: middle; display: inline-block; width: 20px; height: 20px;"></div>
  457. </div>
  458. <p>Please note that sparkline charts are NOT usable with the free version of JavaScript Charts due to branding link taking up most of the plot area. Please consider <a href="http://shop.amcharts.com/">acquiring a commercial license</a>. (licenses starting as low as USD 140)</p>
  459. </html>