Search code examples
androidandroid-studiochartsmpandroidchartandroid-typeface

Android mp android chart set type face for XAxisLeft


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?


Solution

  • 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