Skip to content

Commit

Permalink
improve PR#4836; candlestick colors for multiseries
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Dec 2, 2024
1 parent a3ae79b commit c7dbc6a
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/charts/BoxCandleStick.js
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,15 @@ class BoxCandleStick extends Bar {
let i = indexes.i
let j = indexes.j

const candleColors = w.config.plotOptions.candlestick.colors
let isPositive = true
let realIndex = indexes.realIndex
let colorPos = w.config.plotOptions.candlestick.colors.upward[realIndex]
let colorNeg = w.config.plotOptions.candlestick.colors.downward[realIndex]
let colorPos = Array.isArray(candleColors.upward)
? candleColors.upward[realIndex]
: candleColors.upward
let colorNeg = Array.isArray(candleColors.downward)
? candleColors.downward[realIndex]
: candleColors.downward
let color = ''

if (this.isBoxPlot) {
Expand Down Expand Up @@ -441,25 +446,17 @@ class BoxCandleStick extends Bar {
getOHLCValue(i, j) {
const w = this.w
const coreUtils = new CoreUtils(this.ctx, w)
const h = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleH[i][j], i);
const o = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleO[i][j], i);
const m = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleM[i][j], i);
const c = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleC[i][j], i);
const l = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleL[i][j], i);
const h = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleH[i][j], i)
const o = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleO[i][j], i)
const m = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleM[i][j], i)
const c = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleC[i][j], i)
const l = coreUtils.getLogValAtSeriesIndex(w.globals.seriesCandleL[i][j], i)
return {
o: this.isBoxPlot
? h
: o,
h: this.isBoxPlot
? o
: h,
o: this.isBoxPlot ? h : o,
h: this.isBoxPlot ? o : h,
m: m,
l: this.isBoxPlot
? c
: l,
c: this.isBoxPlot
? l
: c,
l: this.isBoxPlot ? c : l,
c: this.isBoxPlot ? l : c,
}
}
}
Expand Down

0 comments on commit c7dbc6a

Please sign in to comment.