List of usage examples for org.jfree.data.jdbc JDBCCategoryDataset getRowCount
@Override public int getRowCount()
From source file:org.opennms.netmgt.charts.ChartUtils.java
/** * @param chartConfig/*from ww w . j a va2 s. c om*/ * @param baseDataSet * @throws SQLException */ private static DefaultCategoryDataset buildCategoryDataSet(BarChart chartConfig) throws SQLException { DefaultCategoryDataset baseDataSet = new DefaultCategoryDataset(); /* * Configuration can contain more than one series. This loop adds * single series data sets returned from sql query to a base data set * to be displayed in a the chart. */ Connection conn = null; try { conn = DataSourceFactory.getInstance().getConnection(); Iterator<SeriesDef> it = chartConfig.getSeriesDefCollection().iterator(); while (it.hasNext()) { SeriesDef def = it.next(); JDBCCategoryDataset dataSet = new JDBCCategoryDataset(conn, def.getJdbcDataSet().getSql()); for (int i = 0; i < dataSet.getRowCount(); i++) { for (int j = 0; j < dataSet.getColumnCount(); j++) { baseDataSet.addValue(dataSet.getValue(i, j), def.getSeriesName(), dataSet.getColumnKey(j)); } } } } finally { if (conn != null) { conn.close(); } } return baseDataSet; }