Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Nov 27, 2024
2 parents e14f406 + 25c6db1 commit 2e9a821
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/charts/BoxCandleStick.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,21 +440,26 @@ 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);
return {
o: this.isBoxPlot
? w.globals.seriesCandleH[i][j]
: w.globals.seriesCandleO[i][j],
? h
: o,
h: this.isBoxPlot
? w.globals.seriesCandleO[i][j]
: w.globals.seriesCandleH[i][j],
m: w.globals.seriesCandleM[i][j],
? o
: h,
m: m,
l: this.isBoxPlot
? w.globals.seriesCandleC[i][j]
: w.globals.seriesCandleL[i][j],
? c
: l,
c: this.isBoxPlot
? w.globals.seriesCandleL[i][j]
: w.globals.seriesCandleC[i][j],
? l
: c,
}
}
}
Expand Down
15 changes: 15 additions & 0 deletions src/modules/CoreUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,21 @@ class CoreUtils {

return w.globals.invalidLogScale ? series : w.globals.seriesLog
}

getLogValAtSeriesIndex(val, seriesIndex) {
if (val === null) return null
const w = this.w
let yAxisIndex = w.globals.seriesYAxisReverseMap[seriesIndex]
if (w.config.yaxis[yAxisIndex] && w.config.yaxis[yAxisIndex].logarithmic) {
return this.getLogVal(
w.config.yaxis[yAxisIndex].logBase,
val,
seriesIndex
)
}
return val
}

getBaseLog(base, value) {
return Math.log(value) / Math.log(base)
}
Expand Down

0 comments on commit 2e9a821

Please sign in to comment.