这是我的表(在 mysql 中):
mysql> select device from user_management;
+--------+
| device |
+--------+
| APPLE |
| HTC |
| HTC |
| NOKIA |
| APPLE |
| APPLE |
+--------+
6 rows in set (0.00 sec)
我的代码是
<%
String query1 = "select device,count(device) from user_management where device='"+APPLE+"'";
JDBCCategoryDataset dataset = new JDBCCategoryDataset("jdbc:mysql://localhost:8080/apps","com.mysql.jdbc.Driver","root","root");
dataset.executeQuery(query1);
System.out.println("query1");
JFreeChart chart = ChartFactory.createBarChart3D("Device Statictics","Device","Count",dataset,PlotOrientation.VERTICAL,true,true,false);
try
{
ChartUtilities.saveChartAsJPEG(new File("D:/dvc.png"),chart,500,400);
}
catch(IOException e)
{
System.out.println(".....there is a problem in your chart. ");
}
%>
并且基于设备名称(APPLE,NOKIA,SAMSUNG),我想创建一个条形图,显示“设备编号 VS 设备”。我想在 jsp 页面中显示这个。
您的任何意见将不胜感激。