two charts with two image maps in a single jsp page

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
jfreeuser2006
Posts: 59
Joined: Mon Nov 20, 2006 1:00 pm

two charts with two image maps in a single jsp page

Post by jfreeuser2006 » Fri Jan 26, 2007 8:59 am

Hi all

i was wondering if anybody can help me out.

how can i show two images with their respective image maps in one page so that both could have tooltips and drill down capabilities?

right now i can only show 1 chart with an image map per page.

a sample code would be great.

thanks in advance.

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Post by angel » Fri Jan 26, 2007 9:26 am

Something like that

Code: Select all

        ChartRenderingInfo cri = new ChartRenderingInfo();
        String filename1 = "";
        try {
            filename1 = ServletUtilities.saveChartAsPNG(chart1, 790, 430, cri, null);
        } catch (IOException ex) {
            logger.error(ex);
            throw new RuntimeException(ex.getMessage());
        }
        String map1=ChartUtilities.getImageMap("imagemap1", cri);


        String filename2 = "";
        try {
            filename2 = ServletUtilities.saveChartAsPNG(chart2, 790, 430, cri, null);
        } catch (IOException ex) {
            logger.error(ex);
            throw new RuntimeException(ex.getMessage());
        }
        String map2=ChartUtilities.getImageMap("imagemap2", cri);
%>

<%=map1%>
<%=map2%>
<img src="<%=DisplayChart.class.getName()%>?filename=<%=filename1 %> "usemap="#imagemap1">
<img src="<%=DisplayChart.class.getName()%>?filename=<%=filename2 %> "usemap="#imagemap2">

jfreeuser2006
Posts: 59
Joined: Mon Nov 20, 2006 1:00 pm

Post by jfreeuser2006 » Mon Jan 29, 2007 5:21 am

Hi angel,

I was able to show the two charts each with its own imagemap and tooltips.

Thanks you very much. :-)

I have a new question regarding JFreeChart's TextTitle. I've run into a a dead end. I am able to add subtitles to the chart. However I could not format the text. Since TextTitle ignores \t and \u0009 the escape character for tabs.

What I intend to do is have the subtitles have this format:

Code: Select all

     Line 1        20.0
     Line 2        15
     Line 3        3
What I have now is:

Code: Select all

     Line 1 20.0
     Line 2 15
     Line 3 3
I am told that I should subclass Title but i don't know exactly how to do it.
I tried to subclass it but the error that shows is that Title is abstract and that i could not subclass it.

What I did was:

Code: Select all

chart.addSubtitle(new TextTitle(new Title() {
     public void draw(Graphics2D graphics2D, Rectangle2D rectangle2D) {
     }
});

Can you please show me how to properly subclass it so that it recognized the tabs?

Jaypee

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Post by angel » Mon Jan 29, 2007 8:38 am

Sorry, I can't help you with the titel-stuff.

jfreeuser2006
Posts: 59
Joined: Mon Nov 20, 2006 1:00 pm

Post by jfreeuser2006 » Mon Jan 29, 2007 2:00 pm

Thanks for the reply. I'll try to work it out.

I'll post the solution as soon as I solve it.

jfreeuser2006
Posts: 59
Joined: Mon Nov 20, 2006 1:00 pm

DisplayChart Servlet

Post by jfreeuser2006 » Tue Jan 30, 2007 9:04 am

Hi,

I'm able to chart two charts with their tooltips my prob is that the png files in temp directory don't get deleted.

I was going over the forums and i read that i should place DisplayChart servlet in the web.xml

Can anybody show me how to properly do it?

Thanks

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Post by angel » Tue Jan 30, 2007 11:13 am


Locked