JFreeChart的蜘蛛网图(又称雷达图,网状图)应该怎么写啊
给你一个我从上反编译过来的,是个雷达图,包加载对了你就能看到效果
package demo;
import java.awt.Dimension;
import javax.swing.JPanel;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
import org.jfree.chart.plot.SpiderWebPlot;
import org.jfree.chart.title.LegendTitle;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.ui.*;
public class SpiderWebChartDemo1 extends ApplicationFrame
{
public SpiderWebChartDemo1(String s)
{
super(s);
JPanel jpanel = createDemoPanel();
jpanel.setPreferredSize(new Dimension(500, 270));
setContentPane(jpanel);
}
private static CategoryDataset createDataset()
{
String s = "First";
String s1 = "Second";
String s2 = "Third";
String s3 = "Category 1";
String s4 = "Category 2";
String s5 = "Category 3";
String s6 = "Category 4";
String s7 = "Category 5";
DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset();
defaultcategorydataset.addValue(1.0D, s, s3);
defaultcategorydataset.addValue(4D, s, s4);
defaultcategorydataset.addValue(3D, s, s5);
defaultcategorydataset.addValue(5D, s, s6);
defaultcategorydataset.addValue(5D, s, s7);
defaultcategorydataset.addValue(5D, s1, s3);
defaultcategorydataset.addValue(7D, s1, s4);
defaultcategorydataset.addValue(6D, s1, s5);
defaultcategorydataset.addValue(8D, s1, s6);
defaultcategorydataset.addValue(4D, s1, s7);
defaultcategorydataset.addValue(4D, s2, s3);
defaultcategorydataset.addValue(3D, s2, s4);
defaultcategorydataset.addValue(2D, s2, s5);
defaultcategorydataset.addValue(3D, s2, s6);
defaultcategorydataset.addValue(6D, s2, s7);
return defaultcategorydataset;
}
private static JFreeChart createChart(CategoryDataset categorydataset)
{
SpiderWebPlot spiderwebplot = new SpiderWebPlot(categorydataset);
spiderwebplot.setStartAngle(54D);
spiderwebplot.setInteriorGap(0.40000000000000002D);
spiderwebplot.setToolTipGenerator(new StandardCategoryToolTipGenerator());
JFreeChart jfreechart = new JFreeChart("Spider Web Chart Demo 1", TextTitle.DEFAULT_FONT, spiderwebplot, false);
LegendTitle legendtitle = new LegendTitle(spiderwebplot);
legendtitle.setPosition(RectangleEdge.BOTTOM);
jfreechart.addSubtitle(legendtitle);
return jfreechart;
}
public static JPanel createDemoPanel()
{
JFreeChart jfreechart = createChart(createDataset());
return new ChartPanel(jfreechart);
}
public static void main(String args[])
{
SpiderWebChartDemo1 spiderwebchartdemo1 = new SpiderWebChartDemo1("SpiderWebChartDemo1");
spiderwebchartdemo1.pack();
RefineryUtilities.centerFrameOnScreen(spiderwebchartdemo1);
spiderwebchartdemo1.setVisible(true);
}
}