@@ -216,29 +216,26 @@ class BoxCandleStick extends Bar {
216216 let i = indexes . i
217217 let j = indexes . j
218218
219- const candleColors = w . config . plotOptions . candlestick . colors
220- let isPositive = true
221- let realIndex = indexes . 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
228- let color = ''
219+ const { colors : candleColors } = w . config . plotOptions . candlestick
220+ const { colors : boxColors } = this . boxOptions
221+ const realIndex = indexes . realIndex
229222
230- if ( this . isBoxPlot ) {
231- color = [ this . boxOptions . colors . lower , this . boxOptions . colors . upper ]
232- }
223+ const getColor = ( color ) =>
224+ Array . isArray ( color ) ? color [ realIndex ] : color
225+
226+ const colorPos = getColor ( candleColors . upward )
227+ const colorNeg = getColor ( candleColors . downward )
233228
234229 const yRatio = this . yRatio [ indexes . translationsIndex ]
235230
236231 const ohlc = this . getOHLCValue ( realIndex , j )
237232 let l1 = zeroH
238233 let l2 = zeroH
239234
240- if ( ohlc . o > ohlc . c ) {
241- isPositive = false
235+ let color = ohlc . o < ohlc . c ? [ colorPos ] : [ colorNeg ]
236+
237+ if ( this . isBoxPlot ) {
238+ color = [ getColor ( boxColors . lower ) , getColor ( boxColors . upper ) ]
242239 }
243240
244241 let y1 = Math . min ( ohlc . o , ohlc . c )
@@ -336,7 +333,7 @@ class BoxCandleStick extends Bar {
336333 indexes . translationsIndex
337334 ) ,
338335 barXPosition,
339- color : this . isBoxPlot ? color : isPositive ? [ colorPos ] : [ colorNeg ] ,
336+ color,
340337 }
341338 }
342339
0 commit comments