質問を正しく表現できなかったのかもしれません。ゼロから値を開始し、それを目的のポイントまで埋める極座標チャートを描画したいことを説明します。グラフをプロットすると、次のように表示されます
しかし、私はこのようなものを探しています
これがサンプルコードです
import java.awt.Color;
import java.awt.Dimension;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.PolarChartPanel;
import org.jfree.chart.plot.PolarPlot;
import org.jfree.chart.renderer.DefaultPolarItemRenderer;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class PolarCharDemo extends ApplicationFrame {
private static final long serialVersionUID = 1L;
double [][] myData = {{12.1,7.9,3.29,1.01,0,145},
{12.6,8.4,3.22,1,0,145},
{13.1,8.1,3.29,0.97,0,145},
{10,7.5,3.22,0.93,0,145},
{11.4,8.2,3.1,0.93,0,145},
{11.7,7.3,2.99,0.9,0,145},
{10.3,8,2.97,0.89,0,145},
{8.8,7,3.05,0.9,0,145},
{9.8,6.7,3.13,0.93,0,145},
{11.1,7.1,3.05,0.91,0,145},
{8.8,6.2,3.12,0.95,0,145},
{9.6,7,2.82,0.44,2.3,5},
{10.2,6.8,2.82,0.47,3.2,5},
{9.4,6.8,2.76,0.41,2.9,5},
{10,7,2.61,0.44,3.3,45},
{12.8,8,2.95,0.49,2.2,50},
{9.9,7.1,4.08,1.01,0.6,45},
{7.1,4.4,2.23,0.4,1.5,5},
{5,4,2.1,0.37,2.3,5},
{7.2,4.1,2.17,0.37,1.5,5},
{7.1,4.3,2.09,0.36,2,5},
{5.1,4.1,2.17,0.38,2.1,5},
{4.2,3.9,2.16,0.41,1.9,5},
{4.9,3.9,2.08,0.35,2.5,5},
{4.3,3.5,2.09,0.34,3,5}};
/**
* Creates a new instance of the demo.
*
* @param title the frame title.
*/
public PolarCharDemo(final String title) {
super(title);
final XYDataset dataset = createAvgDataset();
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new PolarChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(1000, 670));
chartPanel.setEnforceFileExtensions(false);
setContentPane(chartPanel);
}
/**
* Creates a sample chart.
* @param dataset the dataset.
* @return A sample chart.
*/
private JFreeChart createChart(final XYDataset dataset) {
final JFreeChart chart = ChartFactory.createPolarChart("", dataset, true, true, false);
final PolarPlot plot = (PolarPlot) chart.getPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setAngleGridlinePaint(Color.BLACK);
plot.setRadiusGridlinePaint(Color.LIGHT_GRAY);
final DefaultPolarItemRenderer renderer = (DefaultPolarItemRenderer) plot.getRenderer();
renderer.setSeriesFilled(0, true);
renderer.setSeriesPaint(0, Color.BLUE);
renderer.setSeriesFilled(1, true);
renderer.setSeriesPaint(1, Color.RED);
renderer.setSeriesFilled(2, true);
renderer.setSeriesPaint(2, Color.YELLOW);
renderer.setSeriesFilled(3, true);
renderer.setSeriesPaint(3, Color.GREEN);
return chart;
}
/**
* Creates an Average dataset.
* @return An average dataset.
*/
private XYDataset createAvgDataset() {
final XYSeriesCollection data = new XYSeriesCollection();
XYSeries series0 = new XYSeries("Series1");
XYSeries series1 = new XYSeries("Series2");
XYSeries series2 = new XYSeries("Series3");
for(int i=0;i<myData.length;i++)
{
series0.add(myData[i][5], myData[i][0]);
series1.add(myData[i][5], myData[i][1]);
series2.add(myData[i][5], myData[i][2]);
}
data.addSeries(series0);
data.addSeries(series1);
data.addSeries(series2);
return data;
}
/**
* Main program that creates a thermometer and places it into
* a JFrame.
*
* @param argv Command line arguements - none used.
*/
public static void main(final String[] argv) {
final PolarCharDemo demo = new PolarCharDemo("Polar Chart");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}