MPAndroidChart Bar chart start from non zero Y or

2020-04-30 18:07发布

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,

Column Range chart

How is it possible to achieve this using MPAndroidChart.

1条回答
我只想做你的唯一
2楼-- · 2020-04-30 18:38

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.

查看更多
登录 后发表回答