how to increase the size of chartpanel Dynamically
how to increase the size of chartpanel Dynamically
hai,
i have a problem using jfreecharts. i have attached the chartpanel to a Jscrollpane.Based on real time values the chartpanel should resize.i.e for big chart the size of the chartpanel should be big and i will use scroll bars to view the data and for small graphs the chart panel should be small so that i don not use scroll bars . how can i achive this ?
Thanks.
i have a problem using jfreecharts. i have attached the chartpanel to a Jscrollpane.Based on real time values the chartpanel should resize.i.e for big chart the size of the chartpanel should be big and i will use scroll bars to view the data and for small graphs the chart panel should be small so that i don not use scroll bars . how can i achive this ?
Thanks.
whether jfreechart objects can be displayed in jscrollpane
hai ,
Thanks for your reply. It was mentioned that JfreeChart can be displayed in GUI using ChartPanel only.Is it possible to display in Gui using JScrollPane.
Thanks.
Thanks for your reply. It was mentioned that JfreeChart can be displayed in GUI using ChartPanel only.Is it possible to display in Gui using JScrollPane.
Thanks.
whether jfreechart objects can be displayed in jscrollpane
hai ,
Thanks for your reply. It was mentioned that JfreeChart can be displayed in GUI using ChartPanel only.Is it possible to display in Gui using JScrollPane.
Thanks.
Thanks for your reply. It was mentioned that JfreeChart can be displayed in GUI using ChartPanel only.Is it possible to display in Gui using JScrollPane.
Thanks.
Re: whether jfreechart objects can be displayed in jscrollp
Did you try to enclose the ChartPanel in a JScrollPane yet? I don't think that it will give you an error.sudhakar wrote:It was mentioned that JfreeChart can be displayed in GUI using ChartPanel only.Is it possible to display in Gui using JScrollPane.
Re: whether jfreechart objects can be displayed in jscrollp
thanks for your reply.
Initially i set the size of the ChartPanel to the size such as width as 1000 and height as 800 and enclosed in a JScrollPane. This worked good for big charts.But for small charts also i have to scroll to view the chart. For my need the ChartPanel should be a scrollpane in which scrollbars appear based on the size of the chart. is there any JFreeChart panel which inherits JScrollPane available in JFreeCharts.
thanks.
Initially i set the size of the ChartPanel to the size such as width as 1000 and height as 800 and enclosed in a JScrollPane. This worked good for big charts.But for small charts also i have to scroll to view the chart. For my need the ChartPanel should be a scrollpane in which scrollbars appear based on the size of the chart. is there any JFreeChart panel which inherits JScrollPane available in JFreeCharts.
thanks.
This respons is based on my expereince, others can correct me if I'm off.
The chartPanel is used to decide the physical size to creat the JFreeChart in. If your chartPanel is 200 pixels by 200 pixels, then the JFreeChart will be created (with axises, legends, titles etc) within that size.
If you are making a chartPanel WITHIN a JScrollPane, then no matter the amount of data contained within that JFreeChart, it will expand to fit the chartPanel. This would explain why you ave to scroll no matter how much data is in your JFreeChart.
Possible solution (at least what we did) was to create a JScrollBar independently of JFreeChart (throw it onthe bottom of whatever is holding the chartPanel), and have its 4 values (value, extent, max, min) represent information currently viewed. ie. value = left edge of currently shown graph, extent+value = right edge of currently shown graph, and max and min = the total amount of data available. JFreeChart allows redefininf the upper and lower domain bounds of a plot. Let the user scroll, then redraw the plot based on where the scroll bar ends up.
Not perfect, but it works. And at least this explains the problem you're having.
The chartPanel is used to decide the physical size to creat the JFreeChart in. If your chartPanel is 200 pixels by 200 pixels, then the JFreeChart will be created (with axises, legends, titles etc) within that size.
If you are making a chartPanel WITHIN a JScrollPane, then no matter the amount of data contained within that JFreeChart, it will expand to fit the chartPanel. This would explain why you ave to scroll no matter how much data is in your JFreeChart.
Possible solution (at least what we did) was to create a JScrollBar independently of JFreeChart (throw it onthe bottom of whatever is holding the chartPanel), and have its 4 values (value, extent, max, min) represent information currently viewed. ie. value = left edge of currently shown graph, extent+value = right edge of currently shown graph, and max and min = the total amount of data available. JFreeChart allows redefininf the upper and lower domain bounds of a plot. Let the user scroll, then redraw the plot based on where the scroll bar ends up.
Not perfect, but it works. And at least this explains the problem you're having.
-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
When I first started work on JFreeChart, I decided that it should draw the charts at whatever size the user requested, rather than try to determine some "optimal" size that depends on how much data there is and who knows what other factors (title length and font, legend position etc), because the latter approach is ultimately very subjective.
So what you are trying to do is going "against the grain" for JFreeChart, but as long as you can code up some algorithm for determining the "optimal" chart width, then embedding the ChartPanel inside a JScrollPane is an approach that can be made to work. The alternative is to restrict the axis range as suggested by Mercer (which may be a better approach if your charts can be very large).
So what you are trying to do is going "against the grain" for JFreeChart, but as long as you can code up some algorithm for determining the "optimal" chart width, then embedding the ChartPanel inside a JScrollPane is an approach that can be made to work. The alternative is to restrict the axis range as suggested by Mercer (which may be a better approach if your charts can be very large).
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader


-
- JFreeChart Project Leader
- Posts: 11734
- Joined: Fri Mar 14, 2003 10:29 am
- antibot: No, of course not.
- Contact:
That would have been a mistake. Among other things, you need to bear in mind that JFreeChart output can be sent to a number of places, not just the screen. On the screen, scrollbars are a possibility, but they're not available on a printed page, or in a PDF file, or in a PNG image.sudhakar wrote:You have inherited Jpanel for ChartPanel.It would have been better if you would have inherited JScrollPane for ChartPanel .
I'm aware that there are use cases for charting where people would like the chart to automatically size itself using some kind of "preferred size" mechanism. JFreeChart just doesn't support that case. It approaches the problem from the other direction: here is the space available, now draw a chart in there as best you can.
David Gilbert
JFreeChart Project Leader
Read my blog
Support JFree via the Github sponsorship program
JFreeChart Project Leader

