grazie, ho risolto, se vi interessa ecco il codice, ho usato JFreeChart:
codice:
import java.awt.Font;
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.category.CategoryDataset;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.CategoryPlot;
import java.util.ArrayList;
public class LLineGraph extends JPanel
{
public LLineGraph(ArrayList<Double> datas, ArrayList<String> type, String title, String typeLabel, String valueLabel)
{
CategoryDataset dataset = createDataset(title, datas, type);
this.add(new ChartPanel(setGraph(title, dataset, typeLabel, valueLabel)));
}
private CategoryDataset createDataset(String title, ArrayList<Double> datas, ArrayList<String> type)
{
final DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
int i = 0;
for(double aData : datas)
{
dataset2.addValue(aData, title, type.get(i));
i += 1;
}
return dataset2;
}
public JFreeChart setGraph(String title, CategoryDataset dataset, String typeLabel, String valueLabel)
{
JFreeChart jfc = ChartFactory.createLineChart(title, // chart title
typeLabel, // domain axis label
valueLabel, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
false, // legend
true, // tooltips
false // urls
);
//jfc.setBackgroundPaint(Color.yellow); // Set the background colour of the chart
jfc.getTitle().setPaint(Color.red); // Adjust the colour of the title
CategoryPlot p = jfc.getCategoryPlot(); // Get the Plot object for a bar graph
p.setBackgroundPaint(new Color(253, 252, 237));// Modify the plot background
p.setRangeGridlinePaint(Color.black); // Modify the colour of the plot gridlines Modify Chart
return jfc;
}
}