Sunday, March 20, 2011

Is there a simple way to remove a TimeSeries from a displayed JFreeChart Chart?

I have a Swing application which uses JFreeChart to display one of a series of queries. Some of these queries have a composite TimeSeries key. Each component of this key can contain a few values, but when rendered makes a very noisy graph. I would like a simple way for the users to hide/show some of the TimeSeries in the displayed Chart component.

From stackoverflow
  • It looks like the setSeriesVisible method of AbstractRenderer is what you're looking for. Although this forum discussion suggests that it may only work in the latest release but there's a work around for earlier releases.

    Ryan Ransford : The setSeriesVisible method was not one hundred percent of my answer, but you came close. I also needed to query the displayed chart to find out which series contained the key or key components I needed to hide.
  • I'm not quite sure what you mean, but if you want to keep item shapes apart, have a look at the AnalysisXYItemRenderer class (or corresponding). There's a transXDiff there that can be used for such calculations (such as accumulating the diff and only show plot shapes when that accumulated value reaches a limit).

    It was a couple of years ago I did this, so things might have changed in JFreeChart since then.

0 comments:

Post a Comment