Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
- <script type="text/javascript">
- google.charts.load("visualization", "1", {packages:["corechart"]});
- google.charts.setOnLoadCallback(init);
- function drawChart(myID,titler,known,unknown) {
- var data = google.visualization.arrayToDataTable([
- ['Knowledge', 'Out of 10'],
- ['Known', known],
- ['Unknown', unknown]
- ]);
- var options = {
- title: titler,
- pieHole: 0.7,
- colors: ['#000000', '#cdcdcd'],
- pieSliceText: 'none',
- legend:{position: 'none'},
- tooltip:{text:'percentage'},
- tooltip:{textStyle:{fontSize: 12}}
- };
- var chart = new google.visualization.PieChart(document.getElementById(myID));
- chart.draw(data, options);
- }
- function init(){
- drawChart('donutchart1','VB.NET',8,2);
- drawChart('donutchart2','Javascript',4,6);
- }
- </script>
- <table class="Charts">
- <tr>
- <td><div id="donutchart1" style="width: 256px; height: 256px;"></div></td>
- <td><div id="donutchart2" style="width: 256px; height: 256px;"></div></td>
- </tr>
- </table>
- function centerText(chart, idx, X, Y) {
- idx === 'undefined' || idx === null || idx === NaN ? 0 : idx;
- var cht = document.querySelector(chart);
- var txt = document.querySelectorAll(chart + " text");
- //var chW = cht.width/2;
- //var chH = cht.height/2;
- //var txW = txt[idx].width/2;
- //var txH = txt[idx].height/2;
- //var W = chW - txW;
- //var H = chH - txH;
- txt[idx].setAttribute('x', X);
- txt[idx].setAttribute('y', Y);
- }
- /* chart [string][REQUIRED ]: Id of chart - ex. #donutchart1
- || idx [number][DEFAULT: 0]: Index number of <text>
- || X [number][REQUIRED ]: Set X coordinate of <text>
- || Y [number][REQUIRED ]: Set Y coordinate of <text>
- */
Add Comment
Please, Sign In to add comment