File size: 2,356 Bytes
c02f046
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
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
'use strict';

/**
 * @ngdoc service
 * @name svgChartsApp.service:SvgChartsSubPlot
 * @description
 * # SvgChartsSubPlot
 * Factory that contains all the properties and methods for a SvgChartsSubPlot
 *
 */
angular.module('svgChartsApp')
  .factory('SvgChartsSubPlot', function (SvgChartsScene) {

    var SvgChartsSubPlot = {};


    /**
     * @ngdoc function
     * @name SvgChartsSubPlot.init
     * @methodOf svgChartsApp.service:SvgChartsSubPlot
     *
     * @description
     * Public access to the GET, PUT, and POST methods
     *
     */
    SvgChartsSubPlot.init =function() {
      this.subPlotPoints = SvgChartsScene.svgContent.append('g')
        .attr('name', 'subPlotPoints');
    };


    /**
     * @ngdoc function
     * @name SvgChartsSubPlot.cleanUp
     * @methodOf svgChartsApp.service:SvgChartsSubPlot
     *
     * @description
     * Public access to the GET, PUT, and POST methods
     *
     */
    SvgChartsSubPlot.cleanUp =function() {
      this.subPlotPoints.selectAll('.subplot-points').remove();
    };


    /**
     * @ngdoc function
     * @name SvgChartsSubPlot.renderSubPlots
     * @methodOf svgChartsApp.service:SvgChartsSubPlot
     *
     * @description
     * Public access to the GET, PUT, and POST methods
     *
     */
    SvgChartsSubPlot.renderSubPlots = function () {

      var subPlots = SvgChartsScene.subPlots;

      if(!subPlots) {
        subPlots = [];
      }

      var subPlotCircles = this.subPlotPoints.selectAll('.subplot-points')
        .data(subPlots);

      subPlotCircles
        .enter()
        .append('circle')
        .attr('style', 'cursor: pointer;')
        .attr('class', 'subplot-points')
        .on('click', function(d) {
          console.log(d);
        });

      subPlotCircles.exit().remove();

      subPlotCircles
        // .transition()
        // .duration(500)
        // .ease("linear")
        .attr('fill', function (d) {
          return d.color || 'black';
        })
        .attr('stroke', function (d) {
          return d.strokeColor || '#fff';
        })
        .attr('cx', function(d) {
          return SvgChartsScene.x(d.date);
        })
        .attr('cy', function (d) {
          return SvgChartsScene.y(d.ask);
        })
        .attr('r', function(d) {
          return d.size || 4;
        });
    };

    return SvgChartsSubPlot;

  });