问题
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