用于XAxisLeft的Android mp安卓图表设置类型

时间:2017-10-05 08:35:26

标签: android android-studio charts mpandroidchart android-typeface

我有一个使用库 MPAndroidChart

的折线图
    mChart.setData(data);
                        mChart.getAxisLeft().setTypeface(MyApplication.giloryItaly);
                        mChart.invalidate();

                        mChart.getXAxis().setTypeface(MyApplication.giloryItaly);
                        mChart.getAxisRight().setTypeface(MyApplication.giloryItaly);

问题是即使使用

也无法更改AxisLeft字体值
mChart.getAxisLeft().setTypeface(MyApplication.giloryItaly);

但适用于XAxis

AxisLeftAxisRight?

的任何解决方案如何更改字体类型

2 个答案:

答案 0 :(得分:4)

在你linechart中,使用

LineChart horizontalPChartLine = (LineChart) findViewById(R.id.horizontalPChartLine);
        XAxis xAxis = horizontalPChartLine.getXAxis();
        xAxis.setTypeface(tf);
        xAxis.setTextSize(12f);
        xAxis.setTextColor(ColorTemplate.getHoloBlue());
        xAxis.setEnabled(true);

请检查Styling / modifying the axis

答案 1 :(得分:1)

Paint p = mChart.getPaint(Chart.PAINT_INFO);
p.setTextSize(...);
p.setColor(...);
p.setTypeface(...);