Android mp android chart set type face for XAxisLeft

Viewed 3682

I have a line chart using the library MPAndroidChart

    mChart.setData(data);
                        mChart.getAxisLeft().setTypeface(MyApplication.giloryItaly);
                        mChart.invalidate();

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

The problem is the AxisLeft font value cannot be changed even when using

mChart.getAxisLeft().setTypeface(MyApplication.giloryItaly);

but works well for XAxis

Any solution how to change font type for AxisLeft and AxisRight?

2 Answers

In you linechart, Use

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

please check Styling / modifying the axis

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