MPAndroidChart - Change message “No chart data available”

佐手、 提交于 2019-11-29 06:25:24

问题


Is there any way to change the message "No chart data available" when the chart is not populated?

Edit: Found the answer

chart.setNoDataText("Description that you want");

回答1:


update answer

chart.setNoDataText("Description that you want");



回答2:


If you also want to customize look & feel, you can do it through Paint object:

mChart.setNoDataText("Description that you want");
Paint p = mChart.getPaint(Chart.PAINT_INFO);
p.setTextSize(...);
p.setColor(...);
p.setTypeface(...);
... 



回答3:


The Correct answer is here:

 pie_chart.setNoDataText("No Data Available");
 val paint:Paint =  pie_chart.getPaint(Chart.PAINT_INFO)
 paint.textSize = 40f
 pie_chart.invalidate()

You also set other properties like text color, text typeface etc




回答4:


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_firestore__eintraege__heute);

    mChart = findViewById(R.id.chartZuckerHeute);
    mChart.setNoDataText("PUT IT HERE ON TOP; WORKED FOR ME");



回答5:


You need put pieChart.invalidate() after setNoDataText():

@Override
    public void setDataMessagePieChart() {
        pieChart.setNoDataText("... your message ...");
        pieChart.invalidate();
    }


来源:https://stackoverflow.com/questions/30892275/mpandroidchart-change-message-no-chart-data-available

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!