We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it c开发者_运维知识库an be answered with facts and citations.
Closed 7 years ago.
Improve this questionWhat 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
Options
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
- Use java advanced imaging - jai see histogram demo source
Steps to create a chart using jfreechart
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);
One commonly used charting API is JFreeChart.
I answered in this thread, could be helpful Java graph library for dynamic visualisation
精彩评论