Skip to content

Instantly share code, notes, and snippets.

@slawekkolodziej
Created August 21, 2012 15:51
Show Gist options
  • Save slawekkolodziej/3416789 to your computer and use it in GitHub Desktop.
Save slawekkolodziej/3416789 to your computer and use it in GitHub Desktop.
color negative columns in Highstock
(function () {
var originalGetAttribs = Highcharts.seriesTypes.column.prototype.getAttribs;
Highcharts.seriesTypes.column.prototype.getAttribs = function () {
var merge = Highcharts.merge,
series = this,
points = series.points,
stateOptions = series.options.states,
negativeColor = series.options.negativeColor,
threshold = series.options.negativeThreshold,
i = points.length,
seriesNegativePointAttr;
// run original method
originalGetAttribs.call(this);
// do a magic stuff
seriesNegativePointAttr = merge(series.pointAttr);
seriesNegativePointAttr[''].fill = negativeColor;
seriesNegativePointAttr.hover.fill = stateOptions.hover.upColor || negativeColor;
seriesNegativePointAttr.select.fill = stateOptions.select.upColor || negativeColor;
while (i--) {
if (points[i].y < threshold)
points[i].pointAttr = seriesNegativePointAttr;
}
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment