我有一个包含两组数据的BarChart。一个是蓝色的,一个是绿色的。是否可以为蓝色数据集提供蓝色标记视图,为另一个数据集提供绿色标记视图?
ktca8awb1#
不可以,每个DataSet不能有不同的MarkerView。但是,根据数据集更改标记的背景颜色应该非常容易。只需检查MarkerView的refreshContent(Entry e, int dataSetIndex)方法提供的dataset-index,并相应地以编程方式更改View的背景颜色。
DataSet
MarkerView
refreshContent(Entry e, int dataSetIndex)
View
aamkag612#
除了菲利普的答案之外,这是在新版本的库中可以实现的:
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)}
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)
}
2条答案
按热度按时间ktca8awb1#
不可以,每个
DataSet
不能有不同的MarkerView
。但是,根据数据集更改标记的背景颜色应该非常容易。
只需检查
MarkerView
的refreshContent(Entry e, int dataSetIndex)
方法提供的dataset-index,并相应地以编程方式更改View
的背景颜色。aamkag612#
除了菲利普的答案之外,这是在新版本的库中可以实现的: