I want to generate a bar graph based from user inputs but, I tried passing it from my main class to the class where I coded my graph and it doesn't work.
here's a part of my main class. It's were I will get the value.
public double computeE1() {
double x1 = sFrame.s1;
double x2 = tFrame.t1;
double x3 = fFrame.f1;
E1 = 5.278 + ((-0.172)*x1) + ((-0.197)*x2) + ((-0.191)*x3);
return E1;
}
and here's my JFreeChart class
public class BarChart extends ApplicationFrame {
GUImain gui; //main class
public BarChart(final String title)
{
super(title);
final CategoryDataset dataset = createDataset();
final JFreeChart chart = createChart(dataset);
final ChartPanel chartPanel = new ChartPanel(chart);
chartPanel.setPreferredSize(new Dimension(500,270));
setContentPane(chartPanel);
}
private CategoryDataset createDataset()
{
double e1 = gui.E1;
double e2 = gui.E2;
double e3 = gui.E3;
double e4 = gui.E4;
DefaultCategoryDataset ds = new DefaultCategoryDataset();
ds.addValue(e1, "asdas", null);
ds.addValue(e2, "asdasda", null);
ds.addValue(e3, "sar", null);
ds.addValue(e4, "asda", null);
return ds;
}