Charts: [Swift 3.0 specific] linear line chart has additional line segments wile zooming in

Created on 9 Sep 2016  Â·  15Comments  Â·  Source: danielgindi/Charts

So when testing line chart zooming in Swift 3.0 + Chart 2.2.5,
seeing weird thing:
buggggg

It turned out that Swift 3.0 has totally changed the API signature:
Swift 3.0 is

func strokeLineSegments(between points: [CGPoint])

while swift 2.x is like

CGContextStrokeLineSegments(context, _lineSegments, size)

@danielgindi I am not sure if we should continue using line segments, or we move to old fashion like moveTo, addLineTo.. etc.

I had a simple fix #1420, but it simply destroy _lineSegments to make sure it does not have dirty points to draw, kind of loosing the performance.

Any thoughts?

Most helpful comment

please show us how to use / Fix the new issues in Xcode8 - swift3

All 15 comments

I didn't look at it yet, but what exactly changed? It doesn't draw line segments? Or doesn't accept size?
I think that the reason that I used it was for continuous dash effects. And paths take memory...

it changes API implementation, strokeLineSegments used to take a 'size' parameter, while on swift 3.0, it's gone.

I see the logic that it will use 'size' to determine how many points are actually connected. However, on swift 3.0, it will just connect all the points in the array, so the logic does not work any more if array size is larger than 'size' parameter

You can see from the screenshot, while you zoom in, at right side some additional line segments are drawn.

how to use in Xcode8 with swift3.0

how to use in Xcode8 with swift3.0

please show us how to use / Fix the new issues in Xcode8 - swift3

I updated cocoapods and then did a pod update and got around 200 errors when I set it to use LEGACY swift. But if I set it to use current Swift 3 I get over 1000 errors building.

I manually started fixing the 200 errors in legacy swift but they kept generating new errors each build. It turned into hours of fixing code but there was never any end in sight. Do we have any status update or a guide to show us how to use this library with Swift3/Xcode8?

Please don't hijack other issues. Open another one if anything. But to answer your question, point your podfile to the swift 3.0 branch. There is a lot of documentation on this on the cocoapods website.

try to conver to the swift2.3 and find this root Pod Project -> target Charts -> Building Setting -> Swift Compiler - Version -> Use Legacy swift Language Version set YES, I do these steps then I can run successfully!

hey guys, stop jamming different topics. For all swift 2.3 and 3.0 information please go to #1291.

hey maybe I missed it, is the original bug of this thread fixed in the current Swift-3.0 branch? I'm still seeing those lines
img_5671

@maxydon please try master branch. In Chart 3.0 the code has changed, so the bug should be gone. But Swift3.0 branch had this bug. I have merged #1420 into Swift 3.0 branch, however, you should understand that, this branch is obsoleted, you should move to Chart 3.0.

master sims to have 2.2.5. Where do i find 3.0?

No. master is 3.0. It just isn't final yet so it is not released

I see but it's giving me a lot of errors i guess it's not written in swift 3?!

Charts 3.0 on master is written in Swift 3.0. Please do a git pull to fetch latest or redownload the project.

Was this page helpful?
0 / 5 - 0 ratings