Dashboard sipadu mbip
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.

custom-google-chart.js 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. "use strict";
  2. $(document).ready(function() {
  3. //area chart
  4. google.charts.load('current', { 'packages': ['corechart'] });
  5. google.charts.setOnLoadCallback(drawChart);
  6. function drawChart() {
  7. var data = google.visualization.arrayToDataTable([
  8. ['Year', 'Sales', 'Expenses'],
  9. ['2013', 1000, 400],
  10. ['2014', 1170, 460],
  11. ['2015', 660, 1120],
  12. ['2016', 1030, 540]
  13. ]);
  14. var options = {
  15. vAxis: { minValue: 0 },
  16. colors: ['#11c15b', '#ff5252']
  17. };
  18. var chart = new google.visualization.AreaChart(document.getElementById('chart_area'));
  19. chart.draw(data, options);
  20. }
  21. //stacking area chart
  22. google.charts.load('current', { 'packages': ['corechart'] });
  23. google.charts.setOnLoadCallback(drawChartStacking);
  24. function drawChartStacking() {
  25. var data = google.visualization.arrayToDataTable([
  26. ['Year', 'Sales', 'Expenses'],
  27. ['2013', 1000, 400],
  28. ['2014', 1170, 460],
  29. ['2015', 660, 1120],
  30. ['2016', 1030, 540]
  31. ]);
  32. var options_stacked = {
  33. isStacked: true,
  34. height: 300,
  35. legend: { position: 'top', maxLines: 3 },
  36. vAxis: { minValue: 0 },
  37. colors: ['#11c15b', '#536dfe']
  38. };
  39. var chart = new google.visualization.AreaChart(document.getElementById('chart_stacking'));
  40. chart.draw(data, options_stacked);
  41. }
  42. //BAR CHART
  43. google.charts.load('current', { packages: ['corechart', 'bar'] });
  44. google.charts.setOnLoadCallback(drawStacked);
  45. function drawStacked() {
  46. var data = google.visualization.arrayToDataTable([
  47. ['City', '2010 Population', '2000 Population'],
  48. ['New York City, NY', 8175000, 8008000],
  49. ['Los Angeles, CA', 3792000, 3694000],
  50. ['Chicago, IL', 2695000, 2896000],
  51. ['Houston, TX', 2099000, 1953000],
  52. ['Philadelphia, PA', 1526000, 1517000]
  53. ]);
  54. var options = {
  55. title: 'Population of Largest U.S. Cities',
  56. chartArea: { width: '50%' },
  57. isStacked: true,
  58. hAxis: {
  59. title: 'Total Population',
  60. minValue: 0,
  61. },
  62. vAxis: {
  63. title: 'City'
  64. },
  65. colors: ['#11c15b', '#448aff']
  66. };
  67. var chart = new google.visualization.BarChart(document.getElementById('chart_bar'));
  68. chart.draw(data, options);
  69. }
  70. //Bubble Chart
  71. google.charts.load('current', { 'packages': ['corechart'] });
  72. google.charts.setOnLoadCallback(drawSeriesChart);
  73. function drawSeriesChart() {
  74. var data = google.visualization.arrayToDataTable([
  75. ['ID', 'Life Expectancy', 'Fertility Rate', 'Region', 'Population'],
  76. ['CAN', 80.66, 1.67, 'North America', 33739900],
  77. ['DEU', 79.84, 1.36, 'Europe', 81902307],
  78. ['DNK', 78.6, 1.84, 'Europe', 5523095],
  79. ['EGY', 72.73, 2.78, 'Middle East', 79716203],
  80. ['GBR', 80.05, 2, 'Europe', 61801570],
  81. ['IRN', 72.49, 1.7, 'Middle East', 73137148],
  82. ['IRQ', 68.09, 4.77, 'Middle East', 31090763],
  83. ['ISR', 81.55, 2.96, 'Middle East', 7485600],
  84. ['RUS', 68.6, 1.54, 'Europe', 141850000],
  85. ['USA', 78.09, 2.05, 'North America', 307007000]
  86. ]);
  87. var options = {
  88. title: 'Correlation between life expectancy, fertility rate ' +
  89. 'and population of some world countries (2010)',
  90. hAxis: { title: 'Life Expectancy' },
  91. vAxis: { title: 'Fertility Rate' },
  92. bubble: { textStyle: { fontSize: 11 } },
  93. colors: ['#11c15b', '#448aff', '#ff5252']
  94. };
  95. var chart = new google.visualization.BubbleChart(document.getElementById('chart_bubble'));
  96. chart.draw(data, options);
  97. }
  98. //Candlestick charts
  99. google.charts.load('current', { 'packages': ['corechart'] });
  100. google.charts.setOnLoadCallback(drawChartCandlestick);
  101. function drawChartCandlestick() {
  102. var dataCandlestick = google.visualization.arrayToDataTable([
  103. ['Mon', 20, 28, 38, 45],
  104. ['Tue', 31, 38, 55, 66],
  105. ['Wed', 50, 55, 77, 80],
  106. ['Thu', 77, 77, 66, 50],
  107. ['Fri', 68, 66, 22, 15]
  108. // Treat first row as data as well.
  109. ], true);
  110. var optionsCandlestick = {
  111. legend: 'none',
  112. colors: ['#11c15b']
  113. };
  114. var chart = new google.visualization.CandlestickChart(document.getElementById('chart_Candlestick'));
  115. chart.draw(dataCandlestick, optionsCandlestick);
  116. }
  117. //Waterfall charts
  118. google.charts.load('current', { 'packages': ['corechart'] });
  119. google.charts.setOnLoadCallback(drawChartWaterfall);
  120. function drawChartWaterfall() {
  121. var dataWaterfall = google.visualization.arrayToDataTable([
  122. ['Mon', 28, 28, 38, 38],
  123. ['Tue', 38, 38, 55, 55],
  124. ['Wed', 55, 55, 77, 77],
  125. ['Thu', 77, 77, 66, 66],
  126. ['Fri', 66, 66, 22, 22]
  127. // Treat the first row as data.
  128. ], true);
  129. var optionsWaterfall = {
  130. legend: 'none',
  131. bar: { groupWidth: '100%' }, // Remove space between bars.
  132. candlestick: {
  133. fallingColor: { strokeWidth: 0, fill: '#ff5252' }, // red
  134. risingColor: { strokeWidth: 0, fill: '#11c15b' } // green
  135. }
  136. };
  137. var chart = new google.visualization.CandlestickChart(document.getElementById('chart_Waterfall'));
  138. chart.draw(dataWaterfall, optionsWaterfall);
  139. }
  140. //Combo chart
  141. google.charts.load('current', { 'packages': ['corechart'] });
  142. google.charts.setOnLoadCallback(drawVisualization);
  143. function drawVisualization() {
  144. // Some raw data (not necessarily accurate)
  145. var data = google.visualization.arrayToDataTable([
  146. ['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average'],
  147. ['2004/05', 165, 938, 522, 998, 450, 614.6],
  148. ['2005/06', 135, 1120, 599, 1268, 288, 682],
  149. ['2006/07', 157, 1167, 587, 807, 397, 623],
  150. ['2007/08', 139, 1110, 615, 968, 215, 609.4],
  151. ['2008/09', 136, 691, 629, 1026, 366, 569.6]
  152. ]);
  153. var options = {
  154. title: 'Monthly Coffee Production by Country',
  155. vAxis: { title: 'Cups' },
  156. hAxis: { title: 'Month' },
  157. seriesType: 'bars',
  158. series: { 5: { type: 'line' } },
  159. colors: ['#448aff', '#11c15b', '#ffe100', '#FE8A7D', '#69CEC6', '#ff5252']
  160. };
  161. var chart = new google.visualization.ComboChart(document.getElementById('chart_Combo'));
  162. chart.draw(data, options);
  163. }
  164. //Donut chart
  165. google.charts.load("current", { packages: ["corechart"] });
  166. google.charts.setOnLoadCallback(drawChartDonut);
  167. function drawChartDonut() {
  168. var dataDonut = google.visualization.arrayToDataTable([
  169. ['Task', 'Hours per Day'],
  170. ['Work', 11],
  171. ['Eat', 2],
  172. ['Commute', 2],
  173. ['Watch TV', 2],
  174. ['Sleep', 7]
  175. ]);
  176. var optionsDonut = {
  177. title: 'My Daily Activities',
  178. pieHole: 0.4,
  179. colors: ['#448aff', '#11c15b', '#ffe100', '#FE8A7D', '#ff5252']
  180. };
  181. var chart = new google.visualization.PieChart(document.getElementById('chart_Donut'));
  182. chart.draw(dataDonut, optionsDonut);
  183. }
  184. //EXPLOADING A SLICE CHART
  185. google.charts.load("current", { packages: ["corechart"] });
  186. google.charts.setOnLoadCallback(drawChartExploading);
  187. function drawChartExploading() {
  188. var dataExploading = google.visualization.arrayToDataTable([
  189. ['Language', 'Speakers (in millions)'],
  190. ['Assamese', 13],
  191. ['Bengali', 83],
  192. ['Bodo', 1.4],
  193. ['Dogri', 2.3],
  194. ['Gujarati', 46],
  195. ['Hindi', 300],
  196. ['Kannada', 38],
  197. ['Kashmiri', 5.5],
  198. ['Konkani', 5],
  199. ['Maithili', 20],
  200. ['Malayalam', 33],
  201. ['Manipuri', 1.5],
  202. ['Marathi', 72],
  203. ['Nepali', 2.9],
  204. ['Oriya', 33]
  205. ]);
  206. var optionsExploading = {
  207. title: 'Language',
  208. legend: 'none',
  209. pieSliceText: 'label',
  210. slices: {
  211. 4: { offset: 0.2 },
  212. 12: { offset: 0.3 },
  213. 14: { offset: 0.4 },
  214. 15: { offset: 0.5 },
  215. },
  216. colors: ['#448aff', '#11c15b', '#ffe100', '#FE8A7D', '#69CEC6', '#ff5252']
  217. };
  218. var chart = new google.visualization.PieChart(document.getElementById('chart_Exploading'));
  219. chart.draw(dataExploading, optionsExploading);
  220. }
  221. //Slice Visibility Threshold
  222. google.charts.load('current', { 'packages': ['corechart'] });
  223. google.charts.setOnLoadCallback(drawChartThreshold);
  224. function drawChartThreshold() {
  225. var dataThreshold = new google.visualization.DataTable();
  226. dataThreshold.addColumn('string', 'Pizza');
  227. dataThreshold.addColumn('number', 'Populartiy');
  228. dataThreshold.addRows([
  229. ['Pepperoni', 33],
  230. ['Hawaiian', 26],
  231. ['Mushroom', 22],
  232. ['Sausage', 10], // Below limit.
  233. ['Anchovies', 9] // Below limit.
  234. ]);
  235. var optionsThreshold = {
  236. title: 'Popularity of Types of Pizza',
  237. sliceVisibilityThreshold: .2,
  238. colors: ['#448aff', '#11c15b', '#ff5252', '#ffe100']
  239. };
  240. var chart = new google.visualization.PieChart(document.getElementById('chart_Threshold'));
  241. chart.draw(dataThreshold, optionsThreshold);
  242. }
  243. });