I am trying to scroll my XYBarChart horizontally, I am following one of the JfreeChart's Demo "TranslateDemo1.java" in which the source code you can find here:
The source code works fine for a "TimeSeriesChart".
However I tried with "XYBarChart" and WHEN I SLIDE THE BAR the behavior is not the same.
Just to be clear I replaced the line #157 with the following source code:
JFreeChart chart1= ChartFactory.createXYBarChart(
"Title",
null,
true,
"Ylabel",
xyDatasetTranslating,
PlotOrientation.VERTICAL,
true,
true,
false);
Does anyone know why the application is behaving in this way? and how I could possibly fix it.
Thanks,
TranslatingXYDataset
presently implementsXYDataset
; instead, you'll need to implementIntervalXYDataset
, as required byJFreeChart.createXYBarChart
.Here is a source code that implement a simple solution.
Thanks trashgod :D But I gave up on this approach. I need to get some work done over here ;) So in order to navigate on the graph I used a different dataset
org.jfree.data.time.DynamicTimeSeriesCollection
.This class is aimed for real-time applications in which we have the ability to append new data and discard the oldest in a pretty fast way (depend on your input data). In summary, every time that someone scroll the bar I just need to change my underlying dataset, and that will fire a
PlotChangeEvent
which, in turn, gets passed on to the chart and results in aChartChangeEvent
being fired.This chain of events is used to ensure that charts are automatically updated whenever a change is made to any component of the chart.
Once again, thank you very much