ChartsOrg / Charts

Beautiful charts for iOS/tvOS/OSX! The Apple side of the crossplatform MPAndroidChart.
Apache License 2.0
27.59k stars 6k forks source link

CandleStickChartView not showing values properly #4612

Open matantech opened 3 years ago

matantech commented 3 years ago

What did you do?

I tried to create a candleStickChartView with 4 data entries

What did you expect to happen?

I expected to see the candles in proper way, thin shadows and thick green/red candles.

What happened instead?

Both shadows and candles are in the same width and look odd.

Charts Environment

Charts version/Branch/Commit Number: Latest Xcode version: Version 12.4 (12D4e) Swift version: 5 Platform(s) running Charts: iOS, iPhone 8 macOS version running Xcode: Big-Sur

Code snippet:

func initCandleChartStockInfo(lineChartData : [CandleChartDataEntry])
    {
        let set1 = CandleChartDataSet(entries: lineChartData, label: "Candles Chart")
        set1.axisDependency = .left
        let xValuesNumberFormatter = ChartXAxisFormatter()
        let dateFormatter = DateFormatter()
        dateFormatter.dateFormat = "dd/MM/yyyy"
        xValuesNumberFormatter.dateFormatter = dateFormatter
        self.xAxis.valueFormatter = xValuesNumberFormatter
        self.xAxis.labelCount = 4
        self.leftAxis.enabled = Locale.current.languageCode == "he"
        self.rightAxis.enabled = !(Locale.current.languageCode == "he")
        set1.setColor(UIColor(white: 80/255, alpha: 1))
        set1.drawIconsEnabled = false
        set1.shadowColor = .darkGray
        set1.decreasingColor = .green
        set1.increasingColor = .red
        set1.decreasingFilled = true
        set1.increasingFilled = false
        set1.neutralColor = .green
        let data = CandleChartData(dataSet: set1)
        self.data = data
        self.animate(xAxisDuration: 1, yAxisDuration: 1)
    }

Screenshot:

IMG_B2DC5BF2C198-1

matantech commented 3 years ago

I'm still waiting for help! please!

sergeydi commented 3 years ago

I have the same problem. @matantech do you found how to solve it?

matantech commented 2 years ago

I have the same problem. @matantech do you found how to solve it?

I solved it by changing the X Axis values to the array index instead of dates. each object looks like that (index, price) and it solved the issue