当前位置: 首页>>代码示例>>Java>>正文


Java PiePlot.setIgnoreZeroValues方法代码示例

本文整理汇总了Java中org.jfree.chart.plot.PiePlot.setIgnoreZeroValues方法的典型用法代码示例。如果您正苦于以下问题:Java PiePlot.setIgnoreZeroValues方法的具体用法?Java PiePlot.setIgnoreZeroValues怎么用?Java PiePlot.setIgnoreZeroValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.chart.plot.PiePlot的用法示例。


在下文中一共展示了PiePlot.setIgnoreZeroValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
public PieChart() {
    DefaultPieDataset data = getDataSet();
    JFreeChart chart = ChartFactory.createPieChart3D("水果产量", data, true, false, false);
    //设置百分比
    PiePlot pieplot = (PiePlot) chart.getPlot();
    DecimalFormat df = new DecimalFormat("0.00%");//获得一个DecimalFormat对象,主要是设置小数问题
    NumberFormat nf = NumberFormat.getNumberInstance();//获得一个NumberFormat对象
    StandardPieSectionLabelGenerator sp1 = new StandardPieSectionLabelGenerator("{0}  {2}", nf, df);//获得StandardPieSectionLabelGenerator对象
    pieplot.setLabelGenerator(sp1);//设置饼图显示百分比

    //没有数据的时候显示的内容
    pieplot.setNoDataMessage("无数据显示");
    pieplot.setCircular(false);
    pieplot.setLabelGap(0.02D);

    pieplot.setIgnoreNullValues(true);//设置不显示空值
    pieplot.setIgnoreZeroValues(true);//设置不显示负值
    frame1 = new ChartPanel(chart, true);
    chart.getTitle().setFont(new Font("宋体", Font.BOLD, 20));//设置标题字体
    PiePlot piePlot = (PiePlot) chart.getPlot();//获取图表区域对象
    piePlot.setLabelFont(new Font("宋体", Font.BOLD, 10));//解决乱码
    chart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 10));
}
 
开发者ID:leon66666,项目名称:financehelper,代码行数:24,代码来源:PieChart.java

示例2: testGetLegendItems

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Some checks for the getLegendItems() method.
 */
public void testGetLegendItems() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Item 1", 1.0);
    dataset.setValue("Item 2", 2.0);
    dataset.setValue("Item 3", 0.0);
    dataset.setValue("Item 4", null);
   
    PiePlot plot = new PiePlot(dataset);
    plot.setIgnoreNullValues(false);
    plot.setIgnoreZeroValues(false);
    LegendItemCollection items = plot.getLegendItems();
    assertEquals(4, items.getItemCount());
    
    // check that null items are ignored if requested
    plot.setIgnoreNullValues(true);
    items = plot.getLegendItems();
    assertEquals(3, items.getItemCount());
    
    // check that zero items are ignored if requested
    plot.setIgnoreZeroValues(true);
    items = plot.getLegendItems();
    assertEquals(2, items.getItemCount());
    
    // check that negative items are always ignored
    dataset.setValue("Item 5", -1.0);
    items = plot.getLegendItems();
    assertEquals(2, items.getItemCount());        
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:32,代码来源:PiePlotTests.java

示例3: getMultiplePieChart

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
private JFreeChart getMultiplePieChart( BaseChart chart, CategoryDataset[] dataSets )
{
    JFreeChart multiplePieChart = ChartFactory.createMultiplePieChart( chart.getName(), dataSets[0], TableOrder.BY_ROW,
        !chart.isHideLegend(), false, false );

    setBasicConfig( multiplePieChart, chart );
    
    if ( multiplePieChart.getLegend() != null )
    {
        multiplePieChart.getLegend().setItemFont( SUB_TITLE_FONT );
    }
    
    MultiplePiePlot multiplePiePlot = (MultiplePiePlot) multiplePieChart.getPlot();
    JFreeChart pieChart = multiplePiePlot.getPieChart();
    pieChart.setBackgroundPaint( COLOR_TRANSPARENT );
    pieChart.getTitle().setFont( SUB_TITLE_FONT );

    PiePlot piePlot = (PiePlot) pieChart.getPlot();
    piePlot.setBackgroundPaint( COLOR_TRANSPARENT );
    piePlot.setOutlinePaint( COLOR_TRANSPARENT );
    piePlot.setLabelFont( LABEL_FONT );
    piePlot.setLabelGenerator( new StandardPieSectionLabelGenerator( "{2}" ) );
    piePlot.setSimpleLabels( true );
    piePlot.setIgnoreZeroValues( true );
    piePlot.setIgnoreNullValues( true );
    piePlot.setShadowXOffset( 0d );
    piePlot.setShadowYOffset( 0d );

    for ( int i = 0; i < dataSets[0].getColumnCount(); i++ )
    {
        piePlot.setSectionPaint( dataSets[0].getColumnKey( i ), COLORS[(i % COLORS.length)] );
    }

    return multiplePieChart;
}
 
开发者ID:ehatle,项目名称:AgileAlligators,代码行数:36,代码来源:DefaultChartService.java

示例4: testGetLegendItems

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * Some checks for the getLegendItems() method.
 */
