Boa tarde,
Estou tentando gerar um gráfico baseado em tempo,
mas está retornando um erro. Eu tenho o seguinte código:
TimeSeries s1 = new TimeSeries(title);
int count = 0;
for(; count < items.size(); count++)
{
SimpleLineGraphItem item = (SimpleLineGraphItem)items.get(count);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date d = new Date();
try
{
d = sdf.parse(item.getKey());
s1.add(new Second(d), item.getValue());
}
catch (ParseException e)
{
e.printStackTrace();
}
}
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
[code]
Porém, quando chega na linha "s1.add(new Second(d), item.getValue());" retorna o seguinte erro:
[code]
log4j:WARN No appenders could be found for logger (br.com.alt.database.Database).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "AWT-EventQueue-0" org.jfree.data.general.SeriesException: TimeSeries.add(): you are trying to add data where the time period class is org.jfree.data.time.Second, but the TimeSeries is expecting an instance of org.jfree.data.time.Day.
at org.jfree.data.time.TimeSeries.add(TimeSeries.java:437)
at org.jfree.data.time.TimeSeries.add(TimeSeries.java:488)
at br.com.uol.graph.SimpleLineGraph.TimeSeriesGraph(SimpleLineGraph.java:85)
at br.com.uol.gui.frame.ChartReportFrame.<init>(ChartReportFrame.java:26)
at br.com.uol.gui.frame.GenChartReportFrame.showChart(GenChartReportFrame.java:230)
at br.com.uol.gui.frame.GenChartReportFrame.showChart(GenChartReportFrame.java:251)
at br.com.uol.gui.frame.GenChartReportFrame$1.actionPerformed(GenChartReportFrame.java:80)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
São muitos registros envolvidos no gráfico (milhares), eu precisava que no eixo-X
fosse apresentada apenas algumas datas, e no eixo-Y TODOS os itens.
Como eu faria isso?
Muito obrigado