Page 1 of 1
Make the entire chart clickable. (how?)
Posted: Mon May 15, 2006 8:30 pm
by 9090970
I am trying to add an attribute that links to a javascript onClick event, however:
myChart.Attributes.Add("onClick", "javascript:myFunc();")
does not seem to work correctly. Can anyone give me a quick overview of how I'd go about making the entire chart clickable. I'm looked through the help file, but haven't had much luck.
Thanks in advance.
Posted: Tue May 16, 2006 10:50 am
by narcis
Hi Maxeta,
If you are using TeeChart for .NET in a WebForms application you could implement your code in WebChart's ClickBackground event.
Posted: Tue May 16, 2006 12:40 pm
by 9090970
Wouldn't that require a postback? I'm actually interested in providing a popup window once the chart is clicked, without a full reload of tha page, which inturn would require a javascript call.
I was reading something about an MapAction feature in TeeChart, but I've yet to fully understand how it works for scripts. And I couldn't seem to find a decent tutorial in the help file. Can anyone give me a quick run-through.
Posted: Wed May 17, 2006 11:58 am
by narcis
Hi Maxeta,
To achieve that you'll need to edit WebChart's attributes collections doing:
Code: Select all
protected void Page_Load(object sender, EventArgs e)
{
string style = "position: relative";
string onclick = "javascript:alert('hello world')\" ";
WebChart1.Attributes.Clear();
WebChart1.Attributes.Add("onclick", onclick);
WebChart1.Attributes.Add("Style", style);
}
Posted: Wed May 17, 2006 1:08 pm
by 9090970
Thanks.
Code: Select all
string onclick = "javascript:alert('hello world')\" ";
I didn't realize that the extra literal quote was necessary at the end of the attribute. With that inplace everything seems to be working as expected.
Posted: Wed May 17, 2006 1:12 pm
by narcis
Hi Maxeta,
Yes, it is a little bit tricky but otherwise attributes are not properly added.