Y axis numbers dissapeared

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Post Reply
zoltanik
Posts: 2
Joined: Tue Feb 21, 2017 4:06 pm
antibot: No, of course not.

Y axis numbers dissapeared

Post by zoltanik » Sun Mar 04, 2018 10:47 am

Hello,
I'm building few charts the same way but some of them is not showing the y axis ticks.
Any idea why?
I cant know the charts range before. It can be negative\positive numbers, can be very small, or large numbers.

This is my code:
JFreeChart chart = ChartFactory.createXYLineChart(
chartName,
"",
"",
seriesCollection,
PlotOrientation.VERTICAL,
seriesCollection.getSeries().size() > 1,
true,
false
);

XYPlot plot = (XYPlot) chart.getPlot();
chart.addSubtitle(new TextTitle(chartName);
ValueMarker lowMarker = new ValueMarker();
ValueMarker highMarker = new ValueMarker();
lowMarker.setPaint(Color.BLACK);
lowMarker.setLabel("Minimum");
lowMarker.setLabelAnchor(RectangleAnchor.TOP);
highMarker.setPaint(Color.BLACK);
highMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
highMarker.setLabel("Maximum");
plot.addRangeMarker(lowMarker);
plot.addRangeMarker(highMarker);

ValueMarker marker = new ValueMarker(dataInfo.getTakeoffTime().getTime(), Color.RED, new BasicStroke(1f));
marker.setLabelOffset(new RectangleInsets(10, 0, 0, 0));
plot.addDomainMarker(marker);
ValueMarker marker = new ValueMarker(dataInfo.getLandingTime().getTime(), Color.RED, new BasicStroke(1f));
marker.setLabelOffset(new RectangleInsets(10, 0, 0, 0));
plot.addDomainMarker(marker);

DateAxis dateAxis = new DateAxis();
dateAxis.setDateFormatOverride(dateFormat);
plot.setDomainAxis(dateAxis);
NumberAxis yAxis = new NumberAxis();
yAxis.setFixedDimension(35);
yAxis.setAutoRangeIncludesZero(false);
yAxis.setLabel(seriesCollection.getYAxisLabel());
yAxis.setNumberFormatOverride(decimalFormat);
yAxis.setTickMarksVisible(false);
yAxis.setAutoTickUnitSelection(isAutoTickUnitSelection());
plot.setRangeAxis(yAxis);

Markmilleru2
Posts: 1
Joined: Wed Oct 17, 2018 10:28 am
antibot: No, of course not.

Re: Y axis numbers dissapeared

Post by Markmilleru2 » Wed Oct 17, 2018 10:44 am

zoltanik wrote:
Sun Mar 04, 2018 10:47 am
Hello,
I'm building few charts the same way but some of them is not showing the y axis ticks.
Any idea why?
I cant know the charts range before. It can be negative\positive numbers, can be very small, or large numbers.

This is my code:
JFreeChart chart = ChartFactory.createXYLineChart(
chartName,
"",
"",
seriesCollection,
PlotOrientation.VERTICAL,
seriesCollection.getSeries().size() > 1,
true,
false
);

XYPlot plot = (XYPlot) chart.getPlot();
chart.addSubtitle(new TextTitle(chartName);
ValueMarker lowMarker = new ValueMarker();
ValueMarkerbest cordless drill best miter saw best gaming laptop under 500 best reel mowerhighMarker = new ValueMarker();
lowMarker.setPaint(Color.BLACK);
lowMarker.setLabel("Minimum");
lowMarker.setLabelAnchor(RectangleAnchor.TOP);
highMarker.setPaint(Color.BLACK);
highMarker.setLabelAnchor(RectangleAnchor.BOTTOM);
highMarker.setLabel("Maximum");
plot.addRangeMarker(lowMarker);
plot.addRangeMarker(highMarker);

ValueMarker marker = new ValueMarker(dataInfo.getTakeoffTime().getTime(), Color.RED, new BasicStroke(1f));
marker.setLabelOffset(new RectangleInsets(10, 0, 0, 0));
plot.addDomainMarker(marker);
ValueMarker marker = new ValueMarker(dataInfo.getLandingTime().getTime(), Color.RED, new BasicStroke(1f));
marker.setLabelOffset(new RectangleInsets(10, 0, 0, 0));
plot.addDomainMarker(marker);

DateAxis dateAxis = new DateAxis();
dateAxis.setDateFormatOverride(dateFormat);
plot.setDomainAxis(dateAxis);
NumberAxis yAxis = new NumberAxis();
yAxis.setFixedDimension(35);
yAxis.setAutoRangeIncludesZero(false);
yAxis.setLabel(seriesCollection.getYAxisLabel());
yAxis.setNumberFormatOverride(decimalFormat);
yAxis.setTickMarksVisible(false);
yAxis.setAutoTickUnitSelection(isAutoTickUnitSelection());
plot.setRangeAxis(yAxis);
I have also encountered the same problem

Post Reply