Multiple Line Label in AChartEngine based BarChart

感情迁移 提交于 2019-12-24 07:35:01

问题


I'm writing an application for Android which contains Bar Charts, The Bar Chart is built by using the AChartEngine API. The X axis label is quite long and overlaps the other labels, I was wondering if it is possible to have a line break in the label or have a multiple line label. I tried going through the API documentation but i found no answers and Google proves to be no better.


回答1:


I dont think you can break xlable directly but i tried to rotate the lables so that they fit the page

renderer.setXLabelsAngle(45f);



回答2:


I was able to do a line break using getTimeChartView. By using \n in format parameter of getTimeChartView, but I am not sure how you can get the same with BarCharts.

mChartView = ChartFactory.getTimeChartView(this, dataset, mRenderer,"HH:mm \n dd-MM");

I am still looking for how to have multiple line labels.




回答3:


I was able to get a multiline label with custom text label.

renderer.ShowCustomTextGrid = true;
renderer.AddXTextLabel (0, "first line \n  second line");


来源:https://stackoverflow.com/questions/6698852/multiple-line-label-in-achartengine-based-barchart

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