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 disable highlight for some specific values #3423

Closed
thang2410199 opened this issue Apr 25, 2018 · 2 comments
Closed

How to disable highlight for some specific values #3423

thang2410199 opened this issue Apr 25, 2018 · 2 comments

Comments

@thang2410199
Copy link

Hi, I want to disable highlighting for some values on the chart, as I use custom marker and want to only show it on certain values.

Is there any way to do it ? Should the ChartViewDelegate have func like chartShouldSelectEntry -> Bool?

Thank you very much

@thang2410199 thang2410199 changed the title How to disable highlight for a specific values How to disable highlight for some specific values Apr 25, 2018
@liuxuan30
Copy link
Member

liuxuan30 commented Apr 26, 2018

ask on stack overflow. For this time, any customizations should be done on your side. We cannot satisfy every requirement. You got the source code.

@JeetGandhi1992
Copy link

May be this can help

open class BarHighlighter: ChartHighlighter
{
    open override func getHighlight(x: CGFloat, y: CGFloat) -> Highlight?
    {
        guard
            let barData = (self.chart as? BarChartDataProvider)?.barData,
            let high = super.getHighlight(x: x, y: y)
            else { return nil }
        
        let pos = getValsForTouch(x: x, y: y)

        if let set = barData.getDataSetByIndex(high.dataSetIndex) as? IBarChartDataSet,
            set.isStacked
        {
            return getStackedHighlight(high: high,
                                       set: set,
                                       xValue: Double(pos.x),
                                       yValue: Double(pos.y))
        }
        else
        {
            guard let set = barData.getDataSetByIndex(high.dataSetIndex) as? IBarChartDataSet else {
                return nil
            }
            var isOutOfBound = true
            for entry in set.entriesForXValue(Double(pos.x.rounded(.up))) {
                if entry.y >= Double(pos.y.rounded(.down)) {
                    isOutOfBound = false
                }
            }
            return isOutOfBound ? nil: high
        }
    }

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