Skip to content

Commit

Permalink
Feature: Implemented option to control inactive state of points from …
Browse files Browse the repository at this point in the history
…a series level. Touch #9899.
  • Loading branch information
pawelfus committed Mar 19, 2019
1 parent 76437cf commit f86f50f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 24 deletions.
6 changes: 6 additions & 0 deletions js/modules/networkgraph/networkgraph.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ var addEvent = H.addEvent,
* @optionparent plotOptions.networkgraph
*/
seriesType('networkgraph', 'line', {
inactiveOtherPoints: true,
marker: {
enabled: true,
states: {
Expand Down Expand Up @@ -671,6 +672,11 @@ seriesType('networkgraph', 'line', {
} else {
Series.prototype.setState.apply(this, arguments);
}

// If simulation is done, re-render points with new states:
if (!this.layout.simulation && !state) {
this.render();
}
}
}, {
setState: H.NodesMixin.setNodeState,
Expand Down
1 change: 1 addition & 0 deletions js/modules/sankey.src.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ seriesType('sankey', 'column'
/** @ignore-option */
inside: true
},
inactiveOtherPoints: true,
/**
* Opacity for the links between nodes in the sankey diagram or
* dependency wheel.
Expand Down
12 changes: 5 additions & 7 deletions js/parts/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,11 +765,6 @@ extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {

point.firePointEvent('mouseOut');

// Reset all inactive states
chart.series.forEach(function (series) {
series.setState('', true);
});

chart.hoverPoints = chart.hoverPoint = null;
},

Expand Down Expand Up @@ -1098,8 +1093,11 @@ extend(Series.prototype, /** @lends Highcharts.Series.prototype */ {
tooltip.hide();
}

// set normal state
series.setState();
// Reset all inactive states
chart.series.forEach(function (s) {
s.setState('', true);
});

},

/**
Expand Down
1 change: 1 addition & 0 deletions js/parts/PieSeries.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ seriesType('pie', 'line',
*/
ignoreHiddenPoint: true,

inactiveOtherPoints: true,
/**
* The size of the inner diameter for the pie. A size greater than 0
* renders a donut chart. Can be a percentage or pixel value.
Expand Down
23 changes: 14 additions & 9 deletions js/parts/Pointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,24 +561,29 @@ Highcharts.Pointer.prototype = {
}
});

// set normal state to previous series
// Set normal state to previous series
if (chart.hoverSeries !== hoverSeries) {
hoverSeries.onMouseOver();
}

// Do mouseover on all points (#3919, #3985, #4410, #5622)
(points || []).forEach(function (p) {
p.setState('hover');
activeSeries.push(p.series);
});

// Set inactive state for all points
tooltip.chart.series.forEach(function (inactiveSeries) {
if (activeSeries.indexOf(inactiveSeries) === -1) {
activeSeries = (points || []).map(function (item) {
return item.series;
});
chart.series.forEach(function (inactiveSeries) {
if (
inactiveSeries.options.inactiveOtherPoints ||
activeSeries.indexOf(inactiveSeries) === -1
) {
inactiveSeries.setState('inactive', true);
}
});

// Do mouseover on all points (#3919, #3985, #4410, #5622)
(points || []).forEach(function (p) {
p.setState('hover');
});

// If tracking is on series in stead of on each point,
// fire mouseOver on hover point. // #4448
if (chart.hoverPoint) {
Expand Down
21 changes: 13 additions & 8 deletions js/parts/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,19 +827,24 @@ H.Tooltip.prototype = {

// shared tooltip, array is sent over
if (shared && !(point.series && point.series.noSharedTooltip)) {
// Set inactive state for all points
activeSeries = point.map(function (item) {
return item.series;
});
chart.series.forEach(function (inactiveSeries) {
if (
inactiveSeries.options.inactiveOtherPoints ||
activeSeries.indexOf(inactiveSeries) === -1
) {
inactiveSeries.setState('inactive', true);
}
});

// Now set hover state for the choosen ones:
point.forEach(function (item) {
item.setState('hover');

pointConfig.push(item.getLabelConfig());
activeSeries.push(item.series);
});

// Set inactive state for all points
chart.series.forEach(function (inactiveSeries) {
if (activeSeries.indexOf(inactiveSeries) === -1) {
inactiveSeries.setState('inactive', true);
}
});

textConfig = {
Expand Down

0 comments on commit f86f50f

Please sign in to comment.