tooltip and drill down chart in SVG

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
meodows92
Posts: 4
Joined: Sun Dec 14, 2014 2:55 am
antibot: No, of course not.

tooltip and drill down chart in SVG

Post by meodows92 » Tue Dec 16, 2014 2:32 am

Hi everyone, i am new here and also i am new to jfreesvg to make chart, hope the community will guide me and give more sample codes here because i am on the rush for the dead line for a project. I am doing a web application for using their data. What does this system do is to take their raw data and do some counting and display to the user, this is where user query the certain period and it will display the chart it accordingly. But on my previous post on the tooltip image map problem which one it's being resize the image map will be out of position, so there is a person suggest me to use SVG. But i have no ideal how to start even do my drill down chart. Will your help me by posting some drill down samples for the Servlet side and the JSP side. For the post i just mention is this link: http://www.jfree.org/phpBB2/viewtopic.php?f=3&t=117128 if your could help me on that issue i will be very glade too. Hope could receive your reply and thanks for reading.

meodows92
Posts: 4
Joined: Sun Dec 14, 2014 2:55 am
antibot: No, of course not.

Re: tooltip and drill down chart in SVG

Post by meodows92 » Wed Dec 17, 2014 3:31 am

hi has anyone can give me an answer?

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: tooltip and drill down chart in SVG

Post by david.gilbert » Thu Dec 18, 2014 9:39 pm

I don't have any good example in JFreeChart, because the code isn't finished. A number of renderers have been updated in SVN so you would have to get the code direct from the repo.

The general approach is described for Orson Charts (more or less JFreeChart3D but not free):

http://www.object-refinery.com/blog/blog-20140509.html

It works the same for JFreeChart, or will once the next release is done (I don't know when that will be).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

essday
Posts: 5
Joined: Mon Dec 15, 2014 7:50 pm
antibot: No, of course not.

Re: tooltip and drill down chart in SVG

Post by essday » Wed Dec 24, 2014 3:43 pm

Meodows92, I've been working on something similar using the 1.0.20 top-of-tree code. You may want to follow this post for updates.

However, even without switching to SVG, the image map resizing problem is not intractable. When writing out the <img> tag, we add a "data-original-(height/width)" attribute to record the original size of the image. We then attach a resize handler to the window, and whenever we get a (debounced!) resize event, we resize the coordinates in all of the elements in the image map. The following code works at least for "rect" areas (ie. for bar charts and such).

Code: Select all

    resizeImageMap: function() {
        jQuery('.chartDataViewImage').each(function(idx, chartDiv) {
            var $chartDiv = jQuery(chartDiv);
            var $img = $chartDiv.find('img');
            var $map = $chartDiv.find('map');

            var origHeight = $img.attr('data-original-height');
            var origWidth = $img.attr('data-original-width');

            var heightScale = $img.height() / origHeight;
            var widthScale = $img.width() / origWidth;

            if (typeof $map.attr('data-current-scale-width') === 'undefined') {
                $map.attr('data-current-scale-width', 1);
            }

            if (typeof $map.attr('data-current-scale-height') === 'undefined') {
                $map.attr('data-current-scale-height', 1);
            }

            // If the scale has changed since we last looped through
            // the map, go fix the offsets now.

            if (widthScale != $map.attr('data-current-scale-width') ||
                heightScale != $map.attr('data-current-scale-height')) {

                $map.attr('data-current-scale-width', widthScale);
                $map.attr('data-current-scale-height', heightScale);

                $map.find("area[shape='rect']").each(function(idx, area) {
                    var $area = jQuery(area);

                    var origCoords = $area.attr('data-original-coords');

                    if (typeof origCoords==='undefined') {
                        origCoords = $area.attr('coords');
                        $area.attr('data-original-coords', origCoords);
                    }

                    var coords = origCoords.split(','); // left, top, right, bottom
                    coords[0] *= widthScale;
                    coords[1] *= heightScale;
                    coords[2] *= widthScale;
                    coords[3] *= heightScale;
                    $area.attr('coords', coords.join(','));
                });
            }
        });
    },

Locked