MPAndroidChart如何设置标签颜色? [英] MPAndroidChart how to set label color?

查看:58
本文介绍了MPAndroidChart如何设置标签颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获得以下代码:

    graph = (LineChart) convertView.findViewById(R.id.graph);
    graph.getPaint(Chart.PAINT_LEGEND_LABEL).setColor(Color.BLUE);
    graph.getPaint(Chart.PAINT_YLABEL).setColor(Color.BLUE);
    graph.getPaint(Chart.PAINT_XLABEL).setColor(Color.BLUE);

但是X/Y值标签的颜色以及图例的标签仍然保持黑色.我想念什么吗?还有其他设置颜色的方法吗?

But still the color of X/Y-value-lables and also the lable of the legend stay in black color. Do I miss something? Is there an other way to set the color of these?

例如,此行有效并导致每个数据点的蓝色值标签:

This line for example works and results in blue value-lables for each data-point:

    graph.getPaint(Chart.PAINT_VALUES).setColor(Color.BLUE);

提前谢谢!

推荐答案

尝试设置轴和图例的颜色:

Try this to set the colors of axis and legend:

chart.getAxisLeft().setTextColor(...); // left y-axis
chart.getXAxis().setTextColor(...);
chart.getLegend().setTextColor(...);

如果要设置图表内绘制值的颜色,请检查设置颜色文档或设置数据文档.

If you want to set the color of the drawn values inside the chart, check out the setting colors documentation or the setting data documentation.

这篇关于MPAndroidChart如何设置标签颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