當前位置: 首頁>>代碼示例>>Java>>正文


Java ChartFactory.createPieChart方法代碼示例

本文整理匯總了Java中org.jfree.chart.ChartFactory.createPieChart方法的典型用法代碼示例。如果您正苦於以下問題:Java ChartFactory.createPieChart方法的具體用法?Java ChartFactory.createPieChart怎麽用?Java ChartFactory.createPieChart使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jfree.chart.ChartFactory的用法示例。


在下文中一共展示了ChartFactory.createPieChart方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Common test setup.
 */
protected void setUp() {

    // create a dataset...
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Java", new Double(43.2));
    data.setValue("Visual Basic", new Double(0.0));
    data.setValue("C/C++", new Double(17.5));

    // create the chart...
    this.pieChart = ChartFactory.createPieChart(
        "Pie Chart",  // chart title
        data,         // data
        true,         // include legend
        true,
        false
    );

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:22,代碼來源:JFreeChartTests.java

示例2: piePlt

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public piePlt(String title, String Categories) throws Exception{
    super("");
   DefaultPieDataset dataset = new DefaultPieDataset();
   String[] ct = Categories.split(";");
    for(String bf: ct){
       // if(bf.startsWith("("))
           // bf=bf.substring(1);
       // if(bf.endsWith(")"))
           // bf=bf.substring(0,bf.length()-1);
             dataset.setValue(bf.substring(0,bf.indexOf(',')),
                    new Double(jc.eval("2dbl("+jc.eval(bf.substring(bf.indexOf(',')+1))+")")));
    }
    if(title==null)
      title = "Pie Chart";
    
    
       chart = ChartFactory.createPieChart(
                           title,
                           dataset,
                           true,                     // include legend
                           true,                     // tooltips?
                           false                     // URLs?
                    );
      
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:26,代碼來源:piePlt.java

示例3: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
@Override
public JFreeChart createChart(Element element, ChartSource source) {
    Attribute key = source.getAttributeProperty(PIE_ATTRIBUTE_KEY);
    Attribute value = source.getAttributeProperty(PIE_ATTRIBUTE_VALUE);
    if ((key == null) || (value == null))
        throw new ChartNotSetupedException();
    DefaultPieDataset dataset = new DefaultPieDataset();
    for (Element element2 : source.getElements()) {
        Object v1 = engine.getAttribute(element2, key);
        Object v2 = engine.getAttribute(element2, value);
        if ((v1 != null) && (v2 != null))
            dataset.setValue(toString(v1), toDouble(v2));
    }
    return ChartFactory.createPieChart(element.getName(), dataset, true,
            true, false);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:17,代碼來源:PieChartDataPlugin.java

示例4: createPieChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates a pie chart.
 *
 * @return the pie chart.
 */
private static JFreeChart createPieChart() {
    // create a dataset...
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Java", new Double(43.2));
    data.setValue("Visual Basic", new Double(0.0));
    data.setValue("C/C++", new Double(17.5));

    // create the chart...
    return ChartFactory.createPieChart("Pie Chart",  // chart title
                                       data,         // data
                                       true,         // include legend
                                       true,
                                       false
                                       );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:PieChartTests.java

示例5: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates a chart.
 * 
 * @param dataset  the dataset.
 * 
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {
    
    JFreeChart chart = ChartFactory.createPieChart(
        "Pie Chart Demo 1",  // chart title
        dataset,             // data
        true,               // include legend
        true,
        false
    );

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setSectionOutlinesVisible(false);
    plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    plot.setNoDataMessage("No data available");
    plot.setCircular(false);
    plot.setLabelGap(0.02);
    return chart;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:27,代碼來源:SWTPieChartDemo1.java

示例6: createPieChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates a pie chart.
 *
 * @return The pie chart.
 */
private static JFreeChart createPieChart() {
    // create a dataset...
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("Java", new Double(43.2));
    data.setValue("Visual Basic", new Double(0.0));
    data.setValue("C/C++", new Double(17.5));

    // create the chart...
    return ChartFactory.createPieChart("Pie Chart",  // chart title
                                       data,         // data
                                       true,         // include legend
                                       true,
                                       false
                                       );
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:21,代碼來源:PieChartTests.java

示例7: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public ChartPanel createChart(String title, DefaultPieDataset dataset) {
    JFreeChart chart = ChartFactory.createPieChart(title, dataset);
    ChartUtils.setAntiAlias(chart);
    ChartUtils.setPieRender(chart.getPlot());
    chart.getLegend().setFrame(new BlockBorder(Color.WHITE));
    chart.getLegend().setPosition(RectangleEdge.RIGHT);
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}
 
開發者ID:Fanping,項目名稱:iveely.ml,代碼行數:10,代碼來源:PieChart.java

示例8: CountryAllocationPane

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public CountryAllocationPane(Portfolio portfolio ) {
	this.dataset = new DefaultPieDataset();
	Set<Entry<String, Double>> bookEntries = portfolio.getCountryAllocations();
	double totalValue = portfolio.getPortfolioValue();
	
	for (Entry<String, Double> entry : bookEntries) {
		double percentage = (Double) entry.getValue()/totalValue * 100.0 ;
		dataset.setValue(entry.getKey(), new Double(percentage) );
	}

	this.chart = ChartFactory.createPieChart(
			"Maantieteellinen jakauma", // The chart title
			dataset,         // The dataset for the chart
			false,          // Is a legend required?
			true,          // Use tooltips
			false          // Configure chart to generate URLs?
			);
	/* Creating a pieplot so as to customize the chart  generated */
	final PiePlot plot = (PiePlot)chart.getPlot( ); 

	/* Customizing Label using an inner class */

	plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
			"{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()
			));
	// Create this panel
	this.setLayout( new GridLayout( 1, 1 ) );
	this.panel = new ChartPanel( chart );

	this.add( panel );
}
 
開發者ID:skarna1,項目名稱:javaportfolio,代碼行數:32,代碼來源:CountryAllocationPane.java

示例9: addChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 */
private void addChart() {
    JFreeChart chart = ChartFactory.createPieChart(
            getTitle(), dataset, false, true, false);
    chart.addProgressListener(locker);
    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setToolTipGenerator(dataset);
    
    mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart));
}
 
開發者ID:vimerzhao,項目名稱:gchisto,代碼行數:15,代碼來源:BreakdownChartPanelSingle.java

示例10: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
@Override
public JFreeChart createChart(PieDataset pieDataSet, boolean createLegend) {
	JFreeChart chart = ChartFactory.createPieChart(null, pieDataSet, createLegend, // legend
			true, false);
	return chart;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:7,代碼來源:PieChart2DPlotter.java

示例11: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates a chart.
 *
 * @param dataset  the dataset.
 *
 * @return A chart.
 */
private static JFreeChart createChart(PieDataset dataset) {

    JFreeChart chart = ChartFactory.createPieChart(
        "Smart Phones Manufactured / Q3 2011", dataset);

    // set a custom background for the chart
    chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), 
            new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

    // customise the title position and font
    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.LEFT);
    t.setPaint(new Color(240, 240, 240));
    t.setFont(new Font("Arial", Font.BOLD, 26));

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setInteriorGap(0.04);
    plot.setOutlineVisible(false);

    // use gradients and white borders for the section colours
    plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
    plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
    plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
    plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
    plot.setDefaultSectionOutlinePaint(Color.WHITE);
    plot.setSectionOutlinesVisible(true);
    plot.setDefaultSectionOutlineStroke(new BasicStroke(2.0f));

    // customise the section label appearance
    plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
    plot.setLabelLinkPaint(Color.WHITE);
    plot.setLabelLinkStroke(new BasicStroke(2.0f));
    plot.setLabelOutlineStroke(null);
    plot.setLabelPaint(Color.WHITE);
    plot.setLabelBackgroundPaint(null);
    
    // add a subtitle giving the data source
    TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", 
            new Font("Courier New", Font.PLAIN, 12));
    source.setPaint(Color.WHITE);
    source.setPosition(RectangleEdge.BOTTOM);
    source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(source);
    return chart;

}
 
