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


Java ChartFactory.createBarChart方法代碼示例

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


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

示例1: writeRankVSPercentage

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public static void writeRankVSPercentage(File outputFile, String add, List<ResultList>[] resultsOriginal, List<List<ResultList>>[] resultsDecoy, int length) throws Exception{

		for(List<ResultList> o:resultsOriginal){
			for(List<List<ResultList>> ds:resultsDecoy){
				String name="RankVSpercentage";
				if(ds.size()>1)name+="Mean";
				Map<String,int[]> numbers=new TreeMap<String,int[]>();
				for(List<ResultList> d:ds){
					List<ResultList> merged=ResultList.mergeResults(new List[]{o,d});
					for(int i=0;i<merged.size();i++){
						ResultList rl=merged.get(i);
						for(int j=0;j<Math.min(length,rl.results.size());j++){
							String key=rl.query.getDB()+"-"+rl.results.get(j).getDB();
							if(!numbers.containsKey(key))numbers.put(key, new int[length]);
							numbers.get(key)[j]=numbers.get(key)[j]+1;
						}
					}
				}

				String fileName="";
				final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
				for(Entry<String, int[]> n:numbers.entrySet()){
					double all=0;
					for(int i=0;i<n.getValue().length;i++){
						dataset.addValue(n.getValue()[i], n.getKey(), Integer.toString(i));
					}
					fileName+=n.getKey()+"---";
				}

				fileName=fileName.substring(0,fileName.length()-3);

				final JFreeChart chart = ChartFactory.createBarChart("Boxplot","Ranks","Percentage",dataset);
				ChartUtilities.saveChartAsJPEG(new File(outputFile.getPath()+"\\"+name+"_"+fileName+add+".jpg"), chart, Math.min(2000,length*100), 1000);
			}
		}
	}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:37,代碼來源:Plot.java

示例2: createBarChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates the histogram chart.
 * 
 * @return
 */
private JFreeChart createBarChart() {
	JFreeChart chart = ChartFactory.createBarChart(null, null, null, createBarDataset(), PlotOrientation.VERTICAL,
			false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	CategoryPlot plot = (CategoryPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	BarRenderer renderer = (BarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NOMINAL));
	renderer.setBarPainter(new StandardBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:30,代碼來源:NominalAttributeStatisticsModel.java

示例3: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Creates a sample chart.
 *
 * @param dataset  the dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart(
        "Performance: JFreeSVG vs Batik", null /* x-axis label*/, 
            "Milliseconds" /* y-axis label */, dataset);
    chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG " 
            + "format (lower bars = better performance)"));
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    chart.getLegend().setFrame(BlockBorder.NONE);
    return chart;
}
 
開發者ID:jfree,項目名稱:jfree-fxdemos,代碼行數:24,代碼來源:BarChartFXDemo1.java

示例4: testAutoRange1

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * A simple test for the auto-range calculation looking at a
 * NumberAxis used as the range axis for a CategoryPlot.
 */
public void testAutoRange1() {
    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();
    assertEquals(axis.getLowerBound(), 0.0, EPSILON);    
    assertEquals(axis.getUpperBound(), 210.0, EPSILON);    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:24,代碼來源:NumberAxisTests.java

示例5: createBarChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return the chart.
 */
private static JFreeChart createBarChart() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

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

    // create the chart...
    return ChartFactory.createBarChart(
        "Horizontal Bar Chart",
        "Domain", "Range",
        dataset,
        PlotOrientation.HORIZONTAL,
        true,     // include legend
        true,
        false
    );

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

示例6: testAutoRange1

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * A simple test for the auto-range calculation.
 */
public void testAutoRange1() {
    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
    );
    NumberAxis axis = (NumberAxis) chart.getCategoryPlot().getRangeAxis();
    // range should be 0.0 - 210.0
    assertTrue(same(axis.getLowerBound(), 0.0, 0.00001));    
    assertTrue(same(axis.getUpperBound(), 210.0, 0.00001));    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:NumberAxisTests.java

示例7: createBarChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * Create a bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createBarChart() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

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

    // create the chart...
    return ChartFactory.createBarChart(
        "Bar Chart",
        "Domain", "Range",
        dataset,
        PlotOrientation.HORIZONTAL,
        true,     // include legend
        true,
        true
    );

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

示例8: writeRankVSPercentage

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public void writeRankVSPercentage(File outputFile, int length, String add) throws Exception{

		int[][] sortedIndizes=getIndizesOfSortedScores();
		Map<String,int[]> numbers=new TreeMap<String,int[]>();
		numbers.put("Decoy", new int[Math.min(length,sortedIndizes[0].length)]);
		numbers.put("Original", new int[Math.min(length,sortedIndizes[0].length)]);

		for(int i=0;i<sortedIndizes.length;i++){
			int l=0;
			for(int j=0;j<sortedIndizes[i].length;j++){
				int currCol=sortedIndizes[i][j];
				if(Double.isNaN(getSimilarityValue(i,currCol)))continue;
				String method=methodsDB.get(currCol);
				if(typesDB.get(method)==DatabaseType.Original){
					numbers.get("Original")[l]=numbers.get("Original")[l]+1;
				}else if(typesDB.get(method)==DatabaseType.Decoy){
					numbers.get("Decoy")[l]=numbers.get("Decoy")[l]+1;					
				}
				l++;
				if(l>=numbers.get("Original").length)break;
			}			
		}
		final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
		for(Entry<String, int[]> n:numbers.entrySet()){
			for(int i=0;i<n.getValue().length;i++){
				dataset.addValue(n.getValue()[i], n.getKey(), Integer.toString(i));
			}
		}

		final JFreeChart chart = ChartFactory.createBarChart("BarChart","Ranks","Percentage",dataset);
		ChartUtilities.saveChartAsJPEG(new File(outputFile.getPath()+sep+add+"RankVSpercentage_"+getMethodsQueryAndDBString()+".jpg"), chart, Math.min(2000,length*100), 1000);			
	}
 
開發者ID:boecker-lab,項目名稱:passatuto,代碼行數:33,代碼來源:SimilarityMatrix.java

示例9: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public ChartPanel createChart(final String title,
                              final CategoryDataset dataset,
                              final String xlabel,
                              final String ylable) {
    JFreeChart chart = ChartFactory.createBarChart(title, xlabel, ylable, dataset);
    ChartUtils.setAntiAlias(chart);
    ChartUtils.setBarRenderer(chart.getCategoryPlot(), false);
    ChartUtils.setXAixs(chart.getCategoryPlot());
    ChartUtils.setYAixs(chart.getCategoryPlot());
    chart.getLegend().setFrame(new BlockBorder(Color.WHITE));
    ChartPanel chartPanel = new ChartPanel(chart);
    return chartPanel;
}
 
開發者ID:Fanping,項目名稱:iveely.ml,代碼行數:14,代碼來源:BarChart.java

示例10: barPlt

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public barPlt(String title, String x_title, String y_title, String space, String Categories) throws Exception{
    super("");
   DefaultCategoryDataset dataset = new DefaultCategoryDataset();
   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.addValue(new Double(jc.eval("2dbl("+jc.eval(bf.substring(0,bf.indexOf(',')))+")")),
                              bf.substring(bf.indexOf(',')+1,bf.lastIndexOf(',')),
                              bf.substring(bf.lastIndexOf(',')+1));
    }
    if(title==null)
      title = "Bar Chart";
    if(y_title == null)
       y_title = "y";
    if(x_title == null)
        x_title="x";
    
      chart = ChartFactory.createBarChart(
                           title,
                           x_title,
                           y_title,
                           dataset,
                           PlotOrientation.VERTICAL, // orientation
                           true,                     // include legend
                           true,                     // tooltips?
                           false                     // URLs?
                    );
     if(space!=null){
         BarRenderer renderer = (BarRenderer) ((CategoryPlot)chart.getPlot()).getRenderer();
          renderer.setItemMargin(new Double(space));
     }

    
}
 
開發者ID:mathhobbit,項目名稱:EditCalculateAndChart,代碼行數:38,代碼來源:barPlt.java

示例11: crearBarChartCosteEnergiaRescateVictimas

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public void crearBarChartCosteEnergiaRescateVictimas(CategoryDataset dataset) {
         JFreeChart chart = ChartFactory.createBarChart(
        "Energ�a consumida para salvar las victimas ", // chart title
        "Victimas ordenadas por tiempo de rescate", // domain axis label
        "Energ�a consumida", // range axis label
        dataset, // data
        PlotOrientation.VERTICAL, // orientation
        true, // include legend
        true, // tooltips?
        false // URLs?
        );
        ChartPanel chartPanel = new ChartPanel(chart);
        chart.setBackgroundPaint(Color.white);
        CategoryPlot plot = chart.getCategoryPlot();
        plot.setBackgroundPaint(Color.lightGray);
        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);
//        return chart;
            }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:31,代碼來源:VisualizacionJfreechart.java

示例12: EnergyChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
public EnergyChart(String appFrame , String chartTitle ) throws IOException {
      super(appFrame);  
     
		new EnergyFactory();
		_energy = EnergyFactory.getEnergy();
	
		JFreeChart barChart = ChartFactory.createBarChart(
         chartTitle,           
         "",            
         "Visited Frequency ",            
         createDataset(),          
         PlotOrientation.VERTICAL,           
         true, true, false);
         
      ChartPanel chartPanel = new ChartPanel( barChart );        
      chartPanel.setPreferredSize(new java.awt.Dimension( 560 , 367 ) );  
      setContentPane(chartPanel);
      
      EnergyChartDialog dlg = new EnergyChartDialog(App.getFrame(), Local.getString("Time Management/Energy Bar Chart"),chartPanel);
;
    
      Dimension frmSize = App.getFrame().getSize();
      Point loc = App.getFrame().getLocation();
 
      dlg.setLocation((frmSize.width - dlg.getSize().width) / 2 + loc.x, (frmSize.height - dlg.getSize().height) / 2 + loc.y);
     // dlg.add(jPanel4);
      dlg.setVisible(true);
      //setContentPane( chartPanel ); 
   }
 
開發者ID:ser316asu,項目名稱:Wilmersdorf_SER316,代碼行數:30,代碼來源:EnergyChart.java

示例13: testAutoRange3

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
/**
 * A simple test for the auto-range calculation.
 */
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.createBarChart(
        "Test", 
        "Categories",
        "Value",
        dataset,
        PlotOrientation.VERTICAL,
        false, 
        false,
        false
    );
    NumberAxis axis = (NumberAxis) chart.getCategoryPlot().getRangeAxis();
    axis.setAutoRangeIncludesZero(false);
    
    // range should be 100.0 - 205.0
    assertTrue(same(axis.getLowerBound(), 95.0, 0.00001));    
    assertTrue(same(axis.getUpperBound(), 205.0, 0.00001));    
    
    DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
    dataset2.setValue(900.0, "Row 1", "Column 1");
    dataset2.setValue(1000.0, "Row 1", "Column 2");
    chart.getCategoryPlot().setDataset(dataset2);
    assertTrue(same(axis.getLowerBound(), 895.0, 0.00001));    
    assertTrue(same(axis.getUpperBound(), 1005.0, 0.00001));    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:32,代碼來源:NumberAxisTests.java

示例14: createNominalChart

import org.jfree.chart.ChartFactory; //導入方法依賴的package包/類
private JFreeChart createNominalChart() {
	JFreeChart chart;
	CategoryDataset dataset = createNominalDataSet();

	// create the chart...
	String domainName = dataTable == null ? MODEL_DOMAIN_AXIS_NAME : dataTable.getColumnName(plotColumn);
	chart = ChartFactory.createBarChart(null, // chart title
			domainName, // x axis label
			RANGE_AXIS_NAME, // y axis label
			dataset, // data
			PlotOrientation.VERTICAL, true, // include legend
			true, // tooltips
			false // urls
			);

	CategoryPlot plot = chart.getCategoryPlot();

	BarRenderer renderer = new BarRenderer();
	if (dataset.getRowCount() == 1) {
		renderer.setSeriesPaint(0, Color.RED);
		renderer.setSeriesFillPaint(0, Color.RED);
	} else {
		for (int i = 0; i < dataset.getRowCount(); i++) {
			Color color = getColorProvider(true).getPointColor((double) i / (double) (dataset.getRowCount() - 1));
			renderer.setSeriesPaint(i, color);
			renderer.setSeriesFillPaint(i, color);
		}
	}
	renderer.setBarPainter(new RapidBarPainter());
	renderer.setDrawBarOutline(true);
	plot.setRenderer(renderer);

	// rotate labels
	if (isLabelRotating()) {
		plot.getDomainAxis().setTickLabelsVisible(true);
		plot.getDomainAxis().setCategoryLabelPositions(
				CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
	}

	return chart;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:42,代碼來源:DistributionPlotter.java

示例15: createChart

import org.jfree.chart.ChartFactory; //導入方法依賴的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


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