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

Obtaining current number of points being rendered in zoomed viewing window #2752

Closed
kzhaowmm opened this issue Aug 28, 2017 · 1 comment
Closed

Comments

@kzhaowmm
Copy link

kzhaowmm commented Aug 28, 2017

Is there a method to obtain the total number of points being rendered by the chart within a particular viewport scale (or zoom level)?

There seems to be a more inaccurate method of calculating, such as taking the total number of points being fed into the chart and dividing the by the X viewport scale....but this is not exact and I'd like to see if there is another alternative.

Thanks!

@liuxuan30
Copy link
Member

liuxuan30 commented Aug 29, 2017

I don't see a method doing this if I remember correctly.

but there is something similar:

    open var lowestVisibleX: Double
    {
        var pt = CGPoint(
            x: viewPortHandler.contentLeft,
            y: viewPortHandler.contentBottom)
        
        getTransformer(forAxis: .left).pixelToValues(&pt)
        
        return max(xAxis._axisMinimum, Double(pt.x))
    }
    
    /// - returns: The highest x-index (value on the x-axis) that is still visible on the chart.
    open var highestVisibleX: Double
    {
        var pt = CGPoint(
            x: viewPortHandler.contentRight,
            y: viewPortHandler.contentBottom)
        
        getTransformer(forAxis: .left).pixelToValues(&pt)

        return min(xAxis._axisMaximum, Double(pt.x))
    }

This returns the highest and lowest visible X value, and you can then get how many x values are rendered, you can calculate how many entries you have for each x.

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