CHart axis area Clipping

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

CHart axis area Clipping

Post by Snarkle » Wed Nov 03, 2010 3:58 am

Greetings,

I have a chart with multiple axes and in the top axis I have stock data and many trend lines drawn ... when I zoom in to my stock data the trend lines (drawlines) render on the custom axis. see image.
Clipping.png
Clipping.png (20.44 KiB) Viewed 13637 times
Is there a way to set up a clipping region (or whatever clipping mechanism) to stop drawlines in the top axis from 'overflowing' onto my custom axis.
--------------------
Cheers Phil.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: CHart axis area Clipping

Post by Narcís » Wed Nov 03, 2010 8:29 am

Hi Phil,

You can try doing something like in the All Features\Welcome !\Axes\Opaque zones example in the features demo available at TeeChart's program group.
Best Regards,
Narcís Calvet / 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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: Chart axis area Clipping

Post by Snarkle » Thu Nov 04, 2010 12:30 am

Greetings,

That didn't work for me ... the example hooks up before and afterdraw event handlers to a Series .. my series are fine they only draw within their axes, its the drawlines that are getting drawn every where and they dont have before and after draw events.

We have the source code .. could we clip inside the Drawline.cs class ?

in any case below is the code I put in the before_Draw .. I guess it sets up a clipping region for each series per axis .. but drawlines seem to ignore it.

Code: Select all

        private void StockChart_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            if (sender.GetType() == typeof(Series))
            {
                Rectangle rect = StockChart.Chart.ChartRect;
                int end = rect.Right;
                int start = rect.Left;

                Series s = (Series)sender;

                //int left = s.GetHorizAxis.IStartPos;
                //int right = s.GetHorizAxis.IEndPos;
                int top = s.GetVertAxis.IStartPos;
                int bottom = s.GetVertAxis.IEndPos;
                StockChart.Graphics3D.ClipRectangle(start, top, end, bottom);

            }
        }
--------------------
Cheers Phil.

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

Re: CHart axis area Clipping

Post by Sandra » Thu Nov 04, 2010 12:34 pm

Hello Phil,
I think that you need assign your DrawLine of determinate series. You can do something as next example that works fine here with last version of TeeChart.Net:

Code: Select all

 public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        Steema.TeeChart.Tools.DrawLine drawline,drawline1;
        Steema.TeeChart.Axis axes1;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Aspect.ClipPoints = false;

            Steema.TeeChart.Styles.Line series1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            Steema.TeeChart.Styles.Line series2 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            series1.FillSampleValues();
            series2.FillSampleValues();

            series2.VertAxis = Steema.TeeChart.Styles.VerticalAxis.Left;
            axes1 = new Steema.TeeChart.Axis();
            tChart1.Axes.Custom.Add(axes1);
            axes1.AxisPen.Color = Color.Red;
            series1.CustomVertAxis = axes1;
            tChart1.Axes.Left.StartPosition = 0;
            tChart1.Axes.Left.EndPosition = 50;
            axes1.StartPosition = 50;
            axes1.EndPosition = 100;
            axes1.Automatic = true;
           //DrawLines
            drawline = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
            drawline1 = new Steema.TeeChart.Tools.DrawLine(tChart1.Chart);
            drawline.Active = true;
            drawline.Series = series1;
            drawline1.Series = series2;
            //Series1
            series1.AfterDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
            series1.BeforeDrawValues  = new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
            //Series2
            series2.AfterDrawValues  =new Steema.TeeChart.PaintChartEventHandler(series1_AfterDrawValues);
            series2.BeforeDrawValues  =new Steema.TeeChart.PaintChartEventHandler(series1_BeforeDrawValues);
            drawline.NewLine  = new Steema.TeeChart.Tools.DrawLineEventHandler(drawline_NewLine);
            drawline1.NewLine  = new Steema.TeeChart.Tools.DrawLineEventHandler(drawline1_NewLine);
            tChart1.Draw();
        }
        void drawline1_NewLine(Steema.TeeChart.Tools.DrawLine sender)
        {
            drawline1.EnableDraw = false;
        }
        void drawline_NewLine(Steema.TeeChart.Tools.DrawLine sender)
        {
            drawline.EnableDraw = false;
        }
        void series1_BeforeDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
                Steema.TeeChart.Styles.Series s = sender as Steema.TeeChart.Styles.Series;
   				int left = s.GetHorizAxis.IStartPos;
                int right = s.GetHorizAxis.IEndPos;
                int top = s.GetVertAxis.IStartPos;
				int bottom = s.GetVertAxis.IEndPos;
                tChart1.Graphics3D.ClipRectangle(left, top, right, bottom);
        }
        void series1_AfterDrawValues(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
              tChart1.Graphics3D.ClearClipRegions();
        }
