我正在尋找一個圖表生成庫,它將生成餅圖或數據庫數據的趨勢圖。這裏最重要的因素是圖形應該是活的(每次我刷新它應該從數據庫更新),我想集成到jsf2頁面。jsf圖表生成庫
任何JavaScript庫/ java庫,我可以用來集成到jsf應用程序?我有簡單的jsf應用程序(mojarra)。將primefaces/richfaces添加到應用程序。請建議一些我可以使用的庫/工具。
我正在尋找一個圖表生成庫,它將生成餅圖或數據庫數據的趨勢圖。這裏最重要的因素是圖形應該是活的(每次我刷新它應該從數據庫更新),我想集成到jsf2頁面。jsf圖表生成庫
任何JavaScript庫/ java庫,我可以用來集成到jsf應用程序?我有簡單的jsf應用程序(mojarra)。將primefaces/richfaces添加到應用程序。請建議一些我可以使用的庫/工具。
不確定關於jsf,但此示例顯示如何將JFreeChart連接到數據庫數據集。易於修改定期更新,如果這是你追求的:
來源是:http://www.tutorialspoint.com/jfreechart/jfreechart_database_interface.htm
import java.io.*;
import java.sql.*;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
public class PieChart_DB
{
public static void main(String[ ] args)throws Exception
{
String mobilebrands[] = {
"IPhone 5s",
"SamSung Grand",
"MotoG",
"Nokia Lumia"
};
/* Create MySQL Database Connection */
Class.forName("com.mysql.jdbc.Driver");
Connection connect = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/jf_testdb" ,
"root",
"root123");
Statement statement = connect.createStatement();
ResultSet resultSet = statement.executeQuery("select * from dataset_tb");
DefaultPieDataset dataset = new DefaultPieDataset();
while(resultSet.next())
{
dataset.setValue(
resultSet.getString("brandname") ,
Double.parseDouble(resultSet.getString("datavalue")));
}
JFreeChart chart = ChartFactory.createPieChart(
"Mobile Sales", // chart title
dataset, // data
true, // include legend
true,
false);
int width = 560; /* Width of the image */
int height = 370; /* Height of the image */
File pieChart = new File("Pie_Chart.jpeg");
ChartUtilities.saveChartAsJPEG(pieChart , chart , width , height);
}
}
Charting!=從我的角度來報告。圖表是報告的一部分,但報告往往是更多... – Kukeltje
@kukeltje你正在寫。 –
@Constantin我看到的教程要求我將richfaces添加到我的jsf應用程序中。我可以不用richfaces來完成它。 –
你看着JFreeChart的? https://en.wikipedia.org/wiki/JFreeChart我已經在過去使用它,它很不錯。 – Constantin
Charting!=從我的角度來看報告。圖表是報表的一部分,但報表通常更多...所以OP必須更清楚需要什麼 – Kukeltje
@Kukeltje我正在尋找一個可以從數據庫生成圖表的工具。 –