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 dynamically scale up / down data depends on zoom level #1346

Closed
jcmwang opened this issue Aug 22, 2016 · 2 comments
Closed

How to dynamically scale up / down data depends on zoom level #1346

jcmwang opened this issue Aug 22, 2016 · 2 comments

Comments

@jcmwang
Copy link

jcmwang commented Aug 22, 2016

I have data sampled at every second and I want to plot a total of 7 days worth of data on a line graph. Obviously this would be too busy if I show the entire data set so I am looking for a way to implement something that allow me to show dynamically scaled data. Specifically, after the user has performed a zoom action, if I know what the graph's x value range is, then I can re-render the graph using data prepared specific for that range.

In the Android API, there is a callback function called "onChartGestureEnd" but I cant find anything similar for the iOS API. I also dont know how to find the current data range (x range) that is being displayed on the view port.

Thanks in advance if someone can give me a pointer or two.

@liuxuan30
Copy link
Member

liuxuan30 commented Aug 24, 2016

if you are talking about gesture handlers, it's in BarLineChartViewBase. Since v3 is released, you have to take a look at if lowestVisibleXIndex and highestVisibleXIndex work for you, or you have to look at the new implementation.
I remember there are several apis in ChartTransformer or ChartViewPortHandler can do this

@danielgindi
Copy link
Collaborator

For generic gestures, the chart does not provide delegate callbacks, because it does not have to. It's iOS, you can add any gesture recognizers you want dynamically from outside the chart, and do whatever with them.

As for specifics that you do need the chart for - they are implemented.

public protocol ChartViewDelegate
{
    /// Called when a value has been selected inside the chart.
    /// - parameter entry: The selected Entry.
    /// - parameter highlight: The corresponding highlight object that contains information about the highlighted position such as dataSetIndex etc.
    optional func chartValueSelected(chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight)

    // Called when nothing has been selected or an "un-select" has been made.
    optional func chartValueNothingSelected(chartView: ChartViewBase)

    // Callbacks when the chart is scaled / zoomed via pinch zoom gesture.
    optional func chartScaled(chartView: ChartViewBase, scaleX: CGFloat, scaleY: CGFloat)

    // Callbacks when the chart is moved / translated via drag gesture.
    optional func chartTranslated(chartView: ChartViewBase, dX: CGFloat, dY: CGFloat)
}

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

3 participants