Im using jfree chart for my application. I need the chart looks like this
Expected
but i've formatted the charts many way's but i have got like this only.
Actual
Please help me to get the expected chart. I need a chart without the x-axis line.
My code for the chart is
final JFreeChart chart = ChartFactory.createLineChart(
"", // chart title
"", // domain axis label
"", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
false, // include legend
false, // tooltips
false // urls
);
final CategoryPlot plot = chart.getCategoryPlot();
ValueAxis range = plot.getRangeAxis();
range.setVisible(false);
plot.setBackgroundPaint(Color.WHITE);
plot.setRangeZeroBaselinePaint(Color.RED);
plot.setOutlineVisible(false);
chart.setBackgroundPaint(Color.WHITE);
final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setItemLabelsVisible(false);
renderer.setBaseShapesVisible(true);
renderer.setBaseShapesFilled(true);
plot.setRangeGridlinePaint(Color.white);
renderer.setSeriesStroke(0, new BasicStroke(2.0f));
plot.setDomainGridlinePaint(Color.BLUE);
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setVisible(false);
rangeAxis.setLabelPaint(Color.BLUE);
Shape circle = new Ellipse2D.Double(-3, -3, 6, 6);
renderer.setSeriesShape(0, circle);
plot.getRenderer().setSeriesPaint(0, Color.BLUE);
rangeAxis.setRange(0, 3);
try {
ChartUtilities.saveChartAsPNG(new File("E:\\jfreeLinechart.png"), chart, 211, 90);
System.out.println("=====chart=====");
} catch (Exception e) {
e.printStackTrace();
}