I am writing a cricket scoring system for my school computing course. I am using JFreecharts to produce a few charts. On a couple of the charts, I want to put a shape on the line selectively. It is standard practice in cricket to mark charts with the fall of a wicket. for instance the cumulative run rate chart or the run rate chart need this. I have found out how to put shapes on the line, but I just get all shapes at change points on the line. Here is some of my code that I have used so far (I am using NetBeans if that is important): -
Code: Select all
JFreeChart chart = ChartFactory.createXYLineChart("Cumulative Runs", // Title
"Overs", // x-axis Label
"Runs", // y-axis Label
dataset, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
XYPlot plot = chart.getXYPlot();
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer)
plot.getRenderer();
renderer.setShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setFillPaint(Color.black);
BufferedImage image = chart.createBufferedImage(600,400);
jChartArea.setIcon(new ImageIcon(image));
this.setSize(610, 450);