Can I draw only vertical data axis (without axis line( in XYPlot and only horizontal line in grid lines (I know the hack - draw them by white color, that is coincident with background color, may be, there is more pure way) ?
Asked
Active
Viewed 1,268 times
2 Answers
2
You can specify currency formatting on the range axis using setNumberFormatOverride()
, as shown here.
NumberFormat currency = NumberFormat.getCurrencyInstance();
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setNumberFormatOverride(currency);
1
Here is a simple example.
// create a dataset...
XYSeries series = new XYSeries("Random Data");
series.add(1.0, 500.2);
series.add(10.0, 694.1);
// Create an XY Line chart
XYSeriesCollection data = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo",
null,
"Y",
data,
PlotOrientation.VERTICAL,
true,
true,
false);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainGridlinesVisible(false);
The vertical lines are hidden by calling plot.setDomainGridLinesVisible(false).

obourgain
- 8,856
- 6
- 42
- 57
-
@Eugene: My [answer](http://stackoverflow.com/a/14443791/230513) to this [question](http://stackoverflow.com/q/14442404/230513) was ancillary; don't hesitate to accept this answer if you feel that it addressed your question more directly. – trashgod Mar 06 '13 at 18:45