MPAndroidChart设置高亮颜色

4

想知道是否有人已经发现如何设置MPAndroidChart中柱状图的高亮颜色?目前它是一种类似于深黑色(有点透明)的叠加层。我希望将其改为白色(有点透明)的叠加层,甚至可能是渐变的。就像这样:

enter image description here

1个回答

8
< p > BarDataSet 扩展自 BarLineScatterCandleBubbleDataSet,后者具有 setHighLightColor 方法:
/**
 * Sets the color that is used for drawing the highlight indicators. Dont
 * forget to resolve the color using getResources().getColor(...) or
 * Color.rgb(...).
 * 
 * @param color
 */
public void setHighLightColor(int color) {
    mHighLightColor = color;
}
< p > BarDataSet 还有一个 setHighLightAlpha 方法:

/**
 * Set the alpha value (transparency) that is used for drawing the highlight
 * indicator bar. min = 0 (fully transparent), max = 255 (fully opaque)
 * 
 * @param alpha
 */
public void setHighLightAlpha(int alpha) {
    mHighLightAlpha = alpha;
}

这两种方法都不支持渐变,但您可以更改高亮的外观。

如果您想要实现渐变高亮,可以扩展BarChartRenderer并覆盖drawHighlighted(Canvas c, Highlight[] indices)方法,并通过setRenderer方法将其应用于您的图表(我个人没有尝试过这样做)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接