Selective shapes on a line

A discussion forum for the Eastwood Chart Servlet.

Selective shapes on a line

Postby IanHayes » Wed Dec 07, 2011 4:30 pm


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)
        BufferedImage image = chart.createBufferedImage(600,400);
        jChartArea.setIcon(new ImageIcon(image));
        this.setSize(610, 450);

Posts: 2
Joined: Wed Dec 07, 2011 3:50 pm

Re: Selective shapes on a line

Postby david.gilbert » Tue Jul 17, 2012 9:14 pm

There's no out-of-the-box way to do that with JFreeChart, but if you don't mind subclassing the renderer (XYLineAndShapeRenderer) you could override the getItemShapeVisible(int series, int item) method to control whether or not a shape is drawn for each datapoint. (In JFreeChart, not Eastwood - I think you posted in the wrong forum, and then of course I replied much too late to be useful :oops: ).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
JFreeChart Project Leader
Posts: 11653
Joined: Fri Mar 14, 2003 10:29 am

Return to Eastwood Chart Servlet

Who is online

Users browsing this forum: No registered users and 1 guest