MPAndroidChart设置高亮颜色

时间:2015-11-09 21:16:58

标签: android mpandroidchart

只是想知道是否有人想出如何在MPAndroidChart中设置条形图的高亮颜色?目前,它就像深黑色(略微透明)的叠加层。我想让它成为一个白色(有点透明)的叠加层,甚至可能是渐变色。有点像这样:

enter image description here

1 个答案:

答案 0 :(得分:6)

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;
}

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方法将其应用于您的图表(我还没试过)这个人。)

相关问题