wuxudong / react-native-charts-wrapper

a react native charts wrapper (support android & iOS)
2.44k stars 657 forks source link

autoScaleMinMaxEnabled is not working with Candlestick chart in iOS (version 0.5.11) #932

Open jeffy2007 opened 1 year ago

jeffy2007 commented 1 year ago

*Do read files under `lib/` before reporting issues, you can find all the config there, all of them are straightforward.**

Expected Behavior

The candlestick bar height should auto calculate to fit within yAxis range.

Actual Behavior

The candlestick bar height does not follow the min/max yAxis.

Screenshots

Simulator Screen Shot - iPhone 14 - 2023-02-06 at 19 51 42

Data and config

autoScaleMinMaxEnabled={true} visibleRange={{ x: { min: 5, max: 30, }, }}

Specifications

This issue is caused by the issue in Chart library (iOS library used in this library).

The workaround for my case is to manually change the code in CandleChartDataSet.swift.

open override func calcMinMaxY(entry e: ChartDataEntry)
{
    guard let e = e as? CandleChartDataEntry
        else { return }

    // _yMin = Swift.min(e.low, _yMin)
    // _yMax = Swift.max(e.high, _yMin)

    // _yMin = Swift.min(e.low, _yMax)
    // _yMax = Swift.max(e.high, _yMax)

     _yMin = Swift.min(e.high, _yMin)
    _yMax = Swift.max(e.high, _yMax)

    _yMin = Swift.min(e.low, _yMin)
    _yMax = Swift.max(e.low, _yMax)
}
yiweiwoshiniya commented 6 months ago

and scroll up, flash by flash...