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

Multiple Highlight points #4430

Closed
llKoull opened this issue Jul 30, 2020 · 2 comments
Closed

Multiple Highlight points #4430

llKoull opened this issue Jul 30, 2020 · 2 comments

Comments

@llKoull
Copy link

llKoull commented Jul 30, 2020

Hi!

I'm using this awesome library to represent 2 line charts using the same LineChartView.

Is it possible to show the highlight point simultaneously in both lines? It does not mind me if the highlight points are going to be in the same X value at the same time or not (the X values are the same for both lines).

Thanks and best regards,

@bivant
Copy link
Contributor

bivant commented Jul 30, 2020

Hello @llKoull
Renderer supports this.
LineChart2ViewController from examples:

    override func chartValueSelected(_ chartView: ChartViewBase, entry: ChartDataEntry, highlight: Highlight) {
        super.chartValueSelected(chartView, entry: entry, highlight: highlight)

        var secondSetIndex: Int
        if highlight.dataSetIndex == 0
        {
            secondSetIndex = 2 //the second (index == 1) set is red, the selection is not visible enough
        }
        else
        {
            secondSetIndex = 0
        }
        let secondHighlight = Highlight(x: highlight.x, y: highlight.y, dataSetIndex: secondSetIndex, dataIndex: highlight.dataIndex)

        chartView.highlightValues([highlight, secondHighlight])

        self.chartView.centerViewToAnimated(xValue: entry.x, yValue: entry.y,
                                            axis: self.chartView.data!.getDataSetByIndex(highlight.dataSetIndex).axisDependency,
                                            duration: 1)
        //[_chartView moveViewToAnimatedWithXValue:entry.x yValue:entry.y axis:[_chartView.data getDataSetByIndex:dataSetIndex].axisDependency duration:1.0];
        //[_chartView zoomAndCenterViewAnimatedWithScaleX:1.8 scaleY:1.8 xValue:entry.x yValue:entry.y axis:[_chartView.data getDataSetByIndex:dataSetIndex].axisDependency duration:1.0];
    }

image

@llKoull
Copy link
Author

llKoull commented Jul 30, 2020

Hello @bivant !

Thanks for your quick answer i didn't see the method highlightValues!! I'm using it now and it's working perfectly.

Best regards,

@llKoull llKoull closed this as completed Jul 30, 2020
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