|
Clickable curve in ChartDirector using Javascript does not work |
Posted by Stefan on Oct-04-2012 15:03 |
|
Hi Peter,
I am currently extending my application to click some data in my curve. I used the example from your documentation in "Custom Clickable Objects" of ChartDir 5.1 .
This example works fine, but I need to run Jajascript on a click on the curve and not open a new Webpage like in the example, see here what I tried:
WebUserControl1.ascx.cs:
...
// Include tool tip for the chart
// Working fine here !
//string chartImageMap = c.getHTMLImageMap("WebForm1.aspx", "",
// "title='[{dataSetName}] {x|mmm dd, yyyy}: USD {value|2}'");
// THIS DOES NOT WORK HERE BUT FOR LEGEND LATER IT IS OK.
string chartImageMap = c.getHTMLImageMap("javascript:popMsg('the curve [{dataSetName}]');", "",
"title='[{dataSetName}] {x|mmm dd, yyyy}: USD {value|2}'");
// Create an image map for the legend box -> works fine here !
string legendImageMap = legendBox.getHTMLImageMap(
"javascript:popMsg('the legend key [{dataSetName}]');", " ",
"title='This legend key is clickable!'");
viewer.ImageMap = chartImageMap + legendImageMap;
...
WebUserControl1.ascx:
...
function popMsg(msg) {
alert("You have clicked on " + msg + ".");
}
...
I always get a syntax error when clicking on the curve, clicking the legend is working.
How can I start a Javascript for clicking the curve instead of a new WebPage ?
BR
Stefan |
Re: Clickable curve in ChartDirector using Javascript does not work |
Posted by Peter Kwan on Oct-05-2012 03:29 |
|
Hi Stefan,
I suspect the error is caused by the second parameter to getHTMLImageMap, which is "" (an empty string) in your code. Please change it to " " (a string containing a space character), just like the code you use in the legend box image map.
If you use "" as the second parameter, ChartDirector will assume it refers to the default query parameters. As your URL is actually Javascript, appending query parameters to it will result in illegal Javascript code, and hence the error. On the other hand, appending a space character to it should be fine.
Hope this can help.
Regards
Peter Kwan |
Re: Clickable curve in ChartDirector using Javascript does not work |
Posted by Stefan on Oct-05-2012 15:13 |
|
Hi Peter,
Thanks for the help.
One small invisible character (like " ") and such a big effect really helps.
It works fine now.
BR
Stefan |
|