Stacked Charts - oliverwatkins/Iceberg-Charts GitHub Wiki

It is possible to vertically stack charts if they share the same X-Axis using a StackedXYChart.

The following example creates three seperate charts, and creates an x-axis which is then shared across all three charts. Additionally three percentage values are passed in as an array to give the various percentage heights of the three charts :

	//x-Axis needs to be shared
	XAxis xAxis = new XAxis(new LinearNumericalAxisScalingX(), "X");
	xAxis.axisScaling.setMinValue(0);
	xAxis.axisScaling.setMaxValue(100);
	
	
	XYChart topChart = (XYChart)new TestDataBar_5_PosNegColor().getChart();
	topChart.xAxis = xAxis;
	
	XYChart bottomChart = (XYChart)new TestDataXY_SineCurve().getChart();
	bottomChart.xAxis = xAxis;
	
	XYChart middleChart = (XYChart)new TestDataXY_Scatter().getChart();
	middleChart.xAxis = xAxis;
	
	ArrayList<XYChart> charts = new ArrayList<XYChart>();
	charts.add(topChart);
	charts.add(middleChart);
	charts.add(bottomChart);

	//height percentages
	ArrayList<Integer> percentages = new ArrayList<Integer>();
	percentages.add(40);
	percentages.add(30);
	percentages.add(30);
	
	StackedXYChart stackedXYChart = new StackedXYChart("Three random charts with same X Axis", charts, percentages);

The application of stacked charts is particularly common in the finance world. For example candle stick charts combined with a bar chart :

⚠️ **GitHub.com Fallback** ⚠️