0

This question is related to this question: How to draw multiple axis on a chart using JAVAFX Charts

I'm trying to overlay two JavaFX line charts and offset their axes. I'm using various values for the y axis which may or may not effect the position of the main chart area. Right now I'm using the following code to position the charts, but I cant figure out a way to absolutely position the main chart area.

    primaryChart.setTranslateY(-50.0);
    primaryChart.setTranslateX(80.0);
    AnchorPane.setTopAnchor(primaryChart, 50.0);
    AnchorPane.setRightAnchor(primaryChart, 80.0);
    AnchorPane.setBottomAnchor(primaryChart, 0.0);
    AnchorPane.setLeftAnchor(primaryChart, 0.0);
    secondaryChart.setTranslateY(-50.0);
    secondaryChart.setTranslateX(98.0);
    secondaryChart.getXAxis().setTranslateY(50.0);
    secondaryChart.getYAxis().setTranslateX(-98.0);
    AnchorPane.setTopAnchor(secondaryChart, 50.0);
    AnchorPane.setRightAnchor(secondaryChart, 52.0);
    AnchorPane.setBottomAnchor(secondaryChart, 0.0);
    AnchorPane.setLeftAnchor(secondaryChart, 0.0);

These commands move the whole chart but I just want to move the charting area. Here are some pictures explaining what's going on.

A properly aligned Chart

The chart with the axis shifted due to adding a new axis.

Community
  • 1
  • 1
Doctor Parameter
  • 1,202
  • 2
  • 15
  • 21

1 Answers1

1

I was able to maintain the position of the chart area by setting the preferred width of the Y axis to 80px.

Doctor Parameter
  • 1,202
  • 2
  • 15
  • 21