Izaak Prats
Izaak Prats

Reputation: 159

MPAndroidChart - Is it possible to set different markerViews for different dataSets?

I have a BarChart with two sets of data. One is blue and one is green.

Is it possible to have a blue Marker View for the blue dataset and a green Marker View for the other?

Upvotes: 2

Views: 2045

Answers (2)

Hussain Shabbir
Hussain Shabbir

Reputation: 15015

In addition to the Phillip's answer this is something can be achieved in the new version of library:-

 override fun refreshContent(e: Entry, highlight: Highlight) {
        // This line will return you index eg, 
    if you have two datasets then below index will be returned as 0 and 1 and based on this you can identify and change color or style of your marker view
   val index = highlight.dataSetIndex
   super.refreshContent(e, highlight)
}

Upvotes: 1

Philipp Jahoda
Philipp Jahoda

Reputation: 51411

No, it is not possible to have a different MarkerView for each DataSet.

However, it should be pretty easy to change the background-color of the marker depending on the dataset.

Just check for the dataset-index delivered by the refreshContent(Entry e, int dataSetIndex) method of the MarkerView and programmatically change the background-color of the View accordingly.

Upvotes: 1

Related Questions