Skip to content

Instantly share code, notes, and snippets.

@slawekkolodziej
Created November 28, 2012 12:41
Show Gist options
  • Save slawekkolodziej/4160984 to your computer and use it in GitHub Desktop.
Save slawekkolodziej/4160984 to your computer and use it in GitHub Desktop.
Fix bug with upColor in highcharts candlesticks
(function(HC){
var seriesTypes = Highcharts.seriesTypes;
seriesTypes.candlestick.prototype.getAttribs = function () {
seriesTypes.column.prototype.getAttribs.apply(this, arguments);
var series = this,
options = series.options,
stateOptions = options.states,
upColor = options.upColor || series.color,
seriesDownPointAttr = HC.merge(series.pointAttr),
upColorProp = series.upColorProp,
points = series.points,
length = points.length,
point, upday;
seriesDownPointAttr[''][upColorProp] = upColor;
seriesDownPointAttr.hover[upColorProp] = stateOptions.hover.upColor || upColor;
seriesDownPointAttr.select[upColorProp] = stateOptions.select.upColor || upColor;
for (var i = 0; i < length; i++) {
point = points[i];
upday = i > 0 ? points[i - 1].close < point.close : point.open < point.close;
if (upday) {
point.pointAttr = seriesDownPointAttr;
}
}
}
}(Highcharts));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment