multiple Bars and lines in achartengine

2019-08-11 11:37发布

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条回答
冷血范
2楼-- · 2019-08-11 11:59

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.

查看更多
登录 后发表回答