Skip to content

Commit c7dbc6a

Browse files
committed
improve PR#4836; candlestick colors for multiseries
1 parent a3ae79b commit c7dbc6a

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

src/charts/BoxCandleStick.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,15 @@ class BoxCandleStick extends Bar {
216216
let i = indexes.i
217217
let j = indexes.j
218218

219+
const candleColors = w.config.plotOptions.candlestick.colors
219220
let isPositive = true
220221
let realIndex = indexes.realIndex
221-
let colorPos = w.config.plotOptions.candlestick.colors.upward[realIndex]
222-
let colorNeg = w.config.plotOptions.candlestick.colors.downward[realIndex]
222+
let colorPos = Array.isArray(candleColors.upward)
223+
? candleColors.upward[realIndex]
224+
: candleColors.upward
225+
let colorNeg = Array.isArray(candleColors.downward)
226+
? candleColors.downward[realIndex]
227+
: candleColors.downward
223228
let color = ''
224229

225230
if (this.isBoxPlot) {
@@ -441,25 +446,17 @@ class BoxCandleStick extends Bar {
441446
getOHLCValue(i, j) {
442447
const w = this.w
443448
const coreUtils = new CoreUtils(this.ctx, w)
444-
const h = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleH[i][j], i);
445-
const o = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleO[i][j], i);
446-
const m = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleM[i][j], i);
447-
const c = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleC[i][j], i);
448-
const l = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleL[i][j], i);
449+
const h = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleH[i][j], i)
450+
const o = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleO[i][j], i)
451+
const m = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleM[i][j], i)
452+
const c = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleC[i][j], i)
453+
const l = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleL[i][j], i)
449454
return {
450-
o: this.isBoxPlot
451-
? h
452-
: o,
453-
h: this.isBoxPlot
454-
? o
455-
: h,
455+
o: this.isBoxPlot ? h : o,
456+
h: this.isBoxPlot ? o : h,
456457
m: m,
457-
l: this.isBoxPlot
458-
? c
459-
: l,
460-
c: this.isBoxPlot
461-
? l
462-
: c,
458+
l: this.isBoxPlot ? c : l,
459+
c: this.isBoxPlot ? l : c,
463460
}
464461
}
465462
}

0 commit comments

Comments
 (0)