開發者ID:jfree,項目名稱:jfree-fxdemos,代碼行數:55,代碼來源:PieChartFXDemo1.java

示例12: PieChartPane

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public PieChartPane(Portfolio portfolio ) {
 this.dataset = new DefaultPieDataset();
 Object[][] bookEntries = portfolio.getCombinedBookEntryTable(false);
 double totalValue = portfolio.getPortfolioValue();
 double belowXPercent = 0.0;
 double percentageLimit = bookEntries.length > maxEntries ? belowPercentage : 0.0;
 for (int i = 0; i < bookEntries.length; ++i) {
  double percentage = (Double) bookEntries[i][8]/totalValue * 100.0 ;
  if (percentage > percentageLimit) {
	  dataset.setValue( (String) bookEntries[i][0],  new Double(percentage) );
  }
  else {
	  belowXPercent += percentage;
  }
 }
 if (belowXPercent > 0.0) {
  dataset.setValue( "Alle " + belowPercentage + "%",  new Double(belowXPercent) );
 }

 
   this.chart = ChartFactory.createPieChart(
   	      "Arvopaperijakauma", // The chart title
   	      dataset,         // The dataset for the chart
   	      false,          // Is a legend required?
   	      true,          // Use tooltips
   	      false          // Configure chart to generate URLs?
   	    );
   /* Creating a pieplot so as to customize the chart  generated */
   final PiePlot plot = (PiePlot)chart.getPlot( ); 

        /* Customizing Label using an inner class */
  
   plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
           "{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()
       ));
   // Create this panel
   this.setLayout( new GridLayout( 1, 1 ) );
   this.panel = new ChartPanel( chart );
  
   this.add( panel );

}
 
