You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Olivier Terral <ol...@geomatys.fr> on 2009/01/27 15:45:56 UTC

jFreeChart + batik + Javascript

Hi all,

I 've transformed a JFreeChart in  SVG with Batik without problem but I need
to add some javascript events (onmousover, onmouseout ..)  on SVG elements
to make the Chart more dynamic and beautiful.

The problem is the SVG generated by Batik has no informations (ids or
attributes) about which part of the graph he refere .

Is it possible to add some ids  when the SVG is generated ? 
or does it exist a mapping or something like that to find which SVG elements 
corresponding to which part of the graph? 
 

Thanks in advance

-- 
View this message in context: http://www.nabble.com/jFreeChart-%2B-batik-%2B-Javascript-tp21686678p21686678.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: jFreeChart + batik + Javascript

Posted by Olivier Terral <ol...@geomatys.fr>.
Totally agree with you helder, and I've already ask on their forum but no
answer  that's why I ask to batik user.




Helder Magalhães wrote:
> 
>> Is it possible to add some ids  when the SVG is generated ?
>> or does it exist a mapping or something like that to find which SVG
>> elements
>> corresponding to which part of the graph?
> 
> It looks like this is more related to the JFreeChart project itself.
> I'm sure you may get a lot more interesting feedback by searching
> through the forum [1] and, if nothing found, ask there. ;-)
> 
> Hope this helps,
> 
>  Helder Magalhães
> 
> [1] http://www.jfree.org/jfreechart/support.html
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/jFreeChart-%2B-batik-%2B-Javascript-tp21686678p21707927.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: jFreeChart + batik + Javascript

Posted by Helder Magalhães <he...@gmail.com>.
> Is it possible to add some ids  when the SVG is generated ?
> or does it exist a mapping or something like that to find which SVG elements
> corresponding to which part of the graph?

It looks like this is more related to the JFreeChart project itself.
I'm sure you may get a lot more interesting feedback by searching
through the forum [1] and, if nothing found, ask there. ;-)

Hope this helps,

 Helder Magalhães

[1] http://www.jfree.org/jfreechart/support.html

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: jFreeChart + batik + Javascript

Posted by Olivier Terral <ol...@geomatys.fr>.
In fact no , because in this function :

chartBean.getChart().draw(svgGenerator,	new Rectangle2D.Double(0, 0,
chartBean.getWidth(), chartBean.getHeight()), null);

The chart is transform to a classic Graphics2D 

and it's in the .stream() function that the Graphics2d is transform to
litteral SVG, am I right? 




Olivier Terral wrote:
> 
> here my piece of code, :
> 
> public static void writeChart(ChartBean chartBean, Writer pw) throws
> Exception {
> 		if (chartBean.getChart() != null) {
> 			DOMImplementation domImpl = GenericDOMImplementation
> 					.getDOMImplementation();
> 			Document document = domImpl.createDocument(null, "svg", null);
> 			SVGGraphics2D svgGenerator = new SVGGraphics2D(document);
> 
> 			chartBean.getChart().draw(svgGenerator,	new Rectangle2D.Double(0, 0,
> chartBean.getWidth(), chartBean.getHeight()), null);
> 
> 			svgGenerator.stream(pw, false);
> 		}
> 	}
> 
> As you see the chart is draw with a svgGenerator in parameter so I've no
> power to know or to modify the creation of SVG Elements in the function
> draw().
> 
> So I think you're right I need to modify the JFreechart source code to
> generate my own SVG like I want.
> and it's exactly what I don't want to do :D
> 
> Thanks to try to help me 
> 
> Bye
> 
>  
>  
> 
> 
> thomas.deweese wrote:
>> 
>> Hi Olivier,
>> 
>> Olivier Terral <ol...@geomatys.fr> wrote on 01/27/2009 09:45:56 
>> AM:
>> 
>>> I 've transformed a JFreeChart in  SVG with Batik without problem but I 
>> need
>>> to add some javascript events (onmousover, onmouseout ..)  on SVG 
>> elements
>>> to make the Chart more dynamic and beautiful.
>>> 
>>> The problem is the SVG generated by Batik has no informations (ids or
>>> attributes) about which part of the graph he refere .
>>> 
>>> Is it possible to add some ids  when the SVG is generated ? 
>> 
>>    At any point you can get the current contents of the SVG generator
>> by calling 'getRoot'.  So if you can insert code into the drawing
>> process for JFreeChart you can call getRoot before and after each
>> important 'piece' of the graph.  You can then set an ID attribute on
>> the returned element and append that subtree to your own document.
>> 
>>    Note that getRoot clears the current contents of the Graphics2D.
>> Also you may find that it's best to call getRoot with your own
>> 'container' SVG Element (like an SVG 'g' (group) element).
>> 
>>> or does it exist a mapping or something like that to find which SVG 
>> elements 
>>> corresponding to which part of the graph? 
>> 
>>    I think the above is your best bet.
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/jFreeChart-%2B-batik-%2B-Javascript-tp21686678p21708935.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: jFreeChart + batik + Javascript

