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

How to show/hide one of the line chart during runtime #1381

Closed
nonameplum opened this issue Aug 31, 2016 · 3 comments
Closed

How to show/hide one of the line chart during runtime #1381

nonameplum opened this issue Aug 31, 2016 · 3 comments

Comments

@nonameplum
Copy link

nonameplum commented Aug 31, 2016

Hi,

I have UISwitches in the UI that allow a user show/hide (3) lines of the linechart.
At the beginning I want to show only one line chart when viewDidLoad. But the problem is that hiding during viewDidLoad is not working. When view is loaded and user is changing visibility of the lines using switches then it works.

func showLine(label: String, visible: String) {
    lineChartView.data?.getDataSetByLabel(label, ignorecase: false)?.visible = visible
    lineChartView.setNeedsDisplay()
}

When I move code from the viewDidLoad to the viewDidAppear then it also works but there is visual side effect that user sees that line are hiding which I would like to avoid.

I found that there is also another way using ugly hack. When I wrap body of the showLine method to the dispatch_after with e.g. 0.2 sec.

Is there a way to resolve this problem?

@liuxuan30
Copy link
Member

are you hiding specific lines or line chart views, I am confused.

@nonameplum
Copy link
Author

Exactly. I want to hide only specific lines

@liuxuan30
Copy link
Member

Either add/remove the specific line chart data sets or leverage

    /// Set the visibility of this DataSet. If not visible, the DataSet will not be drawn to the chart upon refreshing it.
    var visible: Bool { get set }

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