CombinedChart - Reduce y-axis of individual data sets
Using a combined chart to display candles and bar charts pictured below.
My question is how can I reduce the scale of the y-axis on the BarChart data so that the overlap isn't as large as it currently is.
Thanks for the help!
Finally figured a way to do this.
Using Combined Chart set bar data to an AxisDependency, Left in this case;
BarDataSet volumeSet = new BarDataSet(yVolumeVals, "Volume Data");
volumeSet.setDrawValues(false);
volumeSet.setAxisDependency(YAxis.AxisDependency.LEFT);
Then after getting all the data, calculate largest Y value and set the left axis max value to N times that for desired height. In this case 3x.
CombinedData combinedData = new CombinedData(xVals);
combinedData.setData(priceData);
combinedData.setData(volumeData);
candleChart.getAxisLeft().setAxisMaxValue(volumeData.getYMax() * 3);
candleChart.setData(combinedData);
candleChart.invalidate();
Thanks again @PhilJay for the awesome library!
My question is how can I reduce the scale of the y-axis on the BarChart data so that the overlap isn't as large as it currently is.
Did you mean BarChat and CandleChart overlap?
@gray419 @PhilJay Can BarChart and CandleChart depend on different axis? And they have different unit. If can, then could you tell me how to? Thanks.
@minggo yes, you can set bardataset and candledataset on another axis
public static void setBarDataSet(BarDataSet dataSet) {
dataSet.setColor(android.support.design.R.color.design_fab_shadow_end_color);
dataSet.setDrawValues(false);
dataSet.setAxisDependency(YAxis.AxisDependency.LEFT);
dataSet.setHighlightEnabled(false);
}
//----------------------------------------------------------------------------------------------
public static void setCandleDataSet(CandleDataSet dataSet) {
dataSet.setAxisDependency(YAxis.AxisDependency.RIGHT);
dataSet.setShadowColorSameAsCandle(true);
dataSet.setBarSpace(0.1f);
dataSet.setDrawValues(false);
dataSet.setIncreasingColor(Color.GREEN);
dataSet.setIncreasingPaintStyle(Paint.Style.FILL);
dataSet.setDecreasingColor(Color.RED);
dataSet.setDecreasingPaintStyle(Paint.Style.FILL);
dataSet.setNeutralColor(Color.BLACK);
}