Posted by Olivier Terral <ol...@geomatys.fr>.
here my piece of code, :

public static void writeChart(ChartBean chartBean, Writer pw) throws
Exception {
		if (chartBean.getChart() != null) {
			DOMImplementation domImpl = GenericDOMImplementation
					.getDOMImplementation();
			Document document = domImpl.createDocument(null, "svg", null);
			SVGGraphics2D svgGenerator = new SVGGraphics2D(document);

			chartBean.getChart().draw(svgGenerator,	new Rectangle2D.Double(0, 0,
chartBean.getWidth(), chartBean.getHeight()), null);

			svgGenerator.stream(pw, false);
		}
	}

As you see the chart is draw with a svgGenerator in parameter so I've no
power to know or to modify the creation of SVG Elements in the function
draw().

So I think you're right I need to modify the JFreechart source code to
generate my own SVG like I want.
and it's exactly what I don't want to do :D

Thanks to try to help me 

Bye

 
 


thomas.deweese wrote:
> 
> Hi Olivier,
> 
> Olivier Terral <ol...@geomatys.fr> wrote on 01/27/2009 09:45:56 
> AM:
> 
>> I 've transformed a JFreeChart in  SVG with Batik without problem but I 
> need
>> to add some javascript events (onmousover, onmouseout ..)  on SVG 
> elements
>> to make the Chart more dynamic and beautiful.
>> 
>> The problem is the SVG generated by Batik has no informations (ids or
>> attributes) about which part of the graph he refere .
>> 
>> Is it possible to add some ids  when the SVG is generated ? 
> 
>    At any point you can get the current contents of the SVG generator
> by calling 'getRoot'.  So if you can insert code into the drawing
> process for JFreeChart you can call getRoot before and after each
> important 'piece' of the graph.  You can then set an ID attribute on
> the returned element and append that subtree to your own document.
> 
>    Note that getRoot clears the current contents of the Graphics2D.
> Also you may find that it's best to call getRoot with your own
> 'container' SVG Element (like an SVG 'g' (group) element).
> 
>> or does it exist a mapping or something like that to find which SVG 
> elements 
>> corresponding to which part of the graph? 
> 
>    I think the above is your best bet.
> 
> 

-- 
View this message in context: http://www.nabble.com/jFreeChart-%2B-batik-%2B-Javascript-tp21686678p21708368.html
Sent from the Batik - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org


Re: jFreeChart + batik + Javascript

Posted by th...@kodak.com.
Hi Olivier,

Olivier Terral <ol...@geomatys.fr> wrote on 01/27/2009 09:45:56 
AM:

> I 've transformed a JFreeChart in  SVG with Batik without problem but I 
need
> to add some javascript events (onmousover, onmouseout ..)  on SVG 
elements
> to make the Chart more dynamic and beautiful.
> 
> The problem is the SVG generated by Batik has no informations (ids or
> attributes) about which part of the graph he refere .
> 
> Is it possible to add some ids  when the SVG is generated ? 

   At any point you can get the current contents of the SVG generator
by calling 'getRoot'.  So if you can insert code into the drawing
process for JFreeChart you can call getRoot before and after each
important 'piece' of the graph.  You can then set an ID attribute on
the returned element and append that subtree to your own document.

   Note that getRoot clears the current contents of the Graphics2D.
Also you may find that it's best to call getRoot with your own
'container' SVG Element (like an SVG 'g' (group) element).

> or does it exist a mapping or something like that to find which SVG 
elements 
> corresponding to which part of the graph? 

   I think the above is your best bet.