SVG - Action with javascript

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
sebastien32
Posts: 4
Joined: Tue Oct 06, 2009 10:48 am
antibot: No, of course not.

SVG - Action with javascript

Post by sebastien32 » Tue Oct 06, 2009 10:59 am

Hi,

I use JFreeChart (and batik) for generate a SVG, that I include into a html page.
I need to use javascript for hide a serie, but my problem is the id of SVG'elements, who are not really useable.

Has anyone a method for overwrite this id with JFreeChart objects ?

Thanks for any help !

Sébastien

jleech
Posts: 62
Joined: Fri Oct 26, 2007 9:18 pm

Re: SVG - Action with javascript

Post by jleech » Tue Oct 06, 2009 8:25 pm

Hi Sébastien,

You should take a look at the paper I just presented at the SVG Open 2009 where I added javascript interactivity etc. to JFreeChart / Batik / SVG. I didn't set the id of any elements, but you should be able to do so using the AttributePaint class that I developed.

-Jonathan

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

Re: SVG - Action with javascript

Post by david.gilbert » Tue Oct 06, 2009 9:18 pm

Very cool. If you are looking for the URL, scan this list for "Leech, Jonathan":

http://www.svgopen.org/2009/registratio ... e_speakers
David Gilbert
JFreeChart Project Leader

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

jleech
Posts: 62
Joined: Fri Oct 26, 2007 9:18 pm

Re: SVG - Action with javascript

Post by jleech » Tue Oct 06, 2009 9:25 pm

Whoops - meant to post the URL! http://www.svgopen.org/2009/registratio ... gs#paper_7 - The paper is entitled "Enhancing Server-Side SVG Generation using the Batik Extension Handler Mechanism" and the links to the abstract, paper, and presentation should appear at the top of the browser.

sebastien32
Posts: 4
Joined: Tue Oct 06, 2009 10:48 am
antibot: No, of course not.

Re: SVG - Action with javascript

Post by sebastien32 » Wed Oct 07, 2009 10:46 am

Hi David, Jonathan,

Thank you for those responses. That seems very well ! :D
I try your approach immediatly.

Sébastien

sebastien32
Posts: 4
Joined: Tue Oct 06, 2009 10:48 am
antibot: No, of course not.

Re: SVG - Action with javascript

Post by sebastien32 » Wed Oct 07, 2009 4:36 pm

Jonathan,

For me, the pattern class work fine, but AttibutePaint or TooltipPaint classes does not.
The element added doesn't appear into the svgfile generated.

This code works fine :

Code: Select all

Paint p = SVGPatternTexturePaint.createStarPaint(14,Color.getHSBColor((float)Math.random()*255, (float)Math.random()*255, (float)Math.random()*255), Color.WHITE);
stackedbarrenderer.setSeriesPaint(i, p);
This doesn't :

Code: Select all

Paint pt = new TooltipPaint("ToolTip : ", "test");
stackedbarrenderer.setSeriesPaint(i, pt);
I generate SVG file with this code (that works for apply a pattern) :

Code: Select all

SVGGraphics2D svgGenerator = SVGPatternTexturePaint.getSVGGraphics2D();
I don't know where is my mistake ! Can you help me, again ?

sebastien32
Posts: 4
Joined: Tue Oct 06, 2009 10:48 am
antibot: No, of course not.

Re: SVG - Action with javascript

Post by sebastien32 » Wed Oct 07, 2009 4:47 pm

I am solving my problem :

Code: Select all

SVGGraphics2D svgGenerator = new ExtensionSVGGraphics2D();
What more easy ?! :oops:

Now, informations are generated into svg file but the tooltips doesn't appear on the SVG with IE :roll:

So, if you can help me ...
Thanks,

Sébastien

jleech
Posts: 62
Joined: Fri Oct 26, 2007 9:18 pm

Re: SVG - Action with javascript

Post by jleech » Wed Oct 07, 2009 9:09 pm

Hi Sébastien,

Which SVG viewer are you using in IE? Adobe SVG viewer? Do the tooltips work for you in another browser - Firefox, Chrome etc?
You probably need to include tooltip.js into the SVG output - The extension doesn't do it for you.
Some browsers will do tooltips without the extra help - Opera will do a tooltip with just the "title" attribute, the Batik squiggle browser will provide a tooltip with both "title" and desc.
Also, not sure if you realized or not, you can combine multiple paints using the provided CompositePaint class.

Thanks for being the first user! Your feedback is appreciated.

-Jonathan

backstage
Posts: 1
Joined: Tue Dec 31, 2019 10:33 am
antibot: No, of course not.

Re: SVG - Action with javascript

Post by backstage » Fri Jan 10, 2020 11:32 am

Sorry for resuming an old thread. I have tried the same thing, i.e. adding tooltip to a SVG pie chart, but it doesn't work. I think I'm missing something. Until now I have set custom colors for the sections, in this way:

Code: Select all

pie.setSectionPaint(k,colors[i]);
Now, if I replace this code and I add the tooltipPaint, the color is not set any more!

Code: Select all

pie.setSectionPaint(k,new cTooltipPaint("test", "desc"));
So, how to have both?

Locked