Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip Drawing Circles for LineCharts #1795

Closed
denrase opened this issue Nov 6, 2016 · 5 comments
Closed

Skip Drawing Circles for LineCharts #1795

denrase opened this issue Nov 6, 2016 · 5 comments

Comments

@denrase
Copy link

denrase commented Nov 6, 2016

We have encountered a case were we needed to skip the drawing of circles for a line chart. Just using a different colors for those indexes was not sufficient. The solution is implemented simply by providing an array with indexes, which are skipped in the renderer.

/// Prevent circle drawing by index.
var circleIndexesNotToDraw: [Int] { get set }
denrase added a commit to denrase/Charts that referenced this issue Nov 6, 2016
Drawing of circles is skipped by providing indexes that should not be drawn. Indexes are set on the dataset and the renderer skips those.
@liuxuan30
Copy link
Member

liuxuan30 commented Nov 7, 2016

I am not quite clear, why dataSet.drawCirclesEnabled does not work? If you are talking about some circles, not sure if other people has such needs, as it is weird. For only one line, some have circles and some not.. any screenshot to showcase?

@denrase
Copy link
Author

denrase commented Nov 18, 2016

Hello. I should have elaborated our use-case more clearly, sorry for the confusion and the late answer.

So we are drawing a graph where we just just want to draw some circles, for example maxima, minima, or any point of interest really.
We have tried to make this work by setting clear color to the circleColors indexes that we don't want to draw, which worked fine. However, we also wanted to use the circleHoleColor, but it cannot be set as an array. The easy route was to just skip drawing circles that we don't need altogether.
In hindsight, setting circleHoleColors as an array would have been better solution.

Is that sufficient as an explanation? I would also take the time to to implement any suggestion that would get merged and cover our use-case. Or maybe there is already a way in the API to achieve this?

graph_with_points

@liuxuan30
Copy link
Member

you can subclass and add circle hole colors and override the render method to feed your color.

@denrase
Copy link
Author

denrase commented Nov 27, 2016

Hey! We have tried it by overriding the render method, but we needed access to internal properties so that didn't work. But we came up with a simpler solution. We just draw two datasets. One with the lines and a second one with the styled circles. Thank you for your time, consider this issue solved. :)

@liuxuan30
Copy link
Member

liuxuan30 commented Nov 29, 2016

hmm.. I don't know what are the 'internal' properties, I guess when you want to subclass, using source code is the best option to get rid of the 'internal' issues, and you have the code and know the details.
Besides:

    open override func drawExtras(context: CGContext)
    {
        drawCircles(context: context)
    }

This is an open func, so you can override it and feed your own drawCircles()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants