Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
[email protected] webmail now available. Want one? Go here.
Cannot use outlook/hotmail/live here to register as they blocking our mail servers. #microsoftdeez
Obey the Epel!

Paste

Pasted as Java by registered user Dieter987 ( 8 years ago )
import org.jfree.chart.*;
import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.demo.BarDemo;
import org.jfree.chart.demo.ChartData;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class BarChart extends ApplicationFrame {



public BarChart(String title, List<ChartData> listData) {
super(title);

DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (ChartData chartData : listData) {
dataset.addValue(chartData.getValue(), chartData.getRow(), chartData.getColumn());
}
listData.add(new ChartData(1.0, "Row 1", "Column 1"));

JFreeChart chart = ChartFactory.createBarChart(
"Balkendiagramm", // chart title
"X", // domain axis label
"Y", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // URLs
);
ChartPanel chartPanel = new ChartPanel(chart, false);
chartPanel.setPreferredSize(new Dimension(1000, 800));
setContentPane(chartPanel);
}

public static void main(String[] args) {
BarChart x= new BarChart("", null);
BarChart demo = new BarChart("",null);
List<ChartData> listData = new ArrayList<>();
BarChart barDemo = new BarChart("", listData);
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}


package org.jfree.chart.demo;

public class ChartData {
 double value;
 public double getValue() {
  return value;
 }
 
 String row;
 public String getRow() {
  return row;
 }
 
 String column;
 public String getColumn() {
  return column;
 }
 
 public ChartData (double x, String y,String z){
  this.value=x;
  this.row=y;
  this.column=z;
 }
}

 

Revise this Paste

Your Name: Code Language: