multiple Bars and lines in achartengine

青春壹個敷衍的年華 提交于 2020-01-16 00:41:08

问题


I want to combine 3 bar series and 3 line series in one chart using achartengine.

When I specify the type of chart as BarChart and give it 3 series, things work right. The bars widths are what I set and the spacing and colouring is correct: (see image here: http://i42.tinypic.com/ifu1ap.jpg)

But when I specify the chart type as

mChart = ChartFactory.getCombinedXYChartView(getView().getContext(), mDataset, mRenderer, new String[] {BarChart.TYPE, BarChart.TYPE, BarChart.TYPE, LineChart.TYPE, LineChart.TYPE,LineChart.TYPE });

the bars display on top of each other and the widths aren't right: (see image here: http://i43.tinypic.com/2vum2xv.jpg)

Neither XYMultipleSeriesRenderer.setBarWidth() nor XYSeriesRenderer.setLineWidth() works for the bar widths.

I thought that if I added the XYSeries x values with an offset that I could fix the overlapping bars issue but then the widths of the bars are still not what I set it to be.

Does anyone know (the right way) how to make a chart that shows multiple bar and line series in one chart?


回答1:


You are correct about using an offset to render the bars such as they don't overlap.

However, for spacing them, you need to use renderer.setBarSpacing(2); which means that the space between 2 items in the same series is equal to two times width of one bar.



来源:https://stackoverflow.com/questions/20195585/multiple-bars-and-lines-in-achartengine

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