Added nv.utils.pjax, while not a required function, its a convenient way of using d3 to do pjax in a VERY simple manor

master-patched
Bob Monteverde 12 years ago
parent d6006ad911
commit 637815f4d8

@ -271,6 +271,30 @@ nv.utils.defaultColor = function(){
}
// From the PJAX example on d3js.org, while this is not really directly needed
// it's a very cool method for doing pjax, I may expand upon it a little bit,
// open to suggestions on anything that may be useful
nv.utils.pjax = function(links, content) {
d3.selectAll(links).on("click", function() {
history.pushState(this.href, this.textContent, this.href);
load(this.href);
d3.event.preventDefault();
});
function load(href) {
d3.html(href, function(fragment) {
var target = d3.select(content).node();
target.parentNode.replaceChild(d3.select(fragment).select(content).node(), target);
nv.utils.pjax(links, content);
});
}
d3.select(window).on("popstate", function() {
if (d3.event.state) load(d3.event.state);
});
}
nv.models.axis = function() {
//Default Settings
var width = 60, //only used for tickLabel currently
@ -6605,7 +6629,7 @@ nv.models.pieChart = function() {
showLegend = true,
color = nv.utils.defaultColor(),
tooltips = true,
tooltip = function(key, y, e, graph) {
tooltip = function(key, y, e, graph) {
return '<h3>' + key + '</h3>' +
'<p>' + y + '</p>'
},
@ -6747,7 +6771,7 @@ nv.models.pieChart = function() {
chart.dispatch = dispatch;
chart.pie = pie; // really just makign the accessible for discretebar.dispatch, may rethink slightly
d3.rebind(chart, pie, 'values', 'x', 'y', 'id', 'showLabels', 'donut', 'labelThreshold');
d3.rebind(chart, pie, 'valueFormat', 'values', 'x', 'y', 'id', 'showLabels', 'donut', 'labelThreshold');
chart.margin = function(_) {

8
nv.d3.min.js vendored

File diff suppressed because one or more lines are too long

@ -58,3 +58,27 @@ nv.utils.defaultColor = function(){
}
// From the PJAX example on d3js.org, while this is not really directly needed
// it's a very cool method for doing pjax, I may expand upon it a little bit,
// open to suggestions on anything that may be useful
nv.utils.pjax = function(links, content) {
d3.selectAll(links).on("click", function() {
history.pushState(this.href, this.textContent, this.href);
load(this.href);
d3.event.preventDefault();
});
function load(href) {
d3.html(href, function(fragment) {
var target = d3.select(content).node();
target.parentNode.replaceChild(d3.select(fragment).select(content).node(), target);
nv.utils.pjax(links, content);
});
}
d3.select(window).on("popstate", function() {
if (d3.event.state) load(d3.event.state);
});
}

Loading…
Cancel
Save