Blame view

datalets/scatterplot-datalet/scatterplot-datalet.html 3.57 KB
36f11711   mwasiluk   d3 scatterplot-da...
1
2
3
4
5
6
  
  <link rel="import" href="../base-ajax-json-alasql-datalet/base-ajax-json-alasql-datalet.html">
  
  
  <dom-module id="scatterplot-datalet">
      <template>
40c0e489   mwasiluk   charts-d3, d3 sc...
7
          <link rel="stylesheet" href="../../bower_components/charts-d3/dist/charts-d3.min.css">
50380d5a   mwasiluk   d3 scatterplot-da...
8
9
10
11
12
13
14
15
          <style is="custom-style">
              :host ::content #scatterplot-placeholder {
                  width: 100%;
                  height: 70%;
                  background: #ffffff;
                  position: relative;
              }
          </style>
36f11711   mwasiluk   d3 scatterplot-da...
16
17
18
          <div id="scatterplot-placeholder"></div>
          <base-ajax-json-alasql-datalet data-url="{{dataUrl}}" fields="{{fields}}" data="{{data}}" title="{{title}}" description="{{description}}" export_menu="{{export_menu}}"></base-ajax-json-alasql-datalet>
      </template>
36f11711   mwasiluk   d3 scatterplot-da...
19
      <script src="../shared_js/d3.js"></script>
40c0e489   mwasiluk   charts-d3, d3 sc...
20
      <script type="text/javascript" src="../../bower_components/charts-d3/dist/charts-d3.min.js"></script>
36f11711   mwasiluk   d3 scatterplot-da...
21
22
23
      <script>
  
          var ScatterplotBehavior = {
50380d5a   mwasiluk   d3 scatterplot-da...
24
              presentData: function () {
e09a3d19   mwasiluk   charts-d3 update,...
25
                  console.log(this.data);
50380d5a   mwasiluk   d3 scatterplot-da...
26
                  var self =this;
42187739   mwasiluk   updated d3-scatte...
27
                  var data = [];
50380d5a   mwasiluk   d3 scatterplot-da...
28
29
                  for (var j = 0; j < this.data[0]["data"].length; j++) {
                      point = [this.data[0].data[j], this.data[1].data[j]];
e09a3d19   mwasiluk   charts-d3 update,...
30
31
32
                      if(this.data.length == 3){
                          point.push(this.data[2].data[j])
                      }
42187739   mwasiluk   updated d3-scatte...
33
                      data.push(point);
50380d5a   mwasiluk   d3 scatterplot-da...
34
35
                  }
  
50380d5a   mwasiluk   d3 scatterplot-da...
36
37
38
39
40
41
42
43
44
45
46
47
48
49
                  this._component.legend = false;
  
                  var conf = {
  //                    width: 500,
  //                    height: 500,
                      x:{
                          label: self._component.yAxisLabel
                      },
                      y:{
                          label: self._component.yAxisLabel
                      },
                      dot: {
                          // color: 'red'
                      }
e09a3d19   mwasiluk   charts-d3 update,...
50
  
50380d5a   mwasiluk   d3 scatterplot-da...
51
                  };
36f11711   mwasiluk   d3 scatterplot-da...
52
  
42187739   mwasiluk   updated d3-scatte...
53
                  var plot = new D3ScatterPlot("#scatterplot-placeholder", data, conf);
50380d5a   mwasiluk   d3 scatterplot-da...
54
              }
36f11711   mwasiluk   d3 scatterplot-da...
55
56
57
58
59
          };
  
          ScatterplotDatalet = Polymer({
              is: 'scatterplot-datalet',
              properties: {
6b636e83   mwasiluk   scatterplot-datal...
60
61
62
63
                  data: {
                      type: Array,
                      value: undefined
                  },
36f11711   mwasiluk   d3 scatterplot-da...
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
                  xAxisLabel: {
                      type: String,
                      value: ""
                  },
                  yAxisLabel: {
                      type: String,
                      value: ""
                  },
                  behavior : {
                      type : Object,
                      value : {}
                  },
                  /**
                   * Control the export menu
                   * xxxx BITMASK. FROM RIGHT : HTML, PNG, RTF, MY SPACE (eg. 1111 show all, 0000 hide all)
                   *
                   * @attribute export_menu
                   * @type Number
                   * @default 15
                   */
                  export_menu : {
                      type  : Number,
                      value : 15 // xxxx BITMASK. FROM RIGHT : HTML, PNG, RTF, MY SPACE (eg. 1111 show all, 0000 hide all)
                  }
              },
  
              /**
               * 'ready' callback extend the scatterchartComponentBehavior with HighchartsComponentBehavior and scatterchartBehavior
               * and run the Datalet workcycle.
               *
               * @method ready
               */
              ready: function(){
                  this.behavior = $.extend(true, {}, BaseDataletBehavior, WorkcycleBehavior, AjaxJsonAlasqlBehavior, ScatterplotBehavior);
                  this.async(function(){this.behavior.init(this)},0);
              }
          });
      </script>
  </dom-module>