public void testGetLegendItems() {
    DefaultPieDataset dataset = new DefaultPieDataset();
    dataset.setValue("Item 1", 1.0);
    dataset.setValue("Item 2", 2.0);
    dataset.setValue("Item 3", 0.0);
    dataset.setValue("Item 4", null);

    PiePlot plot = new PiePlot(dataset);
    plot.setIgnoreNullValues(false);
    plot.setIgnoreZeroValues(false);
    LegendItemCollection items = plot.getLegendItems();
    assertEquals(4, items.getItemCount());

    // check that null items are ignored if requested
    plot.setIgnoreNullValues(true);
    items = plot.getLegendItems();
    assertEquals(3, items.getItemCount());

    // check that zero items are ignored if requested
    plot.setIgnoreZeroValues(true);
    items = plot.getLegendItems();
    assertEquals(2, items.getItemCount());

    // check that negative items are always ignored
    dataset.setValue("Item 5", -1.0);
    items = plot.getLegendItems();
    assertEquals(2, items.getItemCount());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:32,代码来源:PiePlotTests.java

示例5: renderChartToFile

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
private Image renderChartToFile(TotalPaymentSummaryReportResponse response, File chartFile) throws IOException,
        BadElementException, MalformedURLException {
    // For generating pie chart for total payments(example for total deposits) perform following:
    // Create the dataset
    DefaultPieDataset dataset = new DefaultPieDataset();

    dataset.setValue("Pre 10/82 Deposit", response.getTotalDepositsPre1082());
    dataset.setValue("Pre 10/82 Redeposit", response.getTotalRedepositsPre1082());
    dataset.setValue("CSRS: Post 9/82 Deposit", response.getCsrsDepositsPost982());
    dataset.setValue("FERS Postal", response.getFersPostalDepositsPost982());
    dataset.setValue("FERS Non Postal", response.getFersNonPostalDepositsPost982());
    dataset.setValue("Post 9/82 Deposit", response.getTotalDepositsPost982());
    dataset.setValue("Post 9/82 Redeposit", response.getTotalRedepositsPost982());

    // Set following data
    // Create the chart
    JFreeChart chart = ChartFactory.createPieChart("Total Payments", dataset, true, true, false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setLabelFont(new Font("Helvetica", 0, 10));
    plot.setBackgroundPaint(Color.white);
    plot.setIgnoreZeroValues(false);
    plot.setOutlineVisible(false);

    chart.getTitle().setFont(new Font("Helvetica", 1, 14));

    LegendTitle legend = chart.getLegend();
    legend.setItemFont(new Font("Helvetica", 0, 10));
    legend.setPosition(RectangleEdge.RIGHT);

    ChartUtilities.saveChartAsPNG(chartFile, chart, chartWidth, chartHeight);
    Image image = Image.getInstance(chartFile.getAbsolutePath());
    return image;
}
 
开发者ID:NASA-Tournament-Lab,项目名称:CoECI-OPM-Service-Credit-Redeposit-Deposit-Application,代码行数:35,代码来源:TotalPaymentSummaryReportService.java

示例6: init

import org.jfree.chart.plot.PiePlot; //导入方法依赖的package包/类
/**
 * 创建饼状图的步骤如下: 1、创建一个饼状的实例,注意传参的格式,还有需要注意的是此时的数据集应该是defaultPieDataset,
 * 而不是CategoryDataset格式 2、获得饼状图的所在区域 3、设置两个格式化的数据格式,为后面的床架饼状图的实例做基础
 * 4、细节方面是对无数据、零值、负值等情况的处理 5、最后就是设置在出现汉字的地方进行字体内容的设置了(同样的,这是为了防止出现乱码的状况)
 */
public void init() {
	DefaultPieDataset dataset = getDataset();

	JFreeChart chart = ChartFactory.createPieChart3D("The proportion of the book", dataset, true, false, false);

	PiePlot piePlot = (PiePlot) chart.getPlot();
	DecimalFormat df = new DecimalFormat("0.00%");
	NumberFormat nf = NumberFormat.getInstance();

	// 获得StandardPieSectionLabelGenerator对象,生成的格式,{0}表示section名,
	StandardPieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} {2}",
			// {1}表示section的值,{2}表示百分比。可以自定义
			nf, df);
	piePlot.setLabelGenerator(generator);// 设置百分比
	piePlot.setLabelFont(new Font("黑体", Font.ITALIC, 20));

	// 当饼状图内没有有数据时,作如下数据中设置
	piePlot.setNoDataMessage("此时并没有任何数据可用");
	piePlot.setCircular(false);
	piePlot.setLabelGap(0.02D);

	piePlot.setIgnoreNullValues(true);// 设置不显示空位
	piePlot.setIgnoreZeroValues(true);// 设置不显示负值或零值

	panel = new ChartPanel(chart, true);
	chart.getTitle().setFont(new Font("微软雅黑", Font.PLAIN, 25));
	chart.getLegend().setItemFont(new Font("微软雅黑", Font.PLAIN, 16));

	File dir = new File("images\\");
	if (!dir.exists()) {
		dir.mkdir();
	}
	String fName = String.valueOf(System.currentTimeMillis()) + "pie.png";
	File file = new File("images\\", fName);
	try {
		ChartUtilities.saveChartAsPNG(file, chart, 550, 400);
	} catch (IOException e) {

		e.printStackTrace();
	}

}
 
开发者ID:metaotao,项目名称:doubanbook,代码行数:48,代码来源:PieChart.java


注:本文中的org.jfree.chart.plot.PiePlot.setIgnoreZeroValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。