Skip to content

Instantly share code, notes, and snippets.

@sergeylukin
Created May 29, 2013 12:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergeylukin/5669984 to your computer and use it in GitHub Desktop.
Save sergeylukin/5669984 to your computer and use it in GitHub Desktop.
// This patch changes the way Candle's UP state is detected
// Instead of comparing it to the previous candle, we just compare CLOSE and OPEN
// values here
(function(HC) {
var seriesTypes = HC.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,
isUpDay,
point,
i;
seriesDownPointAttr[''][upColorProp] = upColor;
seriesDownPointAttr.hover[upColorProp] = stateOptions.hover.upColor || upColor;
seriesDownPointAttr.select[upColorProp] = stateOptions.select.upColor || upColor;
for (i = 0; i < length; i++) {
point = points[i];
isUpDay = point.close > point.open;
if (isUpDay) {
point.pointAttr = seriesDownPointAttr;
}
}
}
}(Highcharts));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment