What is best and easy to use library for Java graphs? I am working with Swing application and need to integrate a graph for that project
If graphs you mean like clusters nodes and links visualization have a look at graphviz gallery
To generate charts see jfreechart demo Download jfreechart jfreechart-1.0.13
Create Dataset and pass array of data
HistogramDataset dataset = new HistogramDataset();
dataset.addSeries("series label",arrayOfValues,noOfBins);
Create a chart object
JFreeChart chart = ChartFactory.
createHistogram( "plotTitle", "xaxis label", "yaxis label",
dataset, PlotOrientation.VERTICAL, false, false, false);
If swing application use ChartPanel
to render chart
ChartPanel chartPanel = new ChartPanel(chart)
chartPanel.setPreferredSize(new java.awt.Dimension JavaDoc(500, 270));
chartPanel.setMouseZoomable(true, false);
If need to write chart to a file/stream use ChartUtilities.saveChartAsPNG(...)
ChartUtilities.saveChartAsPNG(new File("histogram.PNG"), chart, width, height);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With