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


Java CategoryPlot.setDataset方法代码示例

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


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

示例1: visualizarSerieChartAsignRescateVict

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
public void  visualizarSerieChartAsignRescateVict(Color color,CategoryDataset dataset) {
     ChartPanel chartPanel = new ChartPanel(chartNotifAsigResc);
     chartNotifAsigResc.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chartNotifAsigResc.getPlot();
     plot.setBackgroundPaint(color);
     plot.setDataset(dataset);
     plot.setDomainGridlinePaint(Color.white);
     plot.setRangeGridlinePaint(Color.white);
     NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
     rangeAxis.setUpperMargin(0.15);
     CategoryItemRenderer renderer = plot.getRenderer();
     renderer.setItemLabelGenerator(new LabelGenerator(50.0));
     renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
     renderer.setItemLabelsVisible(true);
     chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
   setContentPane(chartPanel);
   this.pack();
   RefineryUtilities.centerFrameOnScreen(this);
   this.setVisible(true);
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:21,代码来源:VisualizacionJfreechart.java

示例2: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
                + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:StackedBarChart3DTests.java

示例3: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * Replaces the dataset and checks that the data range is as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
            + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
            + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:BarChart3DTests.java

示例4: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * Replaces the chart's dataset and then checks that the new dataset is OK.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
               + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:LineChartTests.java

示例5: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * Replaces the chart's dataset and then checks that the new dataset is OK.
 */
public void testReplaceDataset() {
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset(
            "S", "C", data);
    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
               + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:25,代码来源:AreaChartTests.java

示例6: testAutoRange3

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.  In this
 * case, the 'autoRangeIncludesZero' flag is set to false AND the
 * original dataset is replaced with a new dataset.
 */
public void testAutoRange3() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createLineChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    assertEquals(axis.getLowerBound(), 95.0, EPSILON);    
    assertEquals(axis.getUpperBound(), 205.0, EPSILON);    
    
    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(axis.getLowerBound(), 895.0, EPSILON);    
    assertEquals(axis.getUpperBound(), 1005.0, EPSILON);    
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:28,代码来源:NumberAxisTests.java

示例7: testAxisRange

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * A test for a bug reported in the forum.
 */
public void testAxisRange() {
    DefaultCategoryDataset datasetA = new DefaultCategoryDataset();
    DefaultCategoryDataset datasetB = new DefaultCategoryDataset();
    datasetB.addValue(50.0, "R1", "C1");
    datasetB.addValue(80.0, "R1", "C1");
    CategoryPlot plot = new CategoryPlot(
        datasetA, new CategoryAxis(null), new NumberAxis(null), new LineAndShapeRenderer()
    );
    plot.setDataset(1, datasetB);
    plot.setRenderer(1, new LineAndShapeRenderer());
    Range r = plot.getRangeAxis().getRange();
    assertEquals(84.0, r.getUpperBound(), 0.00001);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:17,代码来源:CategoryPlotTests.java

示例8: testDrawWithNullInfo2

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * Draws the chart with a <code>null</code> info object to make sure that 
 * no exceptions are thrown (a problem that was occurring at one point).
 */
public void testDrawWithNullInfo2() {
    boolean success = false;
    try {
        JFreeChart chart = createGanttChart();
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setDataset(createDataset());
        /* BufferedImage img =*/ chart.createBufferedImage(300, 200, null);
        success = true;
    }
    catch (NullPointerException e) {
        success = false;
    }
    assertTrue(success);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:19,代码来源:GanttChartTests.java

示例9: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * Replaces the chart's dataset and then checks that the new dataset is OK.
 */
public void testReplaceDataset() {
    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(null);
    assertEquals(true, l.flag);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:11,代码来源:GanttChartTests.java

示例10: testAxisRange

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * A test for a bug reported in the forum.
 */
public void testAxisRange() {
    DefaultCategoryDataset datasetA = new DefaultCategoryDataset();
    DefaultCategoryDataset datasetB = new DefaultCategoryDataset();
    datasetB.addValue(50.0, "R1", "C1");
    datasetB.addValue(80.0, "R1", "C1");
    CategoryPlot plot = new CategoryPlot(datasetA, new CategoryAxis(null), 
            new NumberAxis(null), new LineAndShapeRenderer());
    plot.setDataset(1, datasetB);
    plot.setRenderer(1, new LineAndShapeRenderer());
    Range r = plot.getRangeAxis().getRange();
    assertEquals(84.0, r.getUpperBound(), 0.00001);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:CategoryPlotTests.java

示例11: test1169972

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * A test for bug report 1169972.
 */
public void test1169972() {
    CategoryPlot plot = new CategoryPlot(null, null, null, null);
    plot.setDomainAxis(new CategoryAxis("C"));
    plot.setRangeAxis(new NumberAxis("Y"));
    plot.setRenderer(new BarRenderer());
    plot.setDataset(new DefaultCategoryDataset());
    assertTrue(plot != null);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:12,代码来源:CategoryPlotTests.java

示例12: createChart

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
private JFreeChart createChart() {
	if (data.getItemCount() > 0) {
		// get cumulative percentages
		KeyedValues cumulative = DataUtilities.getCumulativePercentages(data);

		CategoryDataset categoryDataset = DatasetUtilities.createCategoryDataset(
				"Count for " + this.dataTable.getColumnName(this.countColumn) + " = " + countValue, data);

		// create the chart...
		final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
				this.dataTable.getColumnName(this.groupByColumn), // domain axis label
				"Count", // range axis label
				categoryDataset, // data
				PlotOrientation.VERTICAL, true, // include legend
				true, false);

		// set the background color for the chart...
		chart.setBackgroundPaint(Color.WHITE);

		// get a reference to the plot for further customization...
		CategoryPlot plot = chart.getCategoryPlot();

		CategoryAxis domainAxis = plot.getDomainAxis();
		domainAxis.setLowerMargin(0.02);
		domainAxis.setUpperMargin(0.02);
		domainAxis.setLabelFont(LABEL_FONT_BOLD);
		domainAxis.setTickLabelFont(LABEL_FONT);

		// set the range axis to display integers only...
		NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
		rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
		rangeAxis.setLabelFont(LABEL_FONT_BOLD);
		rangeAxis.setTickLabelFont(LABEL_FONT);

		// second data set (cumulative percentages)
		CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative (Percent)", cumulative);

		LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
		renderer2.setSeriesPaint(0, SwingTools.VERY_DARK_BLUE.darker());

		NumberAxis axis2 = new NumberAxis("Percent of " + countValue);
		axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
		axis2.setLabelFont(LABEL_FONT_BOLD);
		axis2.setTickLabelFont(LABEL_FONT);

		plot.setRangeAxis(1, axis2);
		plot.setDataset(1, dataset2);
		plot.setRenderer(1, renderer2);
		plot.mapDatasetToRangeAxis(1, 1);

		axis2.setTickUnit(new NumberTickUnit(0.1));

		// show grid lines
		plot.setRangeGridlinesVisible(true);

		// bring cumulative line to front
		plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

		if (isLabelRotating()) {
			domainAxis.setTickLabelsVisible(true);
			domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
		}

		return chart;
	} else {
		return null;
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:69,代码来源:ParetoChartPlotter.java

示例13: testAutoRange4

import org.jfree.chart.plot.CategoryPlot; //导入方法依赖的package包/类
/**
 * A check for the interaction between the 'autoRangeIncludesZero' flag
 * and the base setting in the BarRenderer.
 */
public void testAutoRange4() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(100.0, "Row 1", "Column 1");
    dataset.setValue(200.0, "Row 1", "Column 2");
    JFreeChart chart = ChartFactory.createBarChart("Test", "Categories",
            "Value", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    BarRenderer br = (BarRenderer) plot.getRenderer();
    br.setIncludeBaseInRange(false);
    assertEquals(95.0, axis.getLowerBound(), EPSILON);    
    assertEquals(205.0, axis.getUpperBound(), EPSILON);    
    
    br.setIncludeBaseInRange(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(210.0, axis.getUpperBound(), EPSILON);    
    
    axis.setAutoRangeIncludesZero(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(210.0, axis.getUpperBound(), EPSILON);    
    
    br.setIncludeBaseInRange(true);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(210.0, axis.getUpperBound(), EPSILON);    

    // now replacing the dataset should update the axis range...
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    plot.setDataset(dataset2);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(1050.0, axis.getUpperBound(), EPSILON);
    
    br.setIncludeBaseInRange(false);
    assertEquals(0.0, axis.getLowerBound(), EPSILON);    
    assertEquals(1050.0, axis.getUpperBound(), EPSILON);
    
    axis.setAutoRangeIncludesZero(false);
    assertEquals(895.0, axis.getLowerBound(), EPSILON);    
    assertEquals(1005.0, axis.getUpperBound(), EPSILON);        
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:48,代码来源:NumberAxisTests.java


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