56 lines
1.2 KiB
JavaScript
56 lines
1.2 KiB
JavaScript
Rickshaw.namespace('Rickshaw.Graph.Renderer.ScatterPlot');
|
|
|
|
Rickshaw.Graph.Renderer.ScatterPlot = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
|
|
|
|
name: 'scatterplot',
|
|
|
|
defaults: function($super) {
|
|
|
|
return Rickshaw.extend( $super(), {
|
|
unstack: true,
|
|
fill: true,
|
|
stroke: false,
|
|
padding:{ top: 0.01, right: 0.01, bottom: 0.01, left: 0.01 },
|
|
dotSize: 4
|
|
} );
|
|
},
|
|
|
|
initialize: function($super, args) {
|
|
$super(args);
|
|
},
|
|
|
|
render: function(args) {
|
|
|
|
args = args || {};
|
|
|
|
var graph = this.graph;
|
|
|
|
var series = args.series || graph.series;
|
|
var vis = args.vis || graph.vis;
|
|
|
|
var dotSize = this.dotSize;
|
|
|
|
vis.selectAll('*').remove();
|
|
|
|
series.forEach( function(series) {
|
|
|
|
if (series.disabled) return;
|
|
|
|
var nodes = vis.selectAll("path")
|
|
.data(series.stack.filter( function(d) { return d.y !== null } ))
|
|
.enter().append("svg:circle")
|
|
.attr("cx", function(d) { return graph.x(d.x) })
|
|
.attr("cy", function(d) { return graph.y(d.y) })
|
|
.attr("r", function(d) { return ("r" in d) ? d.r : dotSize});
|
|
if (series.className) {
|
|
nodes.classed(series.className, true);
|
|
}
|
|
|
|
Array.prototype.forEach.call(nodes[0], function(n) {
|
|
n.setAttribute('fill', series.color);
|
|
} );
|
|
|
|
}, this );
|
|
}
|
|
} );
|