mpandroidchart LimitLine 设置透明线并更改标签颜色
mpandroidchart LimitLine set transparent line and change label color
(此题适用于 MPAndroidChart-1.7.4)
我喜欢使用 mpandroidchart
库为我的 android 应用程序创建绘图,但我现在在使用 LimitLine
对象时遇到了一些困难。我正在尝试将行设置为 transparent
并将标签设置为白色,字体更大。可能吗?我知道现在没有任何现有方法可以做到这一点,但只是想知道是否有任何方法可以让我自己定制它?任何帮助都会很棒!谢谢。
注意:这是我的第一个 post 所以我不能在这里附上图片。我希望对 mpandroidchart
.
有经验的人清楚我的问题
LimitLine ll1 = new LimitLine((float) (values[1]*maxFactor));
ll1.setLineWidth(1.5f);
ll1.setDrawValue(true);
ll1.setLineColor(res.getColor(R.color.new_orange));
ll1.setLabelPosition(LimitLabelPosition.RIGHT);
你可以这样做:
ll1.setLineColor(getResources().getColor(R.color.transparent));
请先定义透明色:
<color name="transparent">#00000000</color>
标签的颜色与线条的颜色相同。所以,你不能同时改变白色和透明线。
要更改字体,您可以对所有图表执行此操作。
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
chart.setValueTypeface(tf);
chart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));
(此题适用于 MPAndroidChart-1.7.4)
我喜欢使用 mpandroidchart
库为我的 android 应用程序创建绘图,但我现在在使用 LimitLine
对象时遇到了一些困难。我正在尝试将行设置为 transparent
并将标签设置为白色,字体更大。可能吗?我知道现在没有任何现有方法可以做到这一点,但只是想知道是否有任何方法可以让我自己定制它?任何帮助都会很棒!谢谢。
注意:这是我的第一个 post 所以我不能在这里附上图片。我希望对 mpandroidchart
.
LimitLine ll1 = new LimitLine((float) (values[1]*maxFactor));
ll1.setLineWidth(1.5f);
ll1.setDrawValue(true);
ll1.setLineColor(res.getColor(R.color.new_orange));
ll1.setLabelPosition(LimitLabelPosition.RIGHT);
你可以这样做:
ll1.setLineColor(getResources().getColor(R.color.transparent));
请先定义透明色:
<color name="transparent">#00000000</color>
标签的颜色与线条的颜色相同。所以,你不能同时改变白色和透明线。
要更改字体,您可以对所有图表执行此操作。
Typeface tf = Typeface.createFromAsset(getAssets(), "OpenSans-Regular.ttf");
chart.setValueTypeface(tf);
chart.setCenterTextTypeface(Typeface.createFromAsset(getAssets(), "OpenSans-Light.ttf"));