Created
August 21, 2012 15:51
-
-
Save slawekkolodziej/3416789 to your computer and use it in GitHub Desktop.
color negative columns in Highstock
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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