title: JavaFX 2.x : Using StackPane to layer more different type charts
body: <p>Having this suggestion,</p>
  
  <p><a href="https://forums.oracle.com/forums/thread.jspa?threadID=2435573&amp;tstart=0" rel="nofollow">https://forums.oracle.com/forums/thread.jspa?threadID=2435573&amp;tstart=0</a></p>
  
  <p>I have tryed to use StackPane but second chart replace first one.</p>
  
  <p>How to plot two or more different Chart (as in my example) in the same graph?</p>
  
  <p>Here is my code</p>
  
  <pre><code>public class XyChartInSplitStackpane extends Application {
  SplitPane               splitPane1 = null;
  @Override
  public void start(Stage stage) {
  stage.setTitle("Line plot");
  
  final CategoryAxis xAxis1 = new CategoryAxis();
  final NumberAxis yAxis1 = new NumberAxis();
  
  yAxis1.setTickUnit(1);
  yAxis1.setPrefWidth(35);
  yAxis1.setMinorTickCount(10);
  
  yAxis1.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis1){
      @Override
  public String toString(Number object){
          String label;
          label = String.format("%7.2f", object.floatValue());
          return label;
  }
  });
  final BarChart&lt;String, Number&gt;barChart1 = new BarChart&lt;String, Number&gt;(xAxis1, yAxis1);
  
  barChart1.setAlternativeRowFillVisible(false);
  barChart1.setLegendVisible(false);
  barChart1.setAnimated(false);
  
  XYChart.Series series1 = new XYChart.Series();
  
  series1.getData().add(new XYChart.Data("Jan", 1));
  series1.getData().add(new XYChart.Data("Feb", 2));
  series1.getData().add(new XYChart.Data("Mar", 1.5));
  series1.getData().add(new XYChart.Data("Apr", 3));
  series1.getData().add(new XYChart.Data("May", 2.5));
  series1.getData().add(new XYChart.Data("Jun", 5));
  series1.getData().add(new XYChart.Data("Jul", 4));
  series1.getData().add(new XYChart.Data("Aug", 8));
  series1.getData().add(new XYChart.Data("Sep", 6.5));
  series1.getData().add(new XYChart.Data("Oct", 13));
  series1.getData().add(new XYChart.Data("Nov", 10));
  series1.getData().add(new XYChart.Data("Dec", 20));
  
  barChart1.getData().addAll(series1); 
  
  final CategoryAxis xAxis2 = new CategoryAxis();
  final NumberAxis yAxis2 = new NumberAxis(1, 21,0.1);
  
  yAxis2.setTickUnit(1);
  yAxis2.setPrefWidth(35);
  yAxis2.setMinorTickCount(10);
  
  yAxis2.setTickLabelFormatter(new NumberAxis.DefaultFormatter(yAxis2){
      @Override
  public String toString(Number object){
          String label;
          label = String.format("%7.2f", object.floatValue());
          return label;
  }
  });
  final LineChart&lt;String, Number&gt;lineChart2 = new LineChart&lt;String, Number&gt;(xAxis2,  yAxis2);
  
  lineChart2.setCreateSymbols(false);
  lineChart2.setAlternativeRowFillVisible(false);
  lineChart2.setLegendVisible(false);
  lineChart2.setAnimated(false);
  
  XYChart.Series series2 = new XYChart.Series();
  
  series2.getData().add(new XYChart.Data("Jan", 2));
  series2.getData().add(new XYChart.Data("Feb", 10));
  series2.getData().add(new XYChart.Data("Mar", 8));
  series2.getData().add(new XYChart.Data("Apr", 4));
  series2.getData().add(new XYChart.Data("May", 7));
  series2.getData().add(new XYChart.Data("Jun", 5));
  series2.getData().add(new XYChart.Data("Jul", 4));
  series2.getData().add(new XYChart.Data("Aug", 8));
  series2.getData().add(new XYChart.Data("Sep", 16.5));
  series2.getData().add(new XYChart.Data("Oct", 13.9));
  series2.getData().add(new XYChart.Data("Nov", 17));
  series2.getData().add(new XYChart.Data("Dec", 10));
  
  Set&lt;Node&gt; nodes1 = barChart1.lookupAll(".series0");    
  for (Node n: nodes1) {        
      n.setStyle("-fx-blend-mode:  src-over");        
  }
  
  lineChart2.getData().addAll(series2);
  Set&lt;Node&gt; nodes2 = lineChart2.lookupAll(".series0");    
  for (Node n: nodes2) {        
      n.setStyle("-fx-stroke: red; -fx-background-color: red, white; -fx-blend-mode: src-over; -fx-opacity: 0.5");
  }    
  
  splitPane1 = new SplitPane();   
  StackPane stackpane = new StackPane();
  stackpane.getChildren().add(barChart1);                
  stackpane.getChildren().add(lineChart2);
  
  splitPane1.setOrientation(Orientation.VERTICAL);
  splitPane1.getItems().addAll(stackpane);    
  splitPane1.setDividerPosition(0, 1);
  
  Scene scene = new Scene(splitPane1, 800, 600);
  
  stage.setScene(scene);
  stage.show();
  }
  
   public static void main(String[] args) {
  launch(args);
  }
  }
  </code></pre>