Added the 'highlightPoint' dispatch on nv.models.scatter. This dispatch lets the programmer highlight any point on any series.

Currently used in lineChart to highlight points.
master
Robin Hu 11 years ago
parent dc66846d46
commit 4cbd253c67

@ -305,10 +305,16 @@ nv.models.lineChart = function() {
lines.dispatch.on('elementMouseover.tooltip', function(e) {
e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top];
e.allSeriesData.forEach(function(item, i) {
lines.dispatch.highlightPoint(i, e.pointIndex, true);
});
dispatch.tooltipShow(e);
});
lines.dispatch.on('elementMouseout.tooltip', function(e) {
e.allSeriesData.forEach(function(item, i) {
lines.dispatch.highlightPoint(i, e.pointIndex, false);
});
dispatch.tooltipHide(e);
});

@ -34,7 +34,7 @@ nv.models.scatter = function() {
, sizeDomain = null // Override point size domain
, sizeRange = null
, singlePoint = false
, dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout')
, dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout', 'highlightPoint')
, useVoronoi = true
;
@ -439,17 +439,18 @@ nv.models.scatter = function() {
//============================================================
// Event Handling/Dispatching (out of chart's scope)
//------------------------------------------------------------
dispatch.on('highlightPoint', function(seriesIndex, pointIndex, isHoverOver) {
if (interactive) {
d3.select(".nv-chart-" + id + " .nv-series-" + seriesIndex + " .nv-point-" + pointIndex)
.classed("hover",isHoverOver);
}
});
dispatch.on('elementMouseover.point', function(d) {
if (interactive)
d3.select('.nv-chart-' + id + ' .nv-series-' + d.seriesIndex + ' .nv-point-' + d.pointIndex)
.classed('hover', true);
dispatch.highlightPoint(d.seriesIndex,d.pointIndex,true);
});
dispatch.on('elementMouseout.point', function(d) {
if (interactive)
d3.select('.nv-chart-' + id + ' .nv-series-' + d.seriesIndex + ' .nv-point-' + d.pointIndex)
.classed('hover', false);
dispatch.highlightPoint(d.seriesIndex,d.pointIndex,false);
});
//============================================================

@ -388,6 +388,7 @@ svg .title {
transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
-moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
-webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear;
}
.nvd3.nv-scatter .nv-groups .nv-point.hover,

Loading…
Cancel
Save