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

Multiline chart show only one line chart when x values of datasets are different #4843

Open huynguyencong opened 2 years ago

huynguyencong commented 2 years ago

What did you do?

I was adding a multiline chart to my app using LineChartView, the same code as example code in LineChart2ViewController. The only different thing from the example is datasets has different x values.

What did you expect to happen?

The chart show multilines with different x values.

What happened instead?

Only one line showed, the other lines just show dots. You can reproduce it by update line 96 in the file LineChart2ViewController.swift in the example project, change to i + 1 from i. return ChartDataEntry(x: Double(i + 1), y: val)

Charts Environment

Charts version/Branch/Commit Number: 4.0.3/master/b38b8d45a8cbda9f0f2a3566778ed114f06056b7 Xcode version: 13.2.1 Swift version: 5.5.2 Platform(s) running Charts: iOS macOS version running Xcode: 11.5.2

Demo Project

The demo project is the example project of this library. The only thing I changed is line 96 in the file LineChart2ViewController.swift, to make x value of data set 1 different to the other two data sets. Please build the project, tap Line Chart (Dual YAxis) to see the problem. https://drive.google.com/file/d/1AX-0QbQt8ro_joP2iiDGPksXaWA-l4JI/view?usp=sharing

Screenshots

What I expected: Expected What it happened: Bug What I did: Code

fjgmmg commented 2 years ago

I’m having this issue too. Makes the library not very usable for my use case

TKZwo commented 2 years ago

We have seen this issue too and it is the main reason for us to keep using version 3.6.0 until this Is fixed.

I've determined the linegraphs are calculating some Bounds object which ends up with an internal endpoint of nil and thus returns a range of min = 0, max = 0 and a range of 0 so only the first point gets drawn

fjgmmg commented 2 years ago

@TKZwo thank you! I didn’t realize it was just a problem with the new version. I’ll try the older version.

FelixHerrmann commented 2 years ago

4829 fixes that!

image