情况如下:
图表初始化如下:
protected NumberAxis xAxis;
protected NumberAxis yAxis;
protected StackedAreaChart<Number, Number> chart;
protected final XYChart.Series<Number, Number> waitingSeries
= new XYChart.Series<>();
protected final XYChart.Series<Number, Number> startedSeries
= new XYChart.Series<>();
protected final XYChart.Series<Number, Number> successSeries
= new XYChart.Series<>();
protected final XYChart.Series<Number, Number> failureSeries
= new XYChart.Series<>();
// ...
@Override
public void init()
{
// ...
xAxis = new NumberAxis();
xAxis.setLabel("Line number");
xAxis.setForceZeroInRange(false);
xAxis.setTickUnit(1.0);
xAxis.setTickMarkVisible(false);
yAxis = new NumberAxis();
yAxis.setTickMarkVisible(false);
chart = new StackedAreaChart<>(xAxis, yAxis);
chart.setAnimated(false);
chart.setTitle("Matcher status by line");
waitingSeries.setName("Waiting for children");
startedSeries.setName("Started this line");
successSeries.setName("Succeeded this line");
failureSeries.setName("Failed this line");
final ObservableList<XYChart.Series<Number, Number>> data
= chart.getData();
data.add(waitingSeries);
data.add(startedSeries);
data.add(successSeries);
data.add(failureSeries);
pane.setCenter(chart);
}
好的,所以:
xAxis
它的步骤应为1,它也会显示分数; (解决SO聊天和项目符号列表与代码的错误)
@Override
public void showLineMatcherStatus(final List<LineMatcherStatus> list,
final int startLine, final int nrLines)
{
display.xAxis.setLowerBound(startLine);
display.xAxis.setUpperBound(startLine + nrLines - 1);
// etc
在这种情况下, startLine
为1,nrLines
为25,嗯,endLine为25.好,边界得到尊重......
...但是为什么x轴的范围是0到27.5 ??
如何使轴表现?
答案 0 :(得分:1)
默认情况下,NumberAxis
将autoRanging
设置为true
,因此要让它尊重您需要的下限和上限
xAxis.setAutoRanging(false);
对于刻度线,如果仔细观察图像,您会注意到实际数字旁边没有刻度线;只是在两者之间的“次要价值”。
所以你需要两个
xAxis.setTickMarkVisible(false);
和
xAxis.setMinorTickVisible(false);