i created j table i will update this table monthly , i created a free chart to draw a chart using the data from the table , but i doesn't work till the whole column is entered i used for loop to create the table so it will have data < i where i= the row count of j table
can someone help me ??
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int rowcount=Integer.parseInt(jTextField6.getText());
DefaultTableModel dtm = (DefaultTableModel) table.getModel();
dtm.setRowCount(rowcount);
double o=(double) table.getModel().getValueAt(4,2 );
double p=(double) table.getModel().getValueAt(3,1 );
double q=(double) table.getModel().getValueAt(4,1 );
//double lossunit=abs(p-q);
// JOptionPane.showMessageDialog(null,achievement);
dtm.setValueAt(100*abs((o-p)/(p-q)), 4,3 );
}
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int rowcount=Integer.parseInt(jTextField6.getText());
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
DefaultCategoryDataset dts = new DefaultCategoryDataset();
for(int i=0 ;i<rowcount;i++){
double q =(double) table.getModel().getValueAt(i,2 );
dataset .setValue(q,"achieve%", "month"+(i+1) );
double z =(double) table.getModel().getValueAt(i,1 );
dts.setValue(z , "achieve%", "month"+(i+1) );
}
//XYSeriesCollection dataset = new XYSeriesCollection();
JFreeChart chart = ChartFactory.createLineChart("Result", "month", "achieve%", (CategoryDataset) dataset, PlotOrientation.VERTICAL, false, true, false);
JFreeChart Chart1 = ChartFactory.createLineChart(" Target", "month", "achieve%",(CategoryDataset) dts, PlotOrientation.VERTICAL, false, true, false);
CategoryPlot p = chart.getCategoryPlot();
CategoryPlot n = Chart1.getCategoryPlot();
p.setRangeGridlinePaint(Color.black);
n.setRangeGridlinePaint(Color.blue);
ChartFrame frame =new ChartFrame("bar chart", chart);
ChartFrame frame1 =new ChartFrame("bar chart", Chart1);
frame.setVisible(true);
frame.setSize(1200,300);
frame1.setVisible(true);
frame1.setSize(1200,300);
frame1.setLocation(0, 300);
}