開發者ID:skarna1,項目名稱:javaportfolio,代碼行數:43,代碼來源:PieChartPane.java

示例13: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
     * Creates a chart.
     *
     * @param dataset  the dataset.
     *
     * @return A chart.
     */
    private static JFreeChart createChart(PieDataset dataset) {

        JFreeChart chart = ChartFactory.createPieChart(
            "Smart Phones Manufactured / Q3 2011",  // chart title
            dataset,            // data
            false,              // no legend
            true,               // tooltips
            false               // no URL generation
        );

        // set a custom background for the chart
        chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), 
                new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));

        // customise the title position and font
        TextTitle t = chart.getTitle();
        t.setHorizontalAlignment(HorizontalAlignment.LEFT);
        t.setPaint(new Color(240, 240, 240));
        t.setFont(new Font("Arial", Font.BOLD, 26));

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setBackgroundPaint(null);
        plot.setInteriorGap(0.04);
//        plot.setOutlineVisible(false);

        // use gradients and white borders for the section colours
        plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
        plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
        plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
        plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
        plot.setBaseSectionOutlinePaint(Color.WHITE);
        plot.setSectionOutlinesVisible(true);
        plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f));

        // customise the section label appearance
        plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
        plot.setLabelLinkPaint(Color.WHITE);
        plot.setLabelLinkStroke(new BasicStroke(2.0f));
        plot.setLabelOutlineStroke(null);
        plot.setLabelPaint(Color.WHITE);
        plot.setLabelBackgroundPaint(null);
        
        // add a subtitle giving the data source
        TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", 
                new Font("Courier New", Font.PLAIN, 12));
        source.setPaint(Color.WHITE);
        source.setPosition(RectangleEdge.BOTTOM);
        source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
        chart.addSubtitle(source);
        return chart;

    }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:60,代碼來源:PieChartDemo1.java

示例14: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
private static JFreeChart createChart (PieDataset dataset){
	JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false);
	return chart;
}
 
開發者ID:ser316asu,項目名稱:Dahlem_SER316,代碼行數:5,代碼來源:PopChartPanel.java


注:本文中的org.jfree.chart.ChartFactory.createPieChart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。