I am new to java and jfreechart. I have created a line chart. My x-axis has values (1, 2, 3,4,5,6,7,8,9,10,11,12,13,14). But I would like to have the following values displayed as labels(please note: some values should be blank):
3M,6M,1Y, ,2Y, ,5y, , ,10y, , , ,30Y
Which class I should use to get this result? any sample code? Here is my code. Thanks for help!
YieldXYDataset dataset = new YieldXYDataset();
dataset.loadData();
JFreeChart chart = ChartFactory.createXYLineChart
(seriesNames, // Title
"Time Period", // X-Axis label
"Yield", // Y-Axis label
dataset, // Dataset
PlotOrientation.VERTICAL,// Orientation
true, // Show legend
true, // Show tooltips
false // generate URLs
);
// format the Y-Axis label to use %
XYPlot plot = chart.getXYPlot();
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setNumberFormatOverride(new DecimalFormat("##.###%"));
yAxis.setAutoRangeIncludesZero(false);
// Write the chart image to the temporary directory
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session);
// Write the image map to the PrintWriter
ChartUtilities.writeImageMap(pw, filename, info);
pw.flush();
Customize the x-axis labels
Customize the x-axis labels
can someone please help me with this request? Thanks a lot in advance.
Maybe you can use the SymbilcAxis class for this. Look at the corresponding demos in the standard distribution (e.g. XYTickLabelDemo). In Release 0.9.14 this class is buggy; you can use the CVS version or apply the patch for refreshTicks() provided here: http://www.jfree.org/phpBB2/viewtopic.php?t=6307 .