serverchart.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <head>
  9. <title>goog.ui.ServerChart</title>
  10. <link rel="stylesheet" href="css/demo.css">
  11. <script src="../base.js"></script>
  12. <script>
  13. goog.require('goog.ui.ServerChart');
  14. goog.require('goog.dom');
  15. </script>
  16. <script>
  17. var $ = goog.dom.getElement;
  18. function load() {
  19. // Line Chart
  20. chart = new goog.ui.ServerChart(goog.ui.ServerChart.ChartType.LINE);
  21. chart.addDataSet([5,15,10,25,20,49,10,25,34,25,39,44,49,59,44], 'ff0000');
  22. chart.addDataSet([90,92,98,90,52,54,54,43,72,48,51,72,48,51], '0000ff');
  23. chart.setXLabels(['Jan','Feb','Mar','Jun','Jul','Aug']);
  24. chart.setLeftLabels([0,25,50,75,100]);
  25. chart.setRightLabels([0,50,100]);
  26. chart.setMinValue(-50);
  27. chart.decorate($('line_chart'));
  28. // Finance Chart
  29. finance = new goog.ui.ServerChart(goog.ui.ServerChart.ChartType.FINANCE);
  30. finance.setRightLabels(['-0.25%', '0.00%', '+0.25%', '+0.50%']);
  31. finance.setMiscParameter(2);
  32. finance.setMaxValue(100);
  33. finance.setMinValue(0);
  34. finance.addDataSet([43,44,48,49,52,49,48,44,43,52,49,44,43],'da3b15');
  35. finance.addDataSet([72,66,62,49,48,43,44,49,61,67,70,62,64,70], 'f7a10a');
  36. finance.render($('test2'));
  37. // Pie Chart
  38. pie = new goog.ui.ServerChart(goog.ui.ServerChart.ChartType.PIE, 350, 140);
  39. pie.setMinValue(0);
  40. pie.setMaxValue(100);
  41. pie.addDataSet([7,50,3,30,3,8], 'ff9900');
  42. pie.setXLabels(['Internet Explorer 7',
  43. 'Internet Explorer 6',
  44. 'Internet Explorer 5',
  45. 'Firefox',
  46. 'Mozilla',
  47. 'Other']);
  48. pie.render($('test3'));
  49. // Filled Line Chart
  50. filledLine = new goog.ui.ServerChart(
  51. goog.ui.ServerChart.ChartType.FILLEDLINE, 180, 104);
  52. filledLine.addDataSet([11,49,61,61,66,44,61,43], 'FF0000');
  53. filledLine.setLeftLabels(['20K','','60K','','100K']);
  54. filledLine.setXLabels(['M','J','J','A','S','O','N','D','J','F','M','A']);
  55. filledLine.setMaxValue(100);
  56. filledLine.render($('test4'));
  57. // Bar Chart
  58. bar = new goog.ui.ServerChart(goog.ui.ServerChart.ChartType.BAR, 180, 104);
  59. bar.addDataSet([8,23,7], '008000');
  60. bar.addDataSet([31,11,7], 'ffcc33');
  61. bar.addDataSet([2,43,70,3,43,74], '3072f3');
  62. bar.setLeftLabels(['','20K','','60K','','100K']);
  63. bar.setXLabels(['O','N','D']);
  64. bar.setMaxValue(100);
  65. bar.render($('test5'));
  66. // Venn Diagram
  67. var venn = new goog.ui.ServerChart(
  68. goog.ui.ServerChart.ChartType.VENN, 300, 200);
  69. venn.setTitle('Google Employees');
  70. var weights = [80, // Size of circle A
  71. 60, // Size of circle B
  72. 40, // Size of circle C
  73. 20, // Overlap of A and B
  74. 20, // Overlap of A and C
  75. 20, // Overlap of B and C
  76. 5]; // Overlap of A, B and C
  77. var labels = [
  78. 'C Hackers', // Label for A
  79. 'LISP Gurus', // Label for B
  80. 'Java Jockeys']; // Label for C
  81. venn.setVennSeries(weights, labels);
  82. venn.render($('test6'));
  83. }
  84. function updateFinanceChart() {
  85. finance.addDataSet([25,28,31,30,25,21,26,39,36,28,23,26,31,38,39,28,26],'4582e7');
  86. finance.updateChart();
  87. }
  88. </script>
  89. </head>
  90. <body onload="load()">
  91. <h1>goog.ui.ServerChart</h1>
  92. <div id="test1">
  93. <p>Line Chart:</p>
  94. <img id="line_chart"></div>
  95. <div id="test2">
  96. <p>Finance Chart: <a href="javascript:updateFinanceChart()">Add a Line</a>
  97. </p>
  98. </div>
  99. <div id="test3">
  100. <p>Pie Chart:</p>
  101. </div>
  102. <div id="test4">
  103. <p>Filled Line Chart:</p>
  104. </div>
  105. <div id="test5">
  106. <p>Bar Chart:</p>
  107. </div>
  108. <div id="test6">
  109. <p>Venn Diagram:</p>
  110. </div>
  111. </body>
  112. </html>