|
Showing a thumbnail image in a tooptip |
Posted by Stefan Ohlsson on Aug-20-2012 20:57 |
|
Hello,
We bought your graph engine and it works great. Thank you.
Now to my question.
I have this code to present a tooltip:
viewer.setImageMap(viewer.getChart().getHTMLImageMap("clickable", "surveyName={field0}&diarieNo={field1}&numberOfElements={field2}&x={x}&y={value}&z={z}",
"title='{field0} :: {field1}, y={value}%'"));
The result is image1.png See attached image.
Now I would like to have an image inside the tooltip with the text. The code i wrote you see below.
viewer.setImageMap(viewer.getChart().getHTMLImageMap("clickable", "surveyName={field0}&diarieNo={field1}&numberOfElements={field2}&x={x}&y={value}&z={z}",
"title='<html>{field0} :: {field1}, y={value}%
<img src='http://www.rampanel.com/image/2012_5/MNO_AP_300112_annonse1.JPG'> </html>'"));
The result is image2.png (as you can see it looks like it contains a broken link, but if you copy the url in your webbrowser you will see the image)
Could you please tell me if this works and what im doing wrong? The chartdirector is used inside an java applet to produce tooltips on barcharts. But i want to load both an thumbnail image and text inside the tooltip.
|
Re: Showing a thumbnail image in a tooptip |
Posted by Peter Kwan on Aug-21-2012 01:53 |
|
Hi Stefan,
May be it is caused by using single quotes. The title attribute is already using single quotes, like:
title=' ...... '
If the content inside the title is also single quoted, it may cause issues. May be you can try to use double quotes to see if this can solve the problem:
<img src=\\"http://www.rampanel.com/image/2012_5/MNO_AP_300112_annonse1.JPG\\">
Regards
Peter Kwan |
Re: Showing a thumbnail image in a tooptip |
Posted by Stefan Ohlsson on Aug-21-2012 18:35 |
|
Hello Peter,
i tried that and everything else. It still doesnt work.
Is there any way to solve this? It seems html doesnt itself allow me to add an image inside a tooltip.
Best regards
/Stefan |
Re: Showing a thumbnail image in a tooptip |
Posted by Peter Kwan on Aug-22-2012 22:40 |
|
Hi Stefan,
I have just tried the applet code below, and it works normally in my case. The tooltip will contain the image so long as the URL is for the same directory that loads the Applet.
If the URL is from a different path (say from "www.advsofteng.com", then the Java console will show "java.security.AccessControlException: access denied (java.net.SocketPermission www.advsofteng.com resolve)". So apparently an applet can only load things from the same directory as the applet due to security reasons.
May be you can try the code below to see if it works in your case. You may use the Java console of the browser to determine if there is any error.
//====================================================
import ChartDirector.*;
import javax.swing.*;
public class ChartDirectorApplet extends JApplet
{
//Main code for creating charts
public void createChart(ChartViewer viewer, int index)
{
// The data for the bar chart
double[] data = {85, 156, 179.5, 211, 123};
// The labels for the bar chart
String[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};
// Create a XYChart object of size 250 x 250 pixels
XYChart c = new XYChart(250, 250);
// Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(30, 20, 200, 200);
// Add a bar chart layer using the given data
c.addBarLayer(data);
// Set the labels on the x axis.
c.xAxis().setLabels(labels);
// Output the chart
viewer.setImage(c.makeImage());
//include tool tip for the chart
viewer.setImageMap(c.getHTMLImageMap("clickable", "",
"title='<html>{value}<br><img src=\\"http://192.168.1.131/testimage.jpg\\"></html>'"));
}
public void init()
{
try
{
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
}});
}
catch (Exception e)
{
System.err.println("createGUI didn't successfully complete : " + e.toString());
e.printStackTrace();
}
}
private void createGUI()
{
ChartViewer viewer = new ChartViewer();
createChart(viewer, 0);
setSize(viewer.getImage().getWidth(null), viewer.getImage().getHeight(null));
getContentPane().add(viewer);
}
}
//====================================================
Regards
Peter Kwan |
Re: Showing a thumbnail image in a tooptip |
Posted by Stefan Ohlsson on Aug-23-2012 13:45 |
|
Hi Peter,
thank you very much for taking your time and writing good and detailed answers.
Best regards
/Stefan |
|