MPDandroidChart-是否可以为不同的数据集设置不同的markerView?

2mbi3lxu  于 2023-06-20  发布在  Android
关注(0)|答案(2)|浏览(146)

我有一个包含两组数据的BarChart。一个是蓝色的,一个是绿色的。
是否可以为蓝色数据集提供蓝色标记视图,为另一个数据集提供绿色标记视图?

ktca8awb

ktca8awb1#

不可以,每个DataSet不能有不同的MarkerView
但是,根据数据集更改标记的背景颜色应该非常容易。
只需检查MarkerViewrefreshContent(Entry e, int dataSetIndex)方法提供的dataset-index,并相应地以编程方式更改View的背景颜色。

aamkag61

aamkag612#

除了菲利普的答案之外,这是在新版本的库中可以实现的:

  1. override fun refreshContent(e: Entry, highlight: Highlight) {
  2. // This line will return you index eg,
  3. 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
  4. val index = highlight.dataSetIndex
  5. super.refreshContent(e, highlight)
  6. }

相关问题