Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. <script type="text/javascript" src="http://www.google.com/jsapi"></script>
  2. <script type="text/javascript">
  3. google.load('visualization', '1', {packages: ['corechart']});
  4. </script>
  5. <script type="text/javascript">
  6. function drawVisualization() {
  7. var data = new google.visualization.DataTable();
  8. data.addColumn('string', 'xAxis');
  9. data.addColumn('number', 'dummySeries');
  10. data.addColumn('number', 'realSeries');
  11.  
  12. data.addRow(['x label', null, 2]); // dummy series value needs to be null, otherwise if interactivity is on, the user can discover the dummy values even if the line is hidden per below
  13. data.addRow(...iterate & add the rest of your data);
  14.  
  15. new google.visualization.LineChart(document.getElementById('graphdiv')).
  16. draw(data, {curveType: 'function',
  17. series:[{lineWidth:0},{targetAxisIndex:1}]} // specify right y-axis for 2nd series, and 'hide' the line for the 1st series as a precaution with lineWidth
  18. );
  19. }
  20.  
  21. google.setOnLoadCallback(drawVisualization);
  22. </script>
  23.  
  24. <script type="text/javascript">
  25. function singleUserChart() {
  26. google.charts.load('current', { packages: ['corechart', 'bar'] });
  27. google.charts.setOnLoadCallback(drawAnnotations);
  28.  
  29. function drawAnnotations() {
  30. var dataPercentage = new google.visualization.DataTable();
  31. dataPercentage.addColumn('string', 'Productivity');
  32. dataPercentage.addColumn('number', 'Ravi');
  33. dataPercentage.addColumn({ type: 'string', role: 'annotation' });
  34. dataPercentage.addColumn('number', 'Avg Data');
  35. dataPercentage.addColumn({ type: 'string', role: 'annotation' });
  36.  
  37. dataPercentage.addRows([
  38. ['%Score1', 12, '12%', 15, '15%'],
  39. ['%Score2', 25, '25%', 21, '21%']
  40. ]);
  41. singleUserChartOptions(dataPercentage, 'individualUserPercentageChart', true, 450);
  42. }
  43. }
  44. function singleUserChartOptions(chartData, chartDivId, isShowPercent, chartWidth) {
  45. var options = {
  46. annotations: {
  47. alwaysOutside: true,
  48. textStyle: {
  49. fontSize: 15,
  50. color: '#000',
  51. auraColor: 'none'
  52. }
  53. },
  54. vAxis: { format: (isShowPercent == true) ? '#'%'' : '', ticks :[0,10,20,30,40,50]},
  55. hAxis: {
  56. slantedText: true,
  57. slantedTextAngle: -45,
  58. textStyle: { fontSize: 11 }
  59. },
  60. series: {
  61. 0: { targetAxisIndex: 0, },
  62. 1: { targetAxisIndex: 1, }
  63. },
  64. vAxes: {
  65. 0: { textPosition: 'none' },
  66. 1: {}
  67. },
  68. legend: { position: 'top' },
  69. width: chartWidth,
  70. height: 400
  71. };
  72.  
  73. var chart = new google.visualization.ColumnChart(document.getElementById(chartDivId));
  74. chart.draw(chartData, options);
  75. }
  76. singleUserChart();
  77. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement