Gokul Kulkarni
Gokul Kulkarni

Reputation: 2259

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

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.

Upvotes: 0

Views: 2073

Answers (1)

R. Zagórski
R. Zagórski

Reputation: 20268

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.

Upvotes: 3

Related Questions