File size: 1,586 Bytes
b3787d8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
define(['LayerBase'], function(LayerBase) {
  PointLayer = function(options) {
    if(options)this.init(options);
  };
  PointLayer.prototype = new LayerBase();

  PointLayer.prototype.prep = function() {
    this.config.data = this.plot.data();
    this.config.dur = this.plot.duration();
    this.config.delay = this.plot.delay();
    this.config.scales = this.plot.scales();
    this.config.attrs = this.CompileAttrs(this.config.attrs);

    this.config.elements.forEach(function(elem){
      elem.type =  elem.type || 'circle';
      elem.initAttrs = {
        class:elem.type+"-"+this.config.kind,
        opacity: 1e-6
      };
      if(elem.type == 'circle') elem.initAttrs.r = this.plot.radius.min();
    }, this);
  };

  PointLayer.prototype.update = function() {
    var c = this.config;

    c.elements.forEach(function(e){
      var attrs = this.CompileAttrs(e.attrs),
          elem;

      if(e.static) initAttrs = {};
      c.group
        .selectAll(e.type+".enter")
        .classed('enter',false)
        .attr(attrs)
        .attr(e.initAttrs)
        .text((e.type == 'text'? e.text : null) );

      elem = c.group.selectAll(e.type);

      elem
        .interrupt()
        .transition()
        .delay(c.delay)
        .duration(c.dur)
          .attr("opacity", 1)
          .attr(attrs);

      c.layerElem
        .selectAll( c.groupType+"."+c.name+"-item.exit")
        .selectAll(e.type)
          .interrupt()
          .transition()
          .duration(c.dur)
          .attr(e.initAttrs)
          .remove();
    }, this);
  };

  return PointLayer;
});