Reputation: 121830
Here is the situation:
The graph is initialized as such:
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);
}
OK, so:
xAxis
that its step should be 1, it shows fractions;(work around bug with SO chat and bullet list vs code)
@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
in this case is 1 and nrLines
being 25, well, endLine is 25. Good, the bounds are respected...
... But then why does the x axis range from 0 to 27.5??
How do I make the axes behave?
Upvotes: 0
Views: 45
Reputation: 209694
By default, NumberAxis
has autoRanging
set to true
, so to get it to respect your lower and upper bounds you need
xAxis.setAutoRanging(false);
For the tick marks, if you look at your image closely, you'll notice there are no tick marks next to the actual numbers; only at the "minor values" in between.
So you need both
xAxis.setTickMarkVisible(false);
and
xAxis.setMinorTickVisible(false);
Upvotes: 1