Debian Codegraph @

src/js/Rickshaw.Graph.Renderer.ScatterPlot.js

raw
1 Rickshaw.namespace('Rickshaw.Graph.Renderer.ScatterPlot');
2
3 Rickshaw.Graph.Renderer.ScatterPlot = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
4
5 name: 'scatterplot',
6
7 defaults: function($super) {
8
9 return Rickshaw.extend( $super(), {
10 unstack: true,
11 fill: true,
12 stroke: false,
13 padding:{ top: 0.01, right: 0.01, bottom: 0.01, left: 0.01 },
14 dotSize: 4
15 } );
16 },
17
18 initialize: function($super, args) {
19 $super(args);
20 },
21
22 render: function(args) {
23
24 args = args || {};
25
26 var graph = this.graph;
27
28 var series = args.series || graph.series;
29 var vis = args.vis || graph.vis;
30
31 var dotSize = this.dotSize;
32
33 vis.selectAll('*').remove();
34
35 series.forEach( function(series) {
36
37 if (series.disabled) return;
38
39 var nodes = vis.selectAll("path")
40 .data(series.stack.filter( function(d) { return d.y !== null } ))
41 .enter().append("svg:circle")
42 .attr("cx", function(d) { return graph.x(d.x) })
43 .attr("cy", function(d) { return graph.y(d.y) })
44 .attr("r", function(d) { return ("r" in d) ? d.r : dotSize});
45 if (series.className) {
46 nodes.classed(series.className, true);
47 }
48
49 Array.prototype.forEach.call(nodes[0], function(n) {
50 n.setAttribute('fill', series.color);
51 } );
52
53 }, this );
54 }
55 } );