This is my code.
public static Component create_Chart(double[] xValues2, double[] yValues2) throws IOException
{
JInternalFrame iFrame = new JInternalFrame(
WordsInArray.fc.getSelectedFile().toString(),true,true,true,true);
iFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
iFrame.setSize(600, 200);
double[] xVal=new double[xValues.length];
for(int i=0;i<=xValues.length-1;i+=2)
{
xVal[i]=xValues[i];
System.out.println(xVal[i]);
}
double[] yVal=XYValues.get_yValues();
for(int i=1;i<=yValues.length;i+=2)
{
//i++;
System.out.println(yVal[i]);
}
try{
XYSeries series=new XYSeries("Sample");
//series.add(xVal,yVal);
for(int i=0;i<=xValues.length-1;i++)
{
series.add(xVal[i],yVal[i]);
}
XYDataset xyDataset = new XYSeriesCollection(series);
JFreeChart chart = ChartFactory.createXYLineChart
("","Wave number", "Intensity",
xyDataset, PlotOrientation.VERTICAL, false, true, false);
chart.getPlot().setBackgroundPaint( Color.WHITE);
JPanel chartPanel = new ChartPanel(chart);
iFrame.add(chartPanel);
iFrame.pack();
iFrame.setVisible(true);
}
catch(Exception e)
{
e.printStackTrace();
}
return iFrame;
}
I am not able to get the graph in the JInternalFrame
. Did I missed anything in adding the values for the chart? Please let me know how to add array values to add()
.