Is it possible to add tooltips to servlet based JFreeCharts?
If so an example of how this is done would be appreciated.
Thanks.
ToolTips & Servlets...
Re: ToolTips & Servlets...
Fergus
I am working on this. Have sent DG some code based upon his imagemap. Still have some improvements to make in the next week before (ie make imagemap have html title (ie enabling tooltips) and make href optional).
An example of my current work is available at
http://coyote.aad.gov.au/JFreeServlet/example2.html
Note
a. I am still working on it and am restarting the tomcat server quite a bit at times
b. tooltips are not active yet, only href
It would be great for you to have a look at the example and post any suggestions, you have.
Bryan
I am working on this. Have sent DG some code based upon his imagemap. Still have some improvements to make in the next week before (ie make imagemap have html title (ie enabling tooltips) and make href optional).
An example of my current work is available at
http://coyote.aad.gov.au/JFreeServlet/example2.html
Note
a. I am still working on it and am restarting the tomcat server quite a bit at times
b. tooltips are not active yet, only href
It would be great for you to have a look at the example and post any suggestions, you have.
Bryan
Re: ToolTips & Servlets...
Bryan,
Are you still working on this? I have made some modifications of my own to
show tooltips on XY graphs (alt attributes on the image map), however
they are not sufficiently generic yet (don't handle hrefs or other graph
types). In my current application I do not require any hrefs, however I
think the current solution is far from ideal. I would prefer for hrefs to be
handled in a similar way to tooltips through an interface, then it would be
possible to generate completely custom URLs without any assumptions
about the format.
I have also made a modification to separate the creation of a BufferedImage
from writing the image to an OutputStream. In a JSP/servlet environment
it is useful to create the BufferedImage to allow the production of the
image map in one page, and then save the BufferedImage to a session
variable and have it written to the servlet response OutputStream from
another page (HTTP request). This saves persisting the image to disk and
reading it back again.
Please let me know your thoughts on the matter. I can post the code /
examples if it would be helpful.
Thanks,
Richard...
Are you still working on this? I have made some modifications of my own to
show tooltips on XY graphs (alt attributes on the image map), however
they are not sufficiently generic yet (don't handle hrefs or other graph
types). In my current application I do not require any hrefs, however I
think the current solution is far from ideal. I would prefer for hrefs to be
handled in a similar way to tooltips through an interface, then it would be
possible to generate completely custom URLs without any assumptions
about the format.
I have also made a modification to separate the creation of a BufferedImage
from writing the image to an OutputStream. In a JSP/servlet environment
it is useful to create the BufferedImage to allow the production of the
image map in one page, and then save the BufferedImage to a session
variable and have it written to the servlet response OutputStream from
another page (HTTP request). This saves persisting the image to disk and
reading it back again.
Please let me know your thoughts on the matter. I can post the code /
examples if it would be helpful.
Thanks,
Richard...
Re: ToolTips & Servlets...
Richard
Been away on holidays. Yep always interested in looking at code.
No sure about the BufferedImage solution. Need to read a bit more about how servlet containers (tomcat) handle these. Of concern is high hit rate? But again not sure.
Bryan
Been away on holidays. Yep always interested in looking at code.
No sure about the BufferedImage solution. Need to read a bit more about how servlet containers (tomcat) handle these. Of concern is high hit rate? But again not sure.
Bryan
Re: ToolTips & Servlets...
Bryan,
I have finished making the modifications now to handle fully customizable tooltips and hrefs for HTML image maps for all the chart types. The code is available at
http://homepage.ntlworld.com/richard_c_ ... freechart/
I'm intending to check this into CVS in the near future but have had trouble finding the time so far.
The current JFreeChart methods to write the chart image to disk all involve creating a BufferedImage and then encoding it into the appropriate format and writing it to disk. By breaking out the creation of the BufferedImage it is possible to have one servlet/JSP create the BufferedImage, write out the HTML image map and store the BufferedImage in the session. Another servlet/JSP can then retrieve the BufferedImage from the session, write it out to the servlet response OutputStream and then remove the BufferedImage from the session.
The advantages of doing it this way are that the image does not have to be written to disk or created twice (once to produce the image map and once to stream the image back to the browser). The overhead is that the BufferedImage stays in the memory between the two HTTP requests, but that would normally be a very short amount of time indeed as the browser would request the image as soon as it had processed the first response. So I think the advantages out-weigh the temporary memory overhead.
Any feedback would be appreciated.
Thanks and regards,
Richard...
I have finished making the modifications now to handle fully customizable tooltips and hrefs for HTML image maps for all the chart types. The code is available at
http://homepage.ntlworld.com/richard_c_ ... freechart/
I'm intending to check this into CVS in the near future but have had trouble finding the time so far.
The current JFreeChart methods to write the chart image to disk all involve creating a BufferedImage and then encoding it into the appropriate format and writing it to disk. By breaking out the creation of the BufferedImage it is possible to have one servlet/JSP create the BufferedImage, write out the HTML image map and store the BufferedImage in the session. Another servlet/JSP can then retrieve the BufferedImage from the session, write it out to the servlet response OutputStream and then remove the BufferedImage from the session.
The advantages of doing it this way are that the image does not have to be written to disk or created twice (once to produce the image map and once to stream the image back to the browser). The overhead is that the BufferedImage stays in the memory between the two HTTP requests, but that would normally be a very short amount of time indeed as the browser would request the image as soon as it had processed the first response. So I think the advantages out-weigh the temporary memory overhead.
Any feedback would be appreciated.
Thanks and regards,
Richard...
Re: ToolTips & Servlets...
Richard
Understanding of your time issues.
Understand what you are saying about bufferedimage. A thought, would be to allow the end user to choose what type of buffering they would prefer. Might when I get time mod to allow the choice.
Bryan
Understanding of your time issues.
Understand what you are saying about bufferedimage. A thought, would be to allow the end user to choose what type of buffering they would prefer. Might when I get time mod to allow the choice.
Bryan
Re: ToolTips & Servlets...
Bryan,
The changes that I've made to the API don't imply the enforcing of any particularly method on developers. I have just split the creation of the BufferedImage out from writing the chart either to a file or to an OutputStream. The writeChartAs????() methods and saveChartAs????() methods in ChartUtilities are still all there. I have just added two additional methods writeBufferedImageAs????() methods.
Everyone still has the choice to use the API in any way they want. Another possibility might be writing the images to disk, returning hrefs to the images on disk and adding a HttpSessionBindingListener to delete the images when the users session expires. That may be attractive to many developers because it is in many ways simpler than caching the BufferedImage in the session. However if the web server is running on a different machine to the servlet engine then it is not such a practical solution.
By defining a flexible API it leaves all the options open and people can choose the method they prefer. I'm sure some additional documentation and implementation examples would help a lot, but unfortunately it comes back to the issue of finding the time.
Regards,
Richard...
The changes that I've made to the API don't imply the enforcing of any particularly method on developers. I have just split the creation of the BufferedImage out from writing the chart either to a file or to an OutputStream. The writeChartAs????() methods and saveChartAs????() methods in ChartUtilities are still all there. I have just added two additional methods writeBufferedImageAs????() methods.
Everyone still has the choice to use the API in any way they want. Another possibility might be writing the images to disk, returning hrefs to the images on disk and adding a HttpSessionBindingListener to delete the images when the users session expires. That may be attractive to many developers because it is in many ways simpler than caching the BufferedImage in the session. However if the web server is running on a different machine to the servlet engine then it is not such a practical solution.
By defining a flexible API it leaves all the options open and people can choose the method they prefer. I'm sure some additional documentation and implementation examples would help a lot, but unfortunately it comes back to the issue of finding the time.
Regards,
Richard...