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);
}
}
PRN -> Name of the series
SV_AZ -> Azimuth (0-365.9)
SV_EL -> Elevation (-90 - 90)
Thank you!