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

Bar chart click on outside of bar calling delegate #2741

Closed
perlasivakrishna opened this issue Aug 21, 2017 · 2 comments
Closed

Bar chart click on outside of bar calling delegate #2741

perlasivakrishna opened this issue Aug 21, 2017 · 2 comments

Comments

@perlasivakrishna
Copy link

perlasivakrishna commented Aug 21, 2017

I implemented bar chart. If i selected out side area of bar also "chartValueSelected delegate"
is calling.

  1. Is there any way to avoid that ?(example https://stackoverflow.com/questions/40232200/charts-get-selected-bar-data-only-when-tapped-inside-the-bar)
  2. Is it possible to achieve the following design, (On click of bar i want to show the y value with arrow as shown in image. click on that want to redirect to seperate view)..
    screen shot 2017-08-21 at 4 39 46 pm

Thank you....

@liuxuan30
Copy link
Member

  1. I remember the current design is choosing the closet entry to highlight. You can take a look at BarHighlighter and maybe override
open func getHighlight(xValue xVal: Double, x: CGFloat, y: CGFloat) -> Highlight?
    {
        guard let chart = chart
            else { return nil }
        
        let closestValues = getHighlights(xValue: xVal, x: x, y: y)
        if closestValues.isEmpty
        {
            return nil
        }
        
        let leftAxisMinDist = getMinimumDistance(closestValues: closestValues, y: y, axis: YAxis.AxisDependency.left)
        let rightAxisMinDist = getMinimumDistance(closestValues: closestValues, y: y, axis: YAxis.AxisDependency.right)
        
        let axis = leftAxisMinDist < rightAxisMinDist ? YAxis.AxisDependency.left : YAxis.AxisDependency.right
        
        let detail = closestSelectionDetailByPixel(closestValues: closestValues, x: x, y: y, axis: axis, minSelectionDistance: chart.maxHighlightDistance)
        
        return detail
    }
  1. You can write your own ChartMarker to show the popup when highlighting

@augustocadini
Copy link

  1. I remember the current design is choosing the closet entry to highlight. You can take a look at BarHighlighter and maybe override
open func getHighlight(xValue xVal: Double, x: CGFloat, y: CGFloat) -> Highlight?
    {
        guard let chart = chart
            else { return nil }
        
        let closestValues = getHighlights(xValue: xVal, x: x, y: y)
        if closestValues.isEmpty
        {
            return nil
        }
        
        let leftAxisMinDist = getMinimumDistance(closestValues: closestValues, y: y, axis: YAxis.AxisDependency.left)
        let rightAxisMinDist = getMinimumDistance(closestValues: closestValues, y: y, axis: YAxis.AxisDependency.right)
        
        let axis = leftAxisMinDist < rightAxisMinDist ? YAxis.AxisDependency.left : YAxis.AxisDependency.right
        
        let detail = closestSelectionDetailByPixel(closestValues: closestValues, x: x, y: y, axis: axis, minSelectionDistance: chart.maxHighlightDistance)
        
        return detail
    }
  1. You can write your own ChartMarker to show the popup when highlighting

You edited this function? I saw the code and actually is different of it.

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