Blame view

datalets/scatterplot-matrix-datalet/scatterplot-matrix-datalet.html 3.65 KB
fc6c91b0   mwasiluk   d3 scatterplot-ma...
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-matrix-datalet">
      <template>
40c0e489   mwasiluk   charts-d3, d3 sc...
7
          <link rel="stylesheet" href="../../bower_components/charts-d3/dist/charts-d3.min.css">
fc6c91b0   mwasiluk   d3 scatterplot-ma...
8
9
10
11
12
13
14
15
16
17
18
19
          <style is="custom-style">
              :host ::content #scatterplot-placeholder {
                  width: 100%;
  
                  background: #ffffff;
                  position: relative;
              }
          </style>
          <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>
      <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.js"></script>
fc6c91b0   mwasiluk   d3 scatterplot-ma...
21
22
23
24
25
26
27
      <script>
  
          var ScatterplotMatrixBehavior = {
              presentData: function () {
  
                  var self =this;
                  var categories = [];
40c0e489   mwasiluk   charts-d3, d3 sc...
28
  //                console.log(this.data);
fc6c91b0   mwasiluk   d3 scatterplot-ma...
29
30
31
32
33
34
35
36
37
38
39
40
41
  
  
                  var data = [];
                  var traits=[];
                  for (var i = 0; i < this.data[0]["data"].length; i++) {
                      var d ={};
  
                      self.data.forEach(function(serie, serieIndex){
                          d[serie.name] = self.data[serieIndex].data[i]
                      });
                      data.push(d);
                  }
  
fc6c91b0   mwasiluk   d3 scatterplot-ma...
42
43
44
45
46
  
                  var conf = {
                      guides: true,
                      brush: true,
                      tooltip: true,
40c0e489   mwasiluk   charts-d3, d3 sc...
47
48
                      groups: {
                          key: self._component.categoryKey
fc6c91b0   mwasiluk   d3 scatterplot-ma...
49
50
51
52
53
54
55
56
57
                      },
                      margin:{
                          left: 50
                      }
                  };
  
                  if(self._component.cellSize){
                      conf.size=self._component.cellSize;
                  }
fc6c91b0   mwasiluk   d3 scatterplot-ma...
58
59
60
61
62
63
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
103
104
105
106
107
                  var plot = new D3ScatterPlotMatrix("#scatterplot-placeholder", data, conf);
              }
          };
  
          ScatterplotMatrixDatalet = Polymer({
              is: 'scatterplot-matrix-datalet',
              properties: {
                  data: {
                      type: Array,
                      value: undefined
                  },
                  cellSize: {
                      type: Number,
                      value: undefined
                  },
                  categoryKey: {
                      type: String,
                      value: undefined
                  },
                  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, ScatterplotMatrixBehavior);
                  this.async(function(){this.behavior.init(this)},0);
              }
          });
      </script>
  </dom-module>