ChartView icon indicating copy to clipboard operation
ChartView copied to clipboard

LineView not properly scaling with large values

Open MattGeimer opened this issue 4 years ago • 19 comments

When data array contains values below, the LineView looks how it does below.

[282.502, 284.495, 283.51, 285.019, 285.197, 286.118, 288.737, 288.455, 289.391, 287.691, 285.878, 286.46, 286.252, 284.652, 284.129, 284.188]

Screen Shot 2020-03-06 at 11 19 53 AM

MattGeimer avatar Mar 06 '20 17:03 MattGeimer

with small values as well.

bhrugs avatar Mar 24 '20 02:03 bhrugs

Just found SwiftUICharts and I think it is great! Thank you.

I'm trying to plot a BarChartView on an iPad running 13.4. The data is (x-axis) a date string and y-axis is the daily virus case count.

If I use ChartForm.medium everything works but the view is too small. If I use ChartForm.large the view expands across the screen but the view hight is small and no data shows.

Please can you allow a more flexible view sizing.

Thank you

jwaddilove avatar Mar 30 '20 15:03 jwaddilove

Guys you've just to modify "StepHeight" in each file.

Where you find : return (frame.size.height-padding) / CGFloat(max + min)

Change it whit : return (frame.size.height-padding) / CGFloat(max - min)

It works for me!

antonio-war avatar Apr 06 '20 09:04 antonio-war

Guys you've just to modify "StepHeight" in each file.

Where you find : return (frame.size.height-padding) / CGFloat(max + min)

Change it whit : return (frame.size.height-padding) / CGFloat(max - min)

It works for me!

it does not work for me still facing same problem

techgeeksid avatar Apr 14 '20 04:04 techgeeksid

@antoniowar17 Where do you find that? I looked in LineView but could not find that line.

MattGeimer avatar Apr 16 '20 21:04 MattGeimer

I am experiencing the same issue. Passing in numbers like 1,500 and it just can't figure out how to scale properly

Dylawelt avatar Apr 22 '20 21:04 Dylawelt

@antoniowar17 thanks, this works for me. You have to adjust in both 'Line' and 'Legend'!

VincentBeee avatar Apr 28 '20 08:04 VincentBeee

Can someone please tell me how to edit the package code? Mine is read only

marchantcilliers avatar Jun 02 '20 14:06 marchantcilliers

Is this still an issue with the latest version, on the master branch?

satan87 avatar Jun 02 '20 15:06 satan87

@satan87 I haven’t tried in a while. I’ll check again tonight.

@marchantcilliers I didn’t manage to solve it, but in order to get around the read-only thing, you have to clone the repo, move it to a new directory w/o git, and then add the local copy as a package. (However I don’t recommend since it causes other issues especially with updating to future versions)

MattGeimer avatar Jun 02 '20 17:06 MattGeimer

@MattGeimer Thanks. Let me know and if it's still there I'll take a look

satan87 avatar Jun 02 '20 17:06 satan87

@satan87 @MattGeimer Thanks. I look forward to your replies.

marchantcilliers avatar Jun 02 '20 17:06 marchantcilliers

@satan87 I was still able to replicate the issue. I copy/pasted the data I initially provided in the issue, and got the same result. I am currently using version 1.5.0 w/ a deployment target of iOS 13.5.

Data: [282.502, 284.495, 283.51, 285.019, 285.197, 286.118, 288.737, 288.455, 289.391, 287.691, 285.878, 286.46, 286.252, 284.652, 284.129, 284.188]

Resulting View: Simulator Screen Shot - iPhone 11 Pro - 2020-06-02 at 22 02 41

EDIT: Noticed it was hard to see simulator's view against white background, so swapped sim to dark mode. Black is background, orange it area allocated to the LineView but not being used, and white is the area being used by the LineView.

MattGeimer avatar Jun 03 '20 01:06 MattGeimer

I push a quick fix based on @antoniowar17 's solution. This needs to be reviewed but I'm hoping it will solve your issues for now.

satan87 avatar Jun 03 '20 04:06 satan87

@satan87 I have updated to latest package versions. But there is no change. Should I do something different?

marchantcilliers avatar Jun 03 '20 08:06 marchantcilliers

@marchantcilliers You need to wait for the PR #113 to be merged into the master branch, then you can do the update.

satan87 avatar Jun 03 '20 15:06 satan87

Will this be pulled into V2 or even a better, a way to manually set the scale?

bcbeta avatar Aug 07 '20 19:08 bcbeta

Will this be pulled into V2 or even a better, a way to manually set the scale?

I tested it out about a couple weeks ago, and it seemed to be fixed, but I didn't get enough time to fully test it out.

MattGeimer avatar Aug 07 '20 19:08 MattGeimer

Using the "new-version-beta2" branch this does not appear to be fixed. The scale for values between 52-67 as shown here is way too compressed. Screen Shot 2020-08-07 at 5 55 16 PM

bcbeta avatar Aug 08 '20 00:08 bcbeta