Could you tell us 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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: CHart axis area Clipping

Post by Snarkle » Fri Nov 05, 2010 12:03 am

Hi Sandra,

No it didnt work for me .. although its different than last time ... I get a clippign region this time although its not where it should be and it doesnt change ... essentially now I have a 2/3 of the screen that I cant draw on .. see below picture. The red circles show where I'm being clipped .. which is about half the chart including the custom axis .. and I can still overflow a drawline onto the custom axis.
clipping2.png
clipping2.png (28.64 KiB) Viewed 13585 times
This is my Before_draw Method.

Code: Select all

        private void StockChart_BeforeDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            if (sender.GetType() == typeof(Candle) || sender.GetType() == typeof(Line))
            {
                Rectangle rect = StockChart.Chart.ChartRect;
                int end = rect.Right;
                int start = rect.Left;
                int Top = rect.Top;
                int Bottom = rect.Bottom;
                Debug.Print("Rect:  " + "  l: " + start.ToString() + " t: " + Top.ToString() + " r: " + end.ToString() + " b: " + Bottom.ToString());

                Series s = sender as Series;

                int left = s.GetHorizAxis.IStartPos;
                int right = s.GetHorizAxis.IEndPos;
                int top = s.GetVertAxis.IStartPos;
                int bottom = s.GetVertAxis.IEndPos;
                StockChart.Graphics3D.ClipRectangle(left, top, right, bottom);
                
                Debug.Print("Series:" + s.Title + "  l: " + left.ToString() + " t: " + top.ToString() + " r: " + right.ToString() + " b: " + bottom.ToString());
                Debug.Print("-------------------------------------------------------");
            }
        } 
The debug code is showing me that it is calculating what look like the correct values for a region .. StockChart.Graphics3D.ClearClipRegions(); is getting called in the Afterdraw event.

This is me setting up the Series and drawlines

Code: Select all

            foreach (Series s in StockChart.Series)
            {
                s.AfterDrawValues += new PaintChartEventHandler(StockChart_AfterDraw);
                s.BeforeDrawValues += new PaintChartEventHandler(StockChart_BeforeDraw);
            }

           ((DrawLine)theTool).Series = StockChart.Series[0];
It seems to be totally ignoring the ClipRectangle values that are getting created in the Before Draw Event. I have no idea what values it must be using ...
--------------------
Cheers Phil.

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

Re: CHart axis area Clipping

Post by Sandra » Fri Nov 05, 2010 10:28 am

Hello Phil,

Could you please, send us a simple project, because we can try to find a good solution for you here?

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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: CHart axis area Clipping

Post by Snarkle » Fri Nov 26, 2010 5:23 am

Here is the first problem I came up against
ClippingProblemDrawline.png
ClippingProblemDrawline.png (106.37 KiB) Viewed 13546 times
you can replicate by hitting the drawline button and dragging across the screen ... it will clip for no apparent reason.
remove the line "Drawline.Series = candles" and there is no clipping at all.

it happens in this code

private void btn_DrawLine2_Click(object sender, EventArgs e)
{
DrawLine drawline = new DrawLine(tChart1.Chart);
drawline.Series = Candles; <================================== when I assign it a series I get the above behaviour.
drawline.Pen.Color = Color.Red;
drawline.Pen.Width = 2;
drawline.EnableDraw = true;
}
Attachments
Sandbox.zip
(279.22 KiB) Downloaded 460 times
--------------------
Cheers Phil.

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

Re: CHart axis area Clipping

Post by Sandra » Fri Nov 26, 2010 3:50 pm

Hello Phil,


I couldn't reproduce your problem using last maintenance release of 28 of September. Please, download last version of TeeChart.Net and try again if your problem appears. If your problem after upgrade still appears, please send us a simple project, because we can reproduce your problem here.

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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: CHart axis area Clipping

Post by Snarkle » Sun Nov 28, 2010 11:25 pm

Looking through the bug fixes, [TF02015039] When Series property of DrawLine Tool assigned lines were erroneously clipped. Fixed.

That looks like my problem ... however when I log into the download site with any of the licences we have I cannot find the source code version ...
Where do I find said source code version (I've added an extra class to the source code we have, so I can just drop it into (fingers crossed) a newer version.)
--------------------
Cheers Phil.

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

Re: CHart axis area Clipping

Post by Sandra » Mon Nov 29, 2010 11:01 am

Hello Phil,

I download last version of TeeChart 2010 Source Code (TeeChartNetSrc_4.1.2010.09280), problem doesn't appear here and drawlineTool works fine for me. Are you using this version?

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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: CHart axis area Clipping

Post by Snarkle » Mon Nov 29, 2010 11:00 pm

No I havent downloaded that ... I cant find it in the list and I KNOW that at least one of our licences includes source code (thus why I have downloaded it once)
I can see all the Binaries and I've downloaded the latest one .. but I and a collegue have looked until our eyes have popped from our heads ... all we see is the gazillion versions of the binaries ... nothing with that magic "src" in the title ...

I'll have another look to confirm I'm not mad ...
--------------------
Cheers Phil.

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

Re: CHart axis area Clipping

Post by Sandra » Tue Nov 30, 2010 9:04 am

Hello Phil,

Ok. Please, contact our Sales Dept. at sales at steema dot com for get your number of license of TeeChart2010 Source code and then try again to download upgrade version . If you have more problems please let me know.

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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: CHart axis area Clipping

Post by Snarkle » Fri Dec 10, 2010 4:31 am

Greetings,

OK sorted out the license issue, downloaded the latest Source code, dropped it into the Solution and then added the above supplied code and now clipping works !!! YAY I'm in clipping paradise ;-)

An aside question though ... the Drawlines are now much slower than before, wheras before I could click and drag the mouse in real time and the Drawline would drawto the mouse position instantly ... now the line lags waaaaaaaaaaaay behind the mouse ... I have branched copies of my solution .. TeeChart 4.0 version is fine .. TeeChart 4.1 is 1/3 of the speed .. have you noticed any speed changes in drawing the DrawLines ???


Cheers Phil.
--------------------
Cheers Phil.

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

Re: CHart axis area Clipping

Post by Sandra » Fri Dec 10, 2010 11:36 am

Hello Phil,
OK sorted out the license issue, downloaded the latest Source code, dropped it into the Solution and then added the above supplied code and now clipping works !!! YAY I'm in clipping paradise ;-)
I am glad that now you are in clipping paradise :D.
An aside question though ... the Drawlines are now much slower than before, wheras before I could click and drag the mouse in real time and the Drawline would drawto the mouse position instantly ... now the line lags waaaaaaaaaaaay behind the mouse ... I have branched copies of my solution .. TeeChart 4.0 version is fine .. TeeChart 4.1 is 1/3 of the speed .. have you noticed any speed changes in drawing the DrawLines ???
Can you please, tell us exactly number of version 4.0 is faster than version last version 4.1?

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

Snarkle
Newbie
Newbie
Posts: 91
Joined: Wed Jun 30, 2010 12:00 am

Re: CHart axis area Clipping

Post by Snarkle » Mon Dec 13, 2010 1:12 am

Hi Sandra,

Our previous TeeChart version we had installed was 4.0.2010.27960 Now we are up to 4.1.2010.11301

As well as the line studies the Line CandleStyles are also much slower ... which is a problem as under 4.0 the line CandleStyles where too slow .. but now under 4.1 they are no longer usable ... the Candle and Bar styles are still very fast.

I'm talking about switching between candleStyles i.e. CandleStyles.CandleStick; CandleStyles.CandleBar; CandleStyles.Line;

I have a button in the App that changes the CandleStyles between Bar, Candle, Line, Color Line and Point and Figure. It doesnt do anything too magical just reloades the data and draws with the new candleStyles .. works Fine between Candle and Bar ... Point and Figure I know has bugs and is waiting to be fixed at some point.

I do populate these Line and ColoredLine with the same OHLC data as Bar and Candle and generally I limit the amount of data to 10 years worth
I generally notice it when I try to zoom in to a Line Style chart and scroll .. it goes sooo slow .. the intial loading and drawing is fast enough .. zooming and scrolling on a candle or Bar chart is really fast.

For the time being I've reverted back to 4.0.2010.27960 (but I have copied across some of the bug fixes that I needed)
--------------------
Cheers Phil.

Post Reply