SwiftChart icon indicating copy to clipboard operation
SwiftChart copied to clipboard

Add support for bezier curves

Open gpbl opened this issue 11 years ago • 6 comments

gpbl avatar Nov 07 '14 13:11 gpbl

Is this still up for discussion?

nehayward avatar Oct 09 '16 17:10 nehayward

Sure! I'm not in need of this feature, so the issue is stale until I've some free time to work on it. Maybe you would like to help? 😄

gpbl avatar Oct 09 '16 17:10 gpbl

Ya definitely do you a have a plan for implementation or how you'd do it. I want a make it so it's an easy pr for you.

On Sun, Oct 9, 2016 at 12:47 PM Giampaolo Bellavite < [email protected]> wrote:

Sure! I'm not in need of this feature, so the issue is stale until I've some free time to work on it. Maybe you would like to help? 😄

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gpbl/SwiftChart/issues/5#issuecomment-252500963, or mute the thread https://github.com/notifications/unsubscribe-auth/AGa85irFiJSGgJ4-FXmJKqPL9cOYINihks5qySixgaJpZM4C4T6F .

nehayward avatar Oct 09 '16 17:10 nehayward

Yup this is my idea:

  • It should be an option of the ChartSeries class (can't figure out the name: curved doesn't sound good), e.g. each series can be either a straight line or a curve
  • The curve must work for both area and line charts
  • The curve should change color for positive/negative values (I say "should" because I have no idea how difficult it would be)
  • The Chart class would implement two new drawBezierLine and drawBezierArea fileprivate methods

Basically, this part of the source:

if series.line {
    drawLine(scaledXValues, yValues: scaledYValues, seriesIndex: index)
}
if series.area {
    drawArea(scaledXValues, yValues: scaledYValues, seriesIndex: index)
}

should become something like:

if series.line {
    if series.bezier {
        drawBezierLine(scaledXValues, yValues: scaledYValues, seriesIndex: index)
    } else {
        drawLine(scaledXValues, yValues: scaledYValues, seriesIndex: index)
    }
}
if series.area {
    if series.bezier {
        drawBezierArea(scaledXValues, yValues: scaledYValues, seriesIndex: index)
    } else {
        drawArea(scaledXValues, yValues: scaledYValues, seriesIndex: index)
    }
}

This would be the ideal implementation. If it doesn't work, let discuss it together :)

gpbl avatar Oct 09 '16 18:10 gpbl

Okay I think I got it. I'll submit a pr later, but It's still rough draft :)

nehayward avatar Oct 12 '16 00:10 nehayward

Is this still up for discussion?

libern avatar Feb 08 '19 11:02 libern