问题
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