Polar chart update data

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
forever
Posts: 2
Joined: Fri Feb 04, 2011 10:05 am
antibot: No, of course not.

Polar chart update data

Post by forever » Fri Feb 04, 2011 10:12 am

Hi,

I'm new in JFreeChart and I'm trying to make a polar chart where the data updates periodically but I don't know how to do it.

This is my code:

Code: Select all

public class Satellite{

    XYSeriesCollection data;
    XYSeries serie;

    public JFreeChart createChart(XYDataset dataset) {
        JFreeChart chart = ChartFactory.createPolarChart(
            null,
            dataset,
            true,
            true,
            false
        );

        PolarPlot plot = (PolarPlot) chart.getPlot();
        MyDefaultPolarItemRenderer dpir = new MyDefaultPolarItemRenderer();
        dpir.setPlot(plot);

        plot.setRadiusGridlinePaint(Color.DARK_GRAY);   //Radius grid lines color
        plot.setAngleGridlinePaint(Color.DARK_GRAY);    //Angle grid lines color
        plot.setBackgroundAlpha(0);                          //Make plot background translucid
        plot.setOutlineVisible(false);                  //Out line not visible

        chart.setBackgroundPaint(null);                 //Make chart background translucid
   
        plot.setRenderer(dpir);

        return chart;
    }

    public XYDataset createDataset(){
        data = new XYSeriesCollection();
        // serie = new XYSeries("Satellites", true, false);

        // data.addSeries(serie);

        return data;
    }


    public void addData(RangeStruct rs){
        
        String name = Integer.toString(rs.PRN);
        
        serie = new XYSeries(name, true, false);

        XYDataItem item = new XYDataItem(rs.SV_AZ,rs.SV_DET);

        serie.add(item);

        
    }
}
Where the info in RangeStruct is:
PRN -> Name of the series
SV_AZ -> Azimuth (0-365.9)
SV_EL -> Elevation (-90 - 90)


Thank you!

Locked