Hi,
I am trying to add a Horizontal Scroll Bar to my Line, High/Low, Candelstick Finencial diagrams. I would like to sroll just the Graphs, the Vertical axis should remain visible on the side(s).
Could someone help me, how to solve this problem with the JFreeChart?
Thanx,
Adam
JFreeChart + Scrollbar
One proposal for a temporary solution until 1.0.0 is released is here:
http://www.jfree.org/phpBB2/viewtopic.php?t=644
http://www.jfree.org/phpBB2/viewtopic.php?t=644
And another:
http://www.jfree.org/phpBB2/viewtopic.php?t=6342
http://www.jfree.org/phpBB2/viewtopic.php?t=6342
LineChart and BarChart problems scrolling horizontally
I am working with JChart v.0.9.18, using the PanScrollZoomDemo features for permitting a chart to be scrollable. However, I am having trouble with the feature.
The chart displays correctly, at first, inside of the PanScrollZoom panel with three series of data graphed. However, once I depress the "plus sign (+)" button for the "zoom in" feature to enable the panning, the data series are no longer displayed, but the scrollbar is enabled.
Next, I use the scrollbar to pan right, and a graph with the series 1 and 2 data displays without series 3 data.
Next, I use the scrollbar to pan left, and the display returns to the no data and no graph.
Lastly, I use the scrollbar to pan left once more, and a graph with the series 3 data displays without series 1 and 2.
This is repeatable as I scroll/pan left or right.
I think the problem is that I am using a LineChart with a CategoryAxis (and a ValueAxis), whereas the feature seems to be using a LineXYChart with two Number Axes. The code checks for a XYPlot, but I am using the CategoryPlot. Therefore, I have added code to test for and handle the CategoryPlot instance at each place that tests for a plot that is an instance of the XYPlot. However, I still can not get the feature to scroll correctly.
I need to work this out for both Line and Bar charts.
I have some MS Word docs of images of this situation, but am unaware of how to attach the doc?
Any suggestions on making this work correctly?
-cgw
The chart displays correctly, at first, inside of the PanScrollZoom panel with three series of data graphed. However, once I depress the "plus sign (+)" button for the "zoom in" feature to enable the panning, the data series are no longer displayed, but the scrollbar is enabled.
Next, I use the scrollbar to pan right, and a graph with the series 1 and 2 data displays without series 3 data.
Next, I use the scrollbar to pan left, and the display returns to the no data and no graph.
Lastly, I use the scrollbar to pan left once more, and a graph with the series 3 data displays without series 1 and 2.
This is repeatable as I scroll/pan left or right.
I think the problem is that I am using a LineChart with a CategoryAxis (and a ValueAxis), whereas the feature seems to be using a LineXYChart with two Number Axes. The code checks for a XYPlot, but I am using the CategoryPlot. Therefore, I have added code to test for and handle the CategoryPlot instance at each place that tests for a plot that is an instance of the XYPlot. However, I still can not get the feature to scroll correctly.
I need to work this out for both Line and Bar charts.
I have some MS Word docs of images of this situation, but am unaware of how to attach the doc?
Any suggestions on making this work correctly?
-cgw
scrollable CategoryAxis
I wonder how you have realized a scrollable CategoryAxis. In the last months I didn't work with JFreeChart; maybe there are new features meanwhile. In the past, because of this scrolling problem, I only used XYPlot, even for bar charts and such. For these then I used SymbolicAxis which is derived from ValueAxis (and not CategoryAxis). Sorry, that I can't say more.
JFreeChart + ScrollBar
Yes, I had added code to the PanScrollZoomDemo Class to handle CategoryAxis. However, the scrollbar feature did not work completely in that only some or none of the data would display when I used the scrollbar to pan left or right.
Since the last posting, I decided to convert my code to using the XYAxis instead. However, I get the same results.
-cgw
Since the last posting, I decided to convert my code to using the XYAxis instead. However, I get the same results.
-cgw
JFreeChart + ScrollBar
Okay, I was able to get the scrollbar working.
I had been using my own createChart() method and needed two statements from the original PanScrollZoomDemo class that saves the original fit y-axis positions:
ValueAxis axis = xyPlot.getRangeAxis();
this.primYMinMax[0]=-5;
this.primYMinMax[1]=15;
Now that I have added them to my code, with the appropriate values for my charts, the scrolling is working using XYAxis for both the line and bar charts.
BTW: I did not go back and try to get CategoryAxis to work, because it was unclear to me how to get the max range on the x-axis, since the values are categories instead of numbers.
cgw(weckenmc)
I had been using my own createChart() method and needed two statements from the original PanScrollZoomDemo class that saves the original fit y-axis positions:
ValueAxis axis = xyPlot.getRangeAxis();
this.primYMinMax[0]=-5;
this.primYMinMax[1]=15;
Now that I have added them to my code, with the appropriate values for my charts, the scrolling is working using XYAxis for both the line and bar charts.
BTW: I did not go back and try to get CategoryAxis to work, because it was unclear to me how to get the max range on the x-axis, since the values are categories instead of numbers.
cgw(weckenmc)