Dear Sir
How to call my javascript function when the web chart series has been click. for example,
function seriesIsClick(){
alert('is click');
}
e.PointPolygon.HREF="seriesIsClick();"; ---> not working...
Thank
Yong
How to call javascript when web chart series has been click
-
- Site Admin
- Posts: 1349
- Joined: Thu Jan 01, 1970 12:00 am
- Location: Riudellots de la Selva, Catalonia
- Contact:
Hello,
Yes, this is possible as the example below shows:
Yes, this is possible as the example below shows:
Code: Select all
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Text;
using Steema.TeeChart.Web;
using Steema.TeeChart.Styles;
using Steema.TeeChart;
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
// ****************************************************
// The data load code for WebChart1 demostrates a technique to save
// data between page calls. The Chart is saved as a TeeChart template
// to a session variable.
// ****************************************************
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language='javascript'>");
sb.Append("function seriesIsClick(){");
sb.Append(" alert('is click');");
sb.Append("}");
sb.Append("</script>");
Type t = this.GetType();
if (!ClientScript.IsClientScriptBlockRegistered(t, "PopupScript"))
ClientScript.RegisterClientScriptBlock(t, "PopupScript", sb.ToString());
Steema.TeeChart.Chart ch1 = WebChart1.Chart;
MemoryStream tmpChart = new MemoryStream();
if (Session["ch1"] == null)
{
//setup Chart
if (ch1.Series.Count < 1)
{
ch1.Series.Add(new Steema.TeeChart.Styles.Points());
}
if (ch1.Tools.Count < 1)
{
ch1.Tools.Add(new Steema.TeeChart.Tools.ZoomTool());
ch1.Tools.Add(new Steema.TeeChart.Tools.SeriesHotspot());
}
((Steema.TeeChart.Tools.ZoomTool)ch1.Tools[0]).ZoomPenColor = Color.OliveDrab;
((Steema.TeeChart.Tools.SeriesHotspot)ch1.Tools[1]).Style = MarksStyles.LabelPercentTotal;
((Steema.TeeChart.Tools.SeriesHotspot)ch1.Tools[1]).GetHTMLMap += new Steema.TeeChart.Tools.SeriesHotspotEventHandler(_Default_GetHTMLMap);
((Steema.TeeChart.Tools.SeriesHotspot)ch1.Tools[1]).MapAction = MapAction.Script;
((Steema.TeeChart.Tools.SeriesHotspot)ch1.Tools[1]).HelperScript = Steema.TeeChart.Tools.HotspotHelperScripts.Annotation;
ch1.Series[0].Color = Color.FromArgb(255, 199, 26);
ch1.Series[0].FillSampleValues(36);
ch1.Export.Template.Save(tmpChart);
//save template to a Session variable
Session.Add("ch1", tmpChart);
}
else
{
//retrieve the session stored Chart
tmpChart = (MemoryStream)Session["ch1"];
//set the Stream position to 0 as the last read/write
//will have moved the position to the end of the stream
tmpChart.Position = 0;
//import saved Chart
WebChart1.Chart.Import.Template.Load(tmpChart);
//check whether zoom request is being sent
CheckZoom(WebChart1);
}
}
void _Default_GetHTMLMap(Steema.TeeChart.Tools.SeriesHotspot sender, Steema.TeeChart.Tools.SeriesHotspotEventArgs e)
{
e.PointPolygon.Attributes = "onmouseover=\"seriesIsClick();\"";
}
private void CheckZoom(WebChart wChart)
{
ArrayList zoomedState = (ArrayList)Session[wChart.ID + "Zoomed"];
zoomedState = ((Steema.TeeChart.Tools.ZoomTool)wChart.Chart.Tools[0]).SetCurrentZoom(Request,
zoomedState);
if (zoomedState == null)
Session.Remove(wChart.ID + "Zoomed");
else
Session.Add(wChart.ID + "Zoomed", zoomedState);
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
}
Thank you!
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/
Christopher Ireland (Steema crew)
Please be aware of the newsgroup archives:
http://www.teechart.net/support/search.php
http://groups.google.com
http://codenewsfast.com/