MPAndroidChart Bar chart start from non zero Y or Column Range chart

随声附和 提交于 2019-12-20 07:26:36

问题


I am using MPAndroidChart for drawing a Combined graph (with a bar chart and line chart).

I want to display a "Column Range Chart" - a bar chart whose starting point will be variable for each entries, as shown in the below image,

How is it possible to achieve this using MPAndroidChart.


回答1:


Try with CandleStickChart. It's main purpose it to show financial data. Your problem might be with highest/lowest (shadow) open or closing values, it might require to play with them to achieve what you want.

A quick sample:

CandleStickChart candleStickChart = (CandleStickChart) findViewById(R.id.chart);</p>
ArrayList<CandleEntry> entries = new ArrayList<>
entries.add(new CandleEntry(0, 2.70f, 4.13f, 2.70f, 4.13f));
entries.add(new CandleEntry(1, 3.35f, 4.96f, 3.35f, 4.96f));
entries.add(new CandleEntry(2, 3.50f, 4.50f, 3.50f, 4.50f));
entries.add(new CandleEntry(3, 4.40f, 5.0f, 4.40f, 5.0f));
entries.add(new CandleEntry(4, 2.80f, 4.5f, 2.80f, 4.5f));

Notice that second/fourth third/fifth parameter in CandleEntry constructor are the same to eliminate shadow values.

Tutorial on how to use it is here

More info: You might have a problem with drawing vertical data values, this might not be possible.



来源:https://stackoverflow.com/questions/39764176/mpandroidchart-bar-chart-start-from-non-zero-y-or-column-range-chart

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