如何创建具有多个Y轴和公共X轴的堆叠JavaFX图表

时间:2015-10-06 11:18:47

标签: javafx

实际上,我有完全相同的问题,之前在D3的以下链接中询问过。但我正在JavaFx中搜索解决方案。

How to create Stacked Line Chart D3, Multiple Y Axis and common X Axis

2 个答案:

答案 0 :(得分:0)

我个人会使用VBox垂直堆叠两个图表,然后隐藏第一个图表的X轴:

// if chart.getXAxis().setVisible(false) doesn't do the trick: chart.getXAxis().setTickLabelsVisible(false); chart.getXAxis().setOpacity(0);

答案 1 :(得分:0)

VinceOPS感谢您的回答,但是让轴不可见无法解决问题,因为它将被用作图表集的公共轴,并且至少有一个图表应该显示它。

今天早上,我找到了针对共轴多轴问题的优雅解决方案。

如果您使用带有多图表的公共轴;至少有一个图表应该显示在其他图表不应该的地方。

我发现的技巧如下

// Inherit from XYChart and in c'tor remove the axis from chart-children.
public DoNotDisplayXAxisChartConstructor(Axis<Number> xAxis, Axis<Number> yAxis)
{
            super(xAxis, yAxis);
            getChartChildren().remove(xAxis); 
    // And now the chart can use the xAxis for layout but cannot display it.
}

它有效......

相关问题