Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <head>
  4. <meta charset="utf-8">
  5. <base href="https://polygit.org/components/">
  6. <script src="webcomponentsjs/webcomponents-lite.min.js"></script>
  7. <link href="polymer/polymer.html" rel="import">
  8. <link href="google-chart/google-chart.html" rel="import">
  9. </head>
  10.  
  11. <body>
  12.  
  13. <dom-module id="x-element">
  14.  
  15. <template>
  16. <style>
  17. google-chart {
  18. width: 100%;
  19. max-height: 300px;
  20. }
  21. </style>
  22. <button on-tap="_show">Show</button>
  23. <google-chart
  24. id="geochart"
  25. type="geo"
  26. options={{options}}
  27. data={{items}}
  28. on-google-chart-select="_onGoogleChartSelect"
  29. ></google-chart>
  30. </template>
  31.  
  32. <script>
  33. (function(){
  34. Polymer({
  35. is: 'x-element',
  36. properties: {
  37. items: {
  38. type: Array,
  39. notify: true,
  40. reflectToAttribute: true,
  41. value: function() {
  42. return [['State', 'Select'], ['Alabama', 0], ['Alaska', 0], ['Arizona', 0], ['Arkansas', 0], ['California', 0], ['Colorado', 0], ['Connecticut', 0], ['Delaware', 0], ['Florida', 0], ['Georgia', 0], ['Hawaii', 0], ['Iowa', 0], ['Idaho', 0], ['Illinois', 0], ['Indiana', 0], ['Kansas', 0], ['Kentucky', 0], ['Louisiana', 0], ['Massachusetts', 0], ['Maryland', 0], ['Maine', 0], ['Michigan', 0], ['Minnesota', 0], ['Missouri', 0], ['Mississippi', 0], ['Montana', 0], ['North Carolina', 0], ['North Dakota', 0], ['Nebraska', 0], ['New Hampshire', 0], ['New Jersey', 0], ['New Mexico', 0], ['Nevada', 0], ['New York', 0], ['Ohio', 0], ['Oklahoma', 0], ['Oregon', 0], ['Pennsylvania', 0], ['Rhode Island', 0], ['South Carolina', 0], ['South Dakota', 0], ['Tennessee', 0], ['Texas', 0], ['Utah', 0], ['Virginia', 0], ['Vermont', 0], ['Washington', 0], ['Wisconsin', 0], ['West Virginia', 0], ['Wyoming', 0]];
  43. }
  44. },
  45. options: {
  46. type: Object,
  47. notify: true,
  48. reflectToAttribute: true,
  49. value: function() {
  50. return {
  51. region: 'US',
  52. displayMode: 'regions',
  53. resolution: 'provinces',
  54. legend: 'none',
  55. defaultColor: '#F5F5F5',
  56. colorAxis: {
  57. colors: ['#F5F5F5', '#455A64'],
  58. minValue: 0,
  59. maxValue: 1,
  60. }
  61. }
  62. }
  63. },
  64. },
  65.  
  66. _onGoogleChartSelect: function(e) {
  67. var str = e.path[0].textContent.split('Select')[0].trim(),
  68. ar = this.items,
  69. i = ar.length;
  70. while(i---1){
  71. if(str === ar[i][0]){
  72. this.set('items.' + i + '.1', ar[i][1] ? 0 : 1);
  73. }
  74. }
  75. console.log(this.items);
  76. },
  77. _show: function() {
  78. console.log(this.items);
  79. },
  80. });
  81. })();
  82. </script>
  83.  
  84. </dom-module>
  85.  
  86. <x-element></x-element>
  87.  
  88. </body>
  89. </html>
  90.  
  91. this.$.geochart._dataTable=this.$.geochart._createDataTable(this.items);
  92. this.$.geochart._chartObject.draw( this.$.geochart._dataTable, this.$.geochart.options);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement