本文整理匯總了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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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
);
}
示例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));
}
示例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
);
}
示例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);
}
示例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;
}
示例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));
}
}
示例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;
}
示例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 );
}
示例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));
}
示例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;
}
示例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;
}
}