I want to built a software for data analysis using machine learning algorithms and I need to visualize the data in charts for preprocessing. I use the following code to display data in the jtable:
I use jfilechooser to open the file and display the data in a jtable as following:
JFileChooser Chooser = new JFileChooser();
FileNameExtensionFilter filter =new FileNameExtensionFilter ("open file
","csv");
Chooser.setFileFilter(filter);
Chooser.showOpenDialog(null);
File f = Chooser.getSelectedFile();
if (f != null) {
String filename1 = f.getAbsolutePath();
filepath.setText(filename1);
} else {
JOptionPane.showMessageDialog(this, "No File Selected");
}
filePath1 = filepath.getText();
File file = new File(filePath1);
//send data to the other tab
jTable1.setModel(new DefaultTableModel(null,new String[]
{"column1","column2","column3","column4"}));
try {
BufferedReader br = new BufferedReader(new FileReader(file));
// get the first line
// get the columns name from the first line
// set columns name to the jtable model
String firstLine = br.readLine();
String[] columnsName = firstLine.split(",");
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
model.setColumnIdentifiers(columnsName);
attributesNum= columnsName.length;
String st;
String eachline;
String[] cells;
DefaultCategoryDataset bardataset =new DefaultCategoryDataset();
// there is a new line
while ((st = br.readLine()) != null) {
// System.out.println(st);
eachline = st.trim();
cells = eachline.split(",");
//show each line in jtable
model.addRow(cells);
after that I want to visualize the data in the table in a bar chart in away similar to weka but I couldn't find a method to do that what I found is methods to create dataset and fill it inside the code.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…