jchart2D多个Y轴标题组合在一起

时间:2012-05-08 14:19:09

标签: java graph charts jchart2d

我一直在使用Achim Westerman的jchart2D课程已经有一段时间了,刚发生在我试图在图表右侧制作3个Y轴的实例上。

制作3轴的代码如下

//Create Y Axis 1
AAxis<IAxisScalePolicy> yAxisShaftSpeed = 
                    new AxisLinear<IAxisScalePolicy>();
yAxisShaftSpeed.setAxisScalePolicy(new AxisScalePolicyManualTicks());
yAxisShaftSpeed.setMinorTickSpacing(10);
yAxisShaftSpeed.setStartMajorTick(true);
yAxisShaftSpeed.setPaintGrid(false);
yAxisShaftSpeed.setAxisTitle(new IAxis.AxisTitle("Shaft Speed (RPM)"));
IRangePolicy rangePolicyYShaftSpeed = 
                    new RangePolicyFixedViewport(new Range(0,225));
//Create Y axis 2
AAxis<IAxisScalePolicy> yAxisWindSpeed = 
                    new AxisLinear<IAxisScalePolicy>();
yAxisWindSpeed.setAxisScalePolicy(new AxisScalePolicyManualTicks());
yAxisWindSpeed.setMinorTickSpacing(10);
yAxisWindSpeed.setStartMajorTick(true);
yAxisWindSpeed.setPaintGrid(false);
yAxisWindSpeed.setAxisTitle(new IAxis.AxisTitle("Wind Speed (m/s))"));
IRangePolicy rangePolicyYWindSpeed = 
                    new RangePolicyFixedViewport(new Range(0,25));
//Create Y axis 3
AAxis<IAxisScalePolicy> yAxisPressure = 
                    new AxisLinear<IAxisScalePolicy>();
yAxisPressure.setAxisScalePolicy(new AxisScalePolicyManualTicks());
yAxisPressure.setMinorTickSpacing(10);
yAxisPressure.setStartMajorTick(true);
yAxisPressure.setPaintGrid(false);
yAxisPressure.setAxisTitle(new IAxis.AxisTitle("Pressure (hPa)"));
IRangePolicy rangePolicyYPressure = 
                    new RangePolicyFixedViewport(new Range(700,1100));

然后我继续添加并设置右手Y轴,如下所示

timePlotZoomableChart.setAxisYRight(yAxisShaftSpeed,0);
timePlotZoomableChart.addAxisYRight(yAxisWindSpeed);
timePlotZoomableChart.addAxisYRight(yAxisPressure);

不幸的是,当图形出现时,三个Y轴按预期在右侧,但所有标题在第一个添加的右Y轴(yAxisShaftSpeed)下相互堆叠。有人有什么想法吗?

提前致谢。

1 个答案:

答案 0 :(得分:0)

可能是一个错误(我从未测试过这个)。随意发布一个错误报告,包括最小的可运行代码,jchart2d的版本,操作系统和源代码的java版本。 亲切的问候, Achim的