(I want in X-axis the values of column 0 and in the Y-axis the values of column 1, the variable arrayVars has 2 cols and several cols)
My code is:
Code: Select all
public JFreeChart OneColorChart(String vInDep, String vDep){
// create a dataset...
final double[][] data = new double[arrayVars.length][arrayVars[0].length];
/* Recorremos el array bidimensional añadiéndolo al chart, siempre y cuando no exista valor nulo por fila */
for (int i=0; i<arrayVars.length; i++)
{
for(int j=0; j<arrayVars[0].length; j++)
{
if( (null != arrayVars[i][0]) && (null != arrayVars[i][1]) )
{
data[i][j] = Double.parseDouble(arrayVars[i][j]);
}
}
}
final CategoryDataset dataset = DatasetUtilities.createCategoryDataset(
"Series ", "Type ", data
);
final JFreeChart chart = ChartFactory.createAreaChart(
"Area Chart", // chart title
"Category", // domain axis label
"Value", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
return chart;
}
Badly is filled up the variable data?,