webchart zooming custom axis

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
simon
Newbie
Newbie
Posts: 14
Joined: Tue Jan 20, 2009 12:00 am

webchart zooming custom axis

Post by simon » Fri Nov 12, 2010 3:13 am

looking through the forums, ive found a reference back in 2007 asking for zooming in the webchart to work for custom axes. it was listed as a soon to be added feature.

at the moment i zoom in on my chart (datetime x axis), and i have 2 custom horizontal axes with different lengths below the default bottom axis

there is no event to capture for zooming in asp.net, so i figured when im checking for the zoomed arraylist, i would adjust each custom axis min and max.

ive come a little stuck with the fact my custom axes are all "different" ranges of values. for example, the default is datetime, the 1st custom is a range of 0-x days, and the 2nd custom is a range of degrees...

how can i get the max and min of the zoom rectangle for these custom axes...

or is there a teechart implementation i can use that ive been unable to find in the help documentation.

version 3.5 of teechart.

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

Re: webchart zooming custom axis

Post by Sandra » Fri Nov 12, 2010 3:46 pm

Hello simon,

It is a feature request known for us and is it in wish-list with number [TW77012342] and we have increased its priority. Moreover, I have made a simple example for that I think you can use in your application:

Code: Select all

    Steema.TeeChart.Styles.FastLine series1, series2, series3;
    Steema.TeeChart.Axis bottomAxis1, bottomAxis2, bottomAxis3;
    Steema.TeeChart.Tools.ZoomTool tool1;
    System.IO.MemoryStream tmpChart;
    bool zoomed;
    protected void Page_Load(object sender, System.EventArgs e)
    {

        Steema.TeeChart.Chart ch1 = WebChart1.Chart;
		     tmpChart=new System.IO.MemoryStream();
            if (Session["ch1"] == null)
			{			
			    ch1 = WebChart1.Chart;
                ch1.AutoRepaint = false;
                ch1.Aspect.View3D = false;     
                tool1 = new Steema.TeeChart.Tools.ZoomTool(WebChart1.Chart);
                tool1.ZoomPenColor = System.Drawing.Color.OliveDrab;
                ch1.Panel.Gradient.Visible = false;
                ch1.Walls.Visible = false;

                series1 = new FastLine(ch1);
                series2 = new FastLine(ch1);
                series3 = new FastLine(ch1);

                series1.FillSampleValues();
                series2.FillSampleValues();
                series3.FillSampleValues();

                Steema.TeeChart.Axis bottomAxis = ch1.Axes.Bottom;
                bottomAxis1 = bottomAxis.Clone() as Steema.TeeChart.Axis;
                bottomAxis1.StartPosition = 0;
                bottomAxis1.EndPosition = 25;
                bottomAxis2 = bottomAxis.Clone() as Steema.TeeChart.Axis;
                bottomAxis2.StartPosition = 30;
                bottomAxis2.EndPosition = 55;
                bottomAxis3 = bottomAxis.Clone() as Steema.TeeChart.Axis;
                bottomAxis3.StartPosition = 60;
                bottomAxis3.EndPosition = 85;

                //series1.CustomHorizAxis = bottomAxis1;
                ch1.Axes.Bottom.EndPosition = 25;

                series2.CustomHorizAxis = bottomAxis2;
                series3.CustomHorizAxis = bottomAxis3;
                ch1.Panel.MarginBottom = 10;
                ch1.Export.Template.IncludeData = true;
                ch1.Export.Template.Save(tmpChart);
                //save template to a Session variable
                Session.Add("ch1", tmpChart);
                series1.BeforeDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
                series1.AfterDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
                series2.BeforeDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
                series2.AfterDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
                series3.BeforeDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
                series3.AfterDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
         			}

			else
			{
				//retrieve the session stored Chart
                tmpChart = (System.IO.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);
                CheckZoom(WebChart1);

                WebChart1.Chart[0].BeforeDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
                WebChart1.Chart[0].AfterDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
                WebChart1.Chart[1].BeforeDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
                WebChart1.Chart[1].AfterDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
                WebChart1.Chart[2].BeforeDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
                WebChart1.Chart[2].AfterDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
                WebChart1.Chart.Invalidate();              
			}
              
    }

    void series1_AfterDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
        if (zoomed)
        {
            g.UnClip();
        }
    }

    void series1_BeforeDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
    {
        if (zoomed)
        {
            Series s = sender as Series;
         
                double left = s.GetHorizAxis.IStartPos;
                double right = s.GetHorizAxis.IEndPos;
                double top = s.GetVertAxis.IStartPos;
                double bottom = s.GetVertAxis.IEndPos;
                g.ClipRectangle((int)left, (int)top, (int)right, (int)bottom);
         }
    }

   
    private void CheckZoom(Steema.TeeChart.Web.WebChart WebChart1)
    {
        Steema.TeeChart.Chart ch1 = WebChart1.Chart;

        System.Collections.ArrayList zoomedState = (System.Collections.ArrayList)Session[WebChart1.ID   "Zoomed"];
        zoomedState = ((Steema.TeeChart.Tools.ZoomTool)WebChart1.Chart.Tools[0]).SetCurrentZoom(Request,
            zoomedState);
        if (zoomedState == null)
        {
            Session.Remove(WebChart1.ID   "Zoomed");
            zoomed = false;
            for (int i = 0; i < WebChart1.Chart.Series.Count; i  )
            {
                if (ch1[i].GetVertAxis.IsCustom())
                {
                    ch1[i].CustomHorizAxis.Automatic = true; 
                }
            }
        }

        else
        {
            Session.Add(WebChart1.ID   "Zoomed", zoomedState);
            zoomed = true;

            for (int i = 0; i < ch1.Series.Count; i  )
            {
                Steema.TeeChart.Axis axis = ch1[i].GetHorizAxis;
                if (axis.IsCustom())
                {                
                    axis.SetMinMax(ch1.Axes.Bottom.Minimum, ch1.Axes.Bottom.Maximum);
                }
            }

        }
Please, could you check if previous code works as you want?

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

simon
Newbie
Newbie
Posts: 14
Joined: Tue Jan 20, 2009 12:00 am

Re: webchart zooming custom axis

Post by simon » Mon Nov 15, 2010 2:20 am

not quite what i was looking for.

ive come up with a poor solution... but should suffice until the feature is added (though the feature wont make back into 3.5, so id have to upgrade). i should note that i still doesnt work exactly as needed, but im working on it.

attached is a picture of the scenario i was attempting to describe.

notice that the GDD axis doesnt match up.

if you have a further solution, let me know...
Attachments
teechartzoom.png
teechartzoom.png (72.83 KiB) Viewed 6129 times

Post Reply