├── README.md ├── static ├── json │ └── sampledata.json └── js │ ├── my_pie_chart.js │ └── mychart.js └── index.html /README.md: -------------------------------------------------------------------------------- 1 | # Dashboard com Google Charts 2 | 3 | Dashboard JavaScript baseado em [meetup.com/NetCoders][0] 4 | 5 | Feito com [Google Charts][1] 6 | 7 | _Web server for Chrome_ 8 | 9 | [Live Demo][2] 10 | 11 | [0]: https://www.meetup.com/pt-BR/NetCoders/events/235179247/ 12 | [1]: https://developers.google.com/chart/interactive/docs/gallery 13 | [2]: https://rg3915.github.io/dashboard_js/ -------------------------------------------------------------------------------- /static/json/sampledata.json: -------------------------------------------------------------------------------- 1 | { 2 | "cols": [ 3 | {"id":"","label":"Topping","pattern":"","type":"string"}, 4 | {"id":"","label":"Slices","pattern":"","type":"number"} 5 | ], 6 | "rows": [ 7 | {"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]}, 8 | {"c":[{"v":"Onions","f":null},{"v":1,"f":null}]}, 9 | {"c":[{"v":"Olives","f":null},{"v":1,"f":null}]}, 10 | {"c":[{"v":"Zucchini","f":null},{"v":5,"f":null}]}, 11 | {"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]} 12 | ] 13 | } -------------------------------------------------------------------------------- /static/js/my_pie_chart.js: -------------------------------------------------------------------------------- 1 | // Load the Visualization API and the corechart package. 2 | google.charts.load('current', {'packages':['corechart']}); 3 | 4 | // Set a callback to run when the Google Visualization API is loaded. 5 | google.charts.setOnLoadCallback(drawChart); 6 | 7 | function drawChart() { 8 | var jsonData = $.ajax({ 9 | url: "static/json/sampledata.json", 10 | dataType: "json", 11 | async: false 12 | }).responseText; 13 | 14 | // Create our data table out of JSON data loaded from server. 15 | var data = new google.visualization.DataTable(jsonData); 16 | 17 | var options = { 18 | title: 'Title', 19 | is3D: true, 20 | pieSliceText: 'percent', 21 | pieSliceTextStyle: { 22 | color: 'white', 23 | }, 24 | }; 25 | 26 | // Instantiate and draw our chart, passing in some options. 27 | var chart = new google.visualization.PieChart(document.getElementById('pie_chart_div')); 28 | chart.draw(data, options); 29 | } -------------------------------------------------------------------------------- /static/js/mychart.js: -------------------------------------------------------------------------------- 1 | // Load the Visualization API and the corechart package. 2 | google.charts.load('current', {'packages':['corechart']}); 3 | 4 | // Set a callback to run when the Google Visualization API is loaded. 5 | google.charts.setOnLoadCallback(drawChart); 6 | 7 | // Callback that creates and populates a data table, 8 | // instantiates the pie chart, passes in the data and 9 | // draws it. 10 | function drawChart() { 11 | 12 | // Create the data table. 13 | var data = new google.visualization.DataTable(); 14 | data.addColumn('string', 'Topping'); 15 | data.addColumn('number', 'Slices'); 16 | data.addRows([ 17 | ['Mushrooms', 3], 18 | ['Onions', 1], 19 | ['Olives', 1], 20 | ['Zucchini', 1], 21 | ['Pepperoni', 2] 22 | ]); 23 | 24 | // Set chart options 25 | var options = {'title':'How Much Pizza I Ate Last Night', 26 | 'width':400, 27 | 'height':300}; 28 | 29 | // Instantiate and draw our chart, passing in some options. 30 | var chart = new google.visualization.PieChart(document.getElementById('chart_div')); 31 | chart.draw(data, options); 32 | } 33 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Dashboard 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 |
23 |
24 | 49 |
50 |

Dashboard

51 |

52 | This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique. 53 |

54 |

55 | Learn more 56 |

57 |
58 |
59 |
60 |
61 |
62 | 63 |
64 |
65 |
66 | 67 |
68 |
69 |
70 |

71 | Heading 72 |

73 |

74 | Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada magna mollis euismod. Donec sed odio dui. 75 |

76 |

77 | View details » 78 |

79 |
80 |
81 |
82 | 83 | 84 | 85 | --------------------------------------------------------------------------------