Issue #68 updated multibar model to standard format

master-patched
Bob Monteverde 12 years ago
parent bdab7c5b50
commit 33823fe24d

@ -2964,6 +2964,8 @@ nv.models.line = function() {
gEnter.append('g').attr('class', 'nv-groups');
gEnter.append('g').attr('class', 'nv-scatterWrap');
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
//------------------------------------------------------------
@ -2978,9 +2980,6 @@ nv.models.line = function() {
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
defsEnter.append('clipPath')
.attr('id', 'nv-edge-clip-' + id)
.append('rect');
@ -4322,29 +4321,35 @@ nv.models.multiBar = function() {
// Public Variables with Default Settings
//------------------------------------------------------------
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960,
height = 500,
x = d3.scale.ordinal(),
y = d3.scale.linear(),
id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one
getX = function(d) { return d.x },
getY = function(d) { return d.y },
forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
clipEdge = true,
stacked = false,
color = nv.utils.defaultColor(),
delay = 1200,
xDomain, yDomain;
var margin = {top: 0, right: 0, bottom: 0, left: 0}
, width = 960
, height = 500
, x = d3.scale.ordinal()
, y = d3.scale.linear()
, id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one
, getX = function(d) { return d.x }
, getY = function(d) { return d.y }
, forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
, clipEdge = true
, stacked = false
, color = nv.utils.defaultColor()
, delay = 1200
, xDomain
, yDomain
, dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout')
;
//============================================================
//============================================================
// Private Variables
//------------------------------------------------------------
//var x = d3.scale.linear(),
var dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout'),
x0, y0;
var x0, y0 //used to store previous scales
;
//============================================================
function chart(selection) {
@ -4353,7 +4358,6 @@ nv.models.multiBar = function() {
availableHeight = height - margin.top - margin.bottom;
if (stacked) {
//var stackedData = d3.layout.stack()
data = d3.layout.stack()
.offset('zero')
.values(function(d){ return d.values })
@ -4362,7 +4366,6 @@ nv.models.multiBar = function() {
}
//add series index to each data point for reference
data = data.map(function(series, i) {
series.values = series.values.map(function(point) {
@ -4373,6 +4376,10 @@ nv.models.multiBar = function() {
});
//------------------------------------------------------------
// Setup Scales
// remap and flatten the data for use in calculating the scales' domains
var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate
data.map(function(d) {
return d.values.map(function(d,i) {
@ -4400,25 +4407,27 @@ nv.models.multiBar = function() {
: y.domain([-1,1]);
//store old scales if they exist
x0 = x0 || x;
y0 = y0 || y;
//------------------------------------------------------------
//------------------------------------------------------------
// Setup containers and skeleton of chart
var wrap = d3.select(this).selectAll('g.nv-wrap.nv-multibar').data([data]);
var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar');
var defsEnter = wrapEnter.append('defs');
var gEnter = wrapEnter.append('g');
var g = wrap.select('g')
gEnter.append('g').attr('class', 'nv-groups');
var g = wrap.select('g')
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
//------------------------------------------------------------
defsEnter.append('clipPath')
@ -4556,10 +4565,6 @@ nv.models.multiBar = function() {
})
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() { chart(selection) };
//store old scales for use in transitions on update
x0 = x.copy();
y0 = y.copy();
@ -4571,7 +4576,7 @@ nv.models.multiBar = function() {
//============================================================
// Global getters and setters
// Expose Public Variables
//------------------------------------------------------------
chart.dispatch = dispatch;
@ -4666,6 +4671,8 @@ nv.models.multiBar = function() {
return chart;
};
//============================================================
return chart;
}
@ -6976,33 +6983,33 @@ nv.models.scatter = function() {
//------------------------------------------------------------
var margin = {top: 0, right: 0, bottom: 0, left: 0}
, width = 960
, height = 500
, color = nv.utils.defaultColor() // chooses color
, id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one
, x = d3.scale.linear()
, y = d3.scale.linear()
, z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area
, getX = function(d) { return d.x } // accessor to get the x value
, getY = function(d) { return d.y } // accessor to get the y value
, getSize = function(d) { return d.size } // accessor to get the point size
, getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape
, forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)
, forceY = [] // List of numbers to Force into the Y scale
, forceSize = [] // List of numbers to Force into the Size scale
, interactive = true // If true, plots a voronoi overlay for advanced point interection
, pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out
, clipEdge = false // if true, masks points within x and y scale
, clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance
, clipRadius = function() { return 25 } // function to get the radius for voronoi point clips
, xDomain = null // Override x domain (skips the calculation from data)
, yDomain = null // Override y domain
, sizeDomain = null // Override point size domain
, sizeRange = null
, singlePoint = false
, dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout')
, useVoronoi = true
;
, width = 960
, height = 500
, color = nv.utils.defaultColor() // chooses color
, id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one
, x = d3.scale.linear()
, y = d3.scale.linear()
, z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area
, getX = function(d) { return d.x } // accessor to get the x value
, getY = function(d) { return d.y } // accessor to get the y value
, getSize = function(d) { return d.size } // accessor to get the point size
, getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape
, forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)
, forceY = [] // List of numbers to Force into the Y scale
, forceSize = [] // List of numbers to Force into the Size scale
, interactive = true // If true, plots a voronoi overlay for advanced point interection
, pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out
, clipEdge = false // if true, masks points within x and y scale
, clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance
, clipRadius = function() { return 25 } // function to get the radius for voronoi point clips
, xDomain = null // Override x domain (skips the calculation from data)
, yDomain = null // Override y domain
, sizeDomain = null // Override point size domain
, sizeRange = null
, singlePoint = false
, dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout')
, useVoronoi = true
;
//============================================================

6
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -70,6 +70,8 @@ nv.models.line = function() {
gEnter.append('g').attr('class', 'nv-groups');
gEnter.append('g').attr('class', 'nv-scatterWrap');
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
//------------------------------------------------------------
@ -84,9 +86,6 @@ nv.models.line = function() {
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
defsEnter.append('clipPath')
.attr('id', 'nv-edge-clip-' + id)
.append('rect');

@ -5,29 +5,35 @@ nv.models.multiBar = function() {
// Public Variables with Default Settings
//------------------------------------------------------------
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = 960,
height = 500,
x = d3.scale.ordinal(),
y = d3.scale.linear(),
id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one
getX = function(d) { return d.x },
getY = function(d) { return d.y },
forceY = [0], // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
clipEdge = true,
stacked = false,
color = nv.utils.defaultColor(),
delay = 1200,
xDomain, yDomain;
var margin = {top: 0, right: 0, bottom: 0, left: 0}
, width = 960
, height = 500
, x = d3.scale.ordinal()
, y = d3.scale.linear()
, id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one
, getX = function(d) { return d.x }
, getY = function(d) { return d.y }
, forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove
, clipEdge = true
, stacked = false
, color = nv.utils.defaultColor()
, delay = 1200
, xDomain
, yDomain
, dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout')
;
//============================================================
//============================================================
// Private Variables
//------------------------------------------------------------
//var x = d3.scale.linear(),
var dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout'),
x0, y0;
var x0, y0 //used to store previous scales
;
//============================================================
function chart(selection) {
@ -36,7 +42,6 @@ nv.models.multiBar = function() {
availableHeight = height - margin.top - margin.bottom;
if (stacked) {
//var stackedData = d3.layout.stack()
data = d3.layout.stack()
.offset('zero')
.values(function(d){ return d.values })
@ -45,7 +50,6 @@ nv.models.multiBar = function() {
}
//add series index to each data point for reference
data = data.map(function(series, i) {
series.values = series.values.map(function(point) {
@ -56,6 +60,10 @@ nv.models.multiBar = function() {
});
//------------------------------------------------------------
// Setup Scales
// remap and flatten the data for use in calculating the scales' domains
var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate
data.map(function(d) {
return d.values.map(function(d,i) {
@ -83,25 +91,27 @@ nv.models.multiBar = function() {
: y.domain([-1,1]);
//store old scales if they exist
x0 = x0 || x;
y0 = y0 || y;
//------------------------------------------------------------
//------------------------------------------------------------
// Setup containers and skeleton of chart
var wrap = d3.select(this).selectAll('g.nv-wrap.nv-multibar').data([data]);
var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar');
var defsEnter = wrapEnter.append('defs');
var gEnter = wrapEnter.append('g');
var g = wrap.select('g')
gEnter.append('g').attr('class', 'nv-groups');
var g = wrap.select('g')
wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')');
//------------------------------------------------------------
defsEnter.append('clipPath')
@ -239,10 +249,6 @@ nv.models.multiBar = function() {
})
//TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection)
chart.update = function() { chart(selection) };
//store old scales for use in transitions on update
x0 = x.copy();
y0 = y.copy();
@ -254,7 +260,7 @@ nv.models.multiBar = function() {
//============================================================
// Global getters and setters
// Expose Public Variables
//------------------------------------------------------------
chart.dispatch = dispatch;
@ -349,6 +355,8 @@ nv.models.multiBar = function() {
return chart;
};
//============================================================
return chart;
}

@ -6,33 +6,33 @@ nv.models.scatter = function() {
//------------------------------------------------------------
var margin = {top: 0, right: 0, bottom: 0, left: 0}
, width = 960
, height = 500
, color = nv.utils.defaultColor() // chooses color
, id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one
, x = d3.scale.linear()
, y = d3.scale.linear()
, z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area
, getX = function(d) { return d.x } // accessor to get the x value
, getY = function(d) { return d.y } // accessor to get the y value
, getSize = function(d) { return d.size } // accessor to get the point size
, getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape
, forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)
, forceY = [] // List of numbers to Force into the Y scale
, forceSize = [] // List of numbers to Force into the Size scale
, interactive = true // If true, plots a voronoi overlay for advanced point interection
, pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out
, clipEdge = false // if true, masks points within x and y scale
, clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance
, clipRadius = function() { return 25 } // function to get the radius for voronoi point clips
, xDomain = null // Override x domain (skips the calculation from data)
, yDomain = null // Override y domain
, sizeDomain = null // Override point size domain
, sizeRange = null
, singlePoint = false
, dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout')
, useVoronoi = true
;
, width = 960
, height = 500
, color = nv.utils.defaultColor() // chooses color
, id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one
, x = d3.scale.linear()
, y = d3.scale.linear()
, z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area
, getX = function(d) { return d.x } // accessor to get the x value
, getY = function(d) { return d.y } // accessor to get the y value
, getSize = function(d) { return d.size } // accessor to get the point size
, getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape
, forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.)
, forceY = [] // List of numbers to Force into the Y scale
, forceSize = [] // List of numbers to Force into the Size scale
, interactive = true // If true, plots a voronoi overlay for advanced point interection
, pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out
, clipEdge = false // if true, masks points within x and y scale
, clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance
, clipRadius = function() { return 25 } // function to get the radius for voronoi point clips
, xDomain = null // Override x domain (skips the calculation from data)
, yDomain = null // Override y domain
, sizeDomain = null // Override point size domain
, sizeRange = null
, singlePoint = false
, dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout')
, useVoronoi = true
;
//============================================================

Loading…
Cancel
Save