Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.  
  5. <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.3.js"></script>
  6.  
  7. <script type="text/javascript" src="https://www.google.com/jsapi"></script>
  8. <script type="text/javascript">
  9. google.load("visualization", "1", {packages:["corechart"]});
  10. google.setOnLoadCallback(drawChart);
  11.  
  12. $(document).ready(function() {
  13. $.ajax({
  14. type: "GET",
  15. url: "ChartData.xml",
  16. dataType: "xml",
  17. success: function(xml) {
  18. $(xml).find('Pie').each(function() {
  19. var sTitle = $(this).find('Title').text();
  20. var sValue = $(this).find('Value').text();
  21.  
  22. alert (sTitle + sValue);
  23. });
  24. },
  25. error: function() {
  26. alert("An error occurred while processing XML file.");
  27. }
  28. });
  29. });
  30.  
  31. function drawChart() {
  32.  
  33. var data = google.visualization.arrayToDataTable([
  34. ['Task', 'Hours per Day'],
  35. ['Work', 11],
  36. ['Eat', 2],
  37. ['Commute', 2],
  38. ['Watch TV', 2],
  39. ['Sleep', 7]
  40. ]);
  41.  
  42. var options = {
  43. title: 'My Daily Activities'
  44. };
  45.  
  46. var chart = new google.visualization.PieChart(document.getElementById('piechart'));
  47.  
  48. chart.draw(data, options);
  49. }
  50. </script>
  51.  
  52. <title>My Read</title>
  53. </head>
  54.  
  55. <body>
  56. <div id="piechart" style="width: 900px; height: 500px;"></div>
  57. </body>
  58. </html>
  59.  
  60. <?xml version="1.0" encoding="utf-8" ?>
  61. <Chart>
  62. <Pie>
  63. <Title>Work</Title>
  64. <Value>11</Value>
  65. </Pie>
  66. <Pie>
  67. <Title>Eat</Title>
  68. <Value>2</Value>
  69. </Pie>
  70. <Pie>
  71. <Title>Commute</Title>
  72. <Value>2</Value>
  73. </Pie>
  74. <Pie>
  75. <Title>Watch TV</Title>
  76. <Value>2</Value>
  77. </Pie>
  78. <Pie>
  79. <Title>Sleep</Title>
  80. <Value>7</Value>
  81. </Pie>
  82. </Chart>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement