Click Series Event Not Getting triggerred for WebChart

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
venus
Newbie
Newbie
Posts: 8
Joined: Fri Jan 27, 2012 12:00 am

Click Series Event Not Getting triggerred for WebChart

Post by venus » Tue Feb 21, 2012 11:39 am

Hi,

I am using FastLine HighSpeed Chart for Trending. The Click Series Event is not getting fired.
I need the same to display X and Y values on mouseclick of the series.
Plz Help. Its urgent.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Click Series Event Not Getting triggerred for WebChart

Post by Sandra » Wed Feb 22, 2012 11:53 am

Hello venus,

I have made a simple example where there is two FastLine series and I get the X and Y values clicking the series. I think you can use a similar code to achieve as you want:

Code: Select all

    protected Steema.TeeChart.Tools.SeriesHotspot seriesHotspot1;

    private int clickedX;
    private int clickedY;
    private string msgText;

    protected void Page_Load(object sender, System.EventArgs e)
    {
        clickedX = -1;
        clickedY = -1;
        msgText = "";
        
        Steema.TeeChart.Chart ch1 = WebChart1.Chart;
        MemoryStream tmpChart = new MemoryStream();
       ch1.Aspect.View3D = false;

        if (Session["ch1"] == null)
        {
            //setup Chart
            if (ch1.Series.Count < 2)
            {
                ch1.Series.Add(new Steema.TeeChart.Styles.FastLine());
                ch1.Series.Add(new Steema.TeeChart.Styles.FastLine());
            }

          
            ch1.Series[0].Color = Color.FromArgb(255, 199, 26);
            ch1.Series[1].Color = Color.FromArgb(106, 106, 255);
            (ch1.Series[0] as Steema.TeeChart.Styles.FastLine).LinePen.Width = 5;
            (ch1.Series[1] as Steema.TeeChart.Styles.FastLine).LinePen.Width = 5;

            ch1.Series[0].FillSampleValues(6);
            ch1.Series[1].FillSampleValues(6);
            this.seriesHotspot1 = new Steema.TeeChart.Tools.SeriesHotspot();

            seriesHotspot1.HelperScript = Steema.TeeChart.Tools.HotspotHelperScripts.Annotation;
            seriesHotspot1.HotspotCanvasIndex = 499;
            seriesHotspot1.MapAction = Steema.TeeChart.Styles.MapAction.Script;
            seriesHotspot1.MapElements = "";

            WebChart1.ClickBackground += new Steema.TeeChart.Web.WebChart.ClickEventHandler(this.WebChart1_ClickBackground);
            WebChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(this.WebChart1_AfterDraw);
            WebChart1.ClickSeries += new Steema.TeeChart.Web.WebChart.SeriesEventHandler(this.WebChart1_ClickSeries);
            //export Chart to a MemoryStream template
            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
            ch1.Import.Template.Load(tmpChart);
            WebChart1.ClickBackground += new Steema.TeeChart.Web.WebChart.ClickEventHandler(this.WebChart1_ClickBackground);
            WebChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(this.WebChart1_AfterDraw);
            WebChart1.ClickSeries += new Steema.TeeChart.Web.WebChart.SeriesEventHandler(this.WebChart1_ClickSeries);
        }
    }


    private void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
        //output text message to the rendered Chart.
        if (clickedX != -1)
        {
            g.Font.Bold = true;
            g.Font.Color = Color.Blue;
            g.TextOut(clickedX, clickedY, msgText);
        }
    }

    private void WebChart1_ClickBackground(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        //event triggered when any point on the Chart is clicked. If the ClickSeries event is active
        //it will take precedence when a Series is clicked.
        clickedX = e.X;
        clickedY = e.Y;
        msgText = "Clicked background\n\rX:" + WebChart1.Chart.Axes.Bottom.CalcPosPoint(clickedX).ToString("#0.00")
            + ", Y:" + WebChart1.Chart.Axes.Left.CalcPosPoint(clickedY).ToString("#0.00");
    }

    private void WebChart1_ClickSeries(object sender, Steema.TeeChart.Styles.Series s, int valueIndex, System.EventArgs e)
    {
        Steema.TeeChart.Chart tChart = ((WebChart)sender).Chart;

        clickedX = s.CalcXPos(valueIndex);
        clickedY = s.CalcYPos(valueIndex);
        msgText = "Series: " + tChart.Series.IndexOf(s).ToString() + "\n\rValue: " + s.YValues[valueIndex].ToString("#0.00");
    }
Can you tell us if previous code works as you expect?

I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

venus
Newbie
Newbie
Posts: 8
Joined: Fri Jan 27, 2012 12:00 am

Re: Click Series Event Not Getting triggerred for WebChart

Post by venus » Thu Feb 23, 2012 4:06 am

I have the below code. For me the Click series event is not getting triggreed. Also Scroll is not working. Plz Help. :(
When i try ur code in a seperate Web Page. It works fine. I guess the problem exists with my code.

Code: Select all

    public partial class Nacelle : System.Web.UI.Page
    {
        private int clickedX;
        private int clickedY;
        private string msgText;
        MemoryStream tmpChart1 = new MemoryStream();

        protected void Page_Load(object sender, EventArgs e)
        {

            clickedX = -1;
            clickedY = -1;
            msgText = "";
         
            if (!Page.IsPostBack)
            {
                Steema.TeeChart.Chart chart1 = WebChart1.Chart;
                ((Steema.TeeChart.Tools.ScrollTool)chart1.Tools[0]).Active = false;

                Steema.TeeChart.Chart chart2 = WebChart2.Chart;
                ((Steema.TeeChart.Tools.ScrollTool)chart2.Tools[0]).Active = false;

            }
                string sQuery = "select PowerMean as Signal, cmstimestamp from aa.vwCMSData where cmstimestamp between '2006-01-01' and '2006-12-31' and unitid = 67754 order by cmstimestamp";
                PlotTeeChart(WebChart2.Chart, sQuery);
                WebChart2.Width = 1000;
                sQuery = "select RMSNacelleDownWind as Signal, cmstimestamp from aa.vwCMSData where cmstimestamp between '2006-01-01' and '2006-12-31' and unitid = 67754 order by cmstimestamp";
                PlotTeeChart(WebChart1.Chart, sQuery);
                WebChart1.Width = 1000;
                WebChart1.ClickSeries += new Steema.TeeChart.Web.WebChart.SeriesEventHandler(this.WebChart1_ClickSeries);
                WebChart2.ClickSeries += new Steema.TeeChart.Web.WebChart.SeriesEventHandler(this.WebChart2_ClickSeries);
                ZoomingCode(WebChart2, WebChart2.Chart, "SessionChart2");
                ZoomingCode(WebChart1, WebChart1.Chart, "SessionChart1");
            //}
          
         
        }
        
        
        //************** Zooming Code Starts for Webchart2*******************
        protected void ZoomingCode(Steema.TeeChart.Web.WebChart Webchartdemo,Steema.TeeChart.Chart ch1,string strSession)
        {
           
          //  Steema.TeeChart.Chart ch1 = WebChart2.Chart;
            System.IO.MemoryStream tmpChart = new System.IO.MemoryStream();

            if (Session[strSession] == null)
            {
                if (ch1.Tools.Count < 2)
                {
                    ch1.Tools.Add(new Steema.TeeChart.Tools.ZoomTool());
                    ch1.Tools.Add(new Steema.TeeChart.Tools.SeriesHotspot());
                }
                ch1.Export.Template.Save(tmpChart);
                // ch1.Export.Image.PDF.Save("C:\\Files\\2.pdf");
                Session.Add(strSession, tmpChart);
            }
            else
            {
                tmpChart = (System.IO.MemoryStream)Session[strSession];
                tmpChart.Position = 0;
                Webchartdemo.Chart.Import.Template.Load(tmpChart);
                CheckZoom(Webchartdemo);
            }

         
        }

        private void CheckZoom(Steema.TeeChart.Web.WebChart wChart)
        {
            System.Collections.ArrayList zoomedState = (System.Collections.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);
        }
        //************** Zooming Code ends for Webchart2*******************


        protected void PlotTeeChart(Steema.TeeChart.Chart Chart1, string strSQL)
        {
            DataAccessLayer objDAL = new DataAccessLayer();
            objDAL.OpenConnection();
            DataSet ds = objDAL.ExecuteQuery(strSQL);
            objDAL.CloseConnection();
           // Steema.TeeChart.Chart Chart2 = WebChart2.Chart;
            Steema.TeeChart.Styles.FastLine series1 = new Steema.TeeChart.Styles.FastLine(Chart1);
            Chart1.Aspect.View3D = false;
            Chart1.Aspect.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighSpeed;
          
            series1.XValues.DateTime = true;
            series1.DateTimeFormat = "dd/MM/yyyy";
            series1.DataSource = ds;
            series1.XValues.DataMember = ds.Tables[0].Columns[1].ToString();
            series1.YValues.DataMember = ds.Tables[0].Columns[0].ToString();
            Chart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMonth);
            Chart1.Axes.Bottom.Labels.ExactDateTime = true;
            Chart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy";
            Chart1.Axes.Bottom.Labels.Angle = 90;
            

        }

     

        protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
        {
            Steema.TeeChart.Chart chart1 = WebChart1.Chart;
            ((Steema.TeeChart.Tools.ScrollTool)chart1.Tools[0]).Active = true;

            Steema.TeeChart.Chart chart2 = WebChart2.Chart;
            ((Steema.TeeChart.Tools.ScrollTool)chart2.Tools[0]).Active = true;

        }

        protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        {
            WebChart1.Chart.Axes.Left.Grid.Visible = false;
            WebChart1.Chart.Axes.Bottom.Grid.Visible = false;

            WebChart2.Chart.Axes.Left.Grid.Visible = false;
            WebChart2.Chart.Axes.Bottom.Grid.Visible = false;
        }

      

        protected void WebChart2_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            //output text message to the rendered Chart.
            if (clickedX != -1)
            {
                g.Font.Bold = true;
                g.Font.Color = Color.Blue;
                g.TextOut(clickedX, clickedY, msgText);
            }
        }

        protected void WebChart1_ClickSeries(object sender, Series s, int valueIndex, EventArgs e)
        {
            Steema.TeeChart.Chart tChart = ((WebChart)sender).Chart;

            clickedX = s.CalcXPos(valueIndex);
            clickedY = s.CalcYPos(valueIndex);
            msgText = "Value(X,Y): (" + s.XValues[valueIndex].ToString() + "," + s.YValues[valueIndex].ToString() + ")";

            Steema.TeeChart.Tools.ColorLine colorLine1 = new Steema.TeeChart.Tools.ColorLine(WebChart1.Chart);
            colorLine1.Axis = WebChart1.Chart.Axes.Bottom;
            colorLine1.Active = true;
            colorLine1.AllowDrag = true;
            colorLine1.Value = s.XValues[valueIndex];
            colorLine1.Pen.Color = Color.Blue;
            // colorLine1.Draw3D = true;
            colorLine1.DragRepaint = true;
            //colorLine1.NoLimitDrag = true;
            WebChart1.Chart.Export.Template.Save(tmpChart1);
            Session.Add("colorLine1", tmpChart1);
        }

        protected void WebChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            //output text message to the rendered Chart.
            if (clickedX != -1)
            {
                g.Font.Bold = true;
                g.Font.Color = Color.Blue;
                g.TextOut(clickedX, clickedY, msgText);
            }
        }

        protected void ddl1_SelectedIndexChanged(object sender, EventArgs e)
      

        protected void lnkScroll_Click(object sender, EventArgs e)
        {
            Steema.TeeChart.Chart chart1 = WebChart1.Chart;
            ((Steema.TeeChart.Tools.ScrollTool)chart1.Tools[0]).Active = true;

            Steema.TeeChart.Chart chart2 = WebChart2.Chart;
            ((Steema.TeeChart.Tools.ScrollTool)chart2.Tools[0]).Active = true;
        }

        protected void WebChart2_ClickSeries(object sender, Series s, int valueIndex, EventArgs e)
        {
          Steema.TeeChart.Chart tChart = ((WebChart)sender).Chart;

clickedX = s.CalcXPos(valueIndex);
clickedY = s.CalcYPos(valueIndex);
msgText = "Series: " + tChart.Series.IndexOf(s).ToString() + "\n\rValue: " + s.YValues[valueIndex].ToString("#0.00");


            
        }

       
        
    }
}

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Click Series Event Not Getting triggerred for WebChart

Post by Sandra » Fri Feb 24, 2012 4:39 pm

Hello Venus,

Sorry for the delay. I am working with your project to try to find a solution I answer your asap.

Thank,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Click Series Event Not Getting triggerred for WebChart

Post by Sandra » Thu Mar 01, 2012 4:30 pm

Hello Venus,

ScrollTool doesn't allow triggered the other tools and for this reason it doesn't works for you. I have added it in bug list report with number [TW77016062]. We will try to fix it for next maintenance release. On the other hand, can you tell us if you remove your scrollTool, click event works as you expect?

thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply