A discussion forum for JFreeChart (a 2D chart library for the Java platform).
-
wisefingaz
- Posts: 6
- Joined: Wed Oct 21, 2009 3:58 am
- antibot: No, of course not.
Post
by wisefingaz » Wed Oct 28, 2009 3:51 am
hi,
i'm trying to create a sliding bar chart. after i created the DefaultCategoryDataset and added value to it, i have encapsulated it in a SlidingCategoryDataset and created the chart as follow:
Code: Select all
SlidingCategoryDataset dataset = new SlidingCategoryDataset (categoryDataset1,0,10);
JFreeChart chart1 = ChartFactory.createBarChart("", "Marks","Frequency", dataset,
PlotOrientation.VERTICAL, true, true, true);
ChartPanel cp1 = new ChartPanel( chart1 );
but after i compile it i can't see the slider so i'm assuming there is an extra work i need to do on either chart1 or cp1 but i have no idea what.
any suggestions?
thanks
-
raj_jfree
- Posts: 20
- Joined: Tue Sep 29, 2009 8:32 am
- antibot: No, of course not.
Post
by raj_jfree » Thu Oct 29, 2009 2:48 am
refer slidingcategorydatasetdemo1.java and slidingcategorydatasetdemo2.java ....
-
wisefingaz
- Posts: 6
- Joined: Wed Oct 21, 2009 3:58 am
- antibot: No, of course not.
Post
by wisefingaz » Thu Oct 29, 2009 6:27 am
thanks
i have been looking for these demo everywhere but i can't find them and i won't be able to purchase the guide as i have to submit the project tomorrow. if you have any information please let me know
-
paradoxoff
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Post
by paradoxoff » Thu Oct 29, 2009 9:32 pm
A ChartPanel doesn´t know the type of the plot that is included in the chart, so the ChartPanel can´t "react" to a specific plot type, not to mention a particular dataset type.
You will have to implement the slider on your own. Just create a JSlider or two buttons to move foreward/backward and register an ActionListener on the JComponent(s) in question. The ActionListener also has to be able to access the SlidingCategoryDataset. In the actionPerformed method, simply call the necessary methods defined by the SlidingCategoryDataset interface, for example call setFirstCategoryIndex(int first) with an incremented or decremented value for "first".