Specifying distinct line style between points

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Specifying distinct line style between points

Post by BenW » Fri Oct 28, 2011 8:47 pm

Hi Narcis!

It's been a while, but I've finally had to come back to this post because of an issue we're experiencing. I did try and finally employ your recommended solution of creating a new class (DashLine in the code sample you posted), but this does not work (remember we are still working with version 2). Is there a way to get your sample code to function in the desired manner, as I'm really keen to try and implement a new similar class to see if it fixes our issue.

Our issue, is that we currently use the following event handle:

void lineSeries_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)

to set the series Pointer color and series LinePen.Style so that we can show lines of a specific dash style and color. This solution works well for us except for 1 glitch. When we pan our samples (left or right), the update of the line style (line colors are fine) of the line just off to the left of the chart (its associated pointer is just off to the left boundary also and so is not one of the visible pointers), follows the line style of the line that follows it. I have tried many, many things to solve this but nothing works. It seems that via the GetPointerStyle event handler we're not provided direct access to the 'problem' line (at least its Linepen.Style setting) via the set of visible indicies that are successively passed in to the calls to that event handler. We almost need whatever calls the event handler to provide successive calls from FirstVisibleIndex -1 (instead of FirstVisibleIndex) up to LastVisibleIndex. Is it possible to force/cause this to happen perhaps via the overridden DrawValues(indexValue) call in the DashLine class or some other method within the Steem.TeeChart.Styles.Line class?

When I used your sample code for the DashLine class, it seems that setting g.Pen.Style or even g.Pen.Color and then calling base.DrawValue(valueIndex) has no effect whatsoever on changing the line color or linestyle for that index (Please try it yourself). Are the correct properties of 'g' (the Steema.TeeChart.Chart.Graphics3D object) being accessed to alter the series linestyle and color settings?

Please any suggestions on how to solve or alternatively address this issue will be very much appreciated!

Thanks,
Ben.

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

Re: Specifying distinct line style between points

Post by Sandra » Wed Nov 02, 2011 1:47 pm

Hello Ben,

Sorry for delay. Seems the code of Narcís suggest you, doesn't work because in version 2 of Teechart.Net, Pen.Style is overwritte and in version 4 not, so LinePen.Style in version 2 is always solid and in version 4 take values we have given. I have modified the code of DashLine Class and now it works correctly:

Code: Select all

        public class DashLine : Steema.TeeChart.Styles.Line
        {
            private Steema.TeeChart.Drawing.Graphics3D g;
            public System.Collections.ArrayList penStyles;

            public DashLine() : this(null) { }
            public DashLine(Steema.TeeChart.Chart c)
                : base(c)
            {
                g = c.Graphics3D;
                penStyles = new System.Collections.ArrayList();
            }

            protected override void Draw()
            {
                base.Draw();
            }

            public int Add(double x, double y, System.Drawing.Drawing2D.DashStyle ds, string text, Color color)
            {
                penStyles.Add(ds);
                return Add(x, y, text, color); ;
            }

            public int Add(double x, double y, System.Drawing.Drawing2D.DashStyle ds)
            {
                return Add(x, y, ds, String.Empty, Color.Red);
            }

            public override void DrawValue(int valueIndex)
            {
                g.Pen.Style = (System.Drawing.Drawing2D.DashStyle)penStyles[valueIndex];
                this.LinePen.Style = g.Pen.Style;
                base.DrawValue(valueIndex);
            }

        }

        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                InitializeChart();
            }

            private void InitializeChart()
            {
                tChart1.Aspect.View3D = false;
                tChart1.Dock = DockStyle.Fill;

                DashLine myCustomLine = new DashLine(tChart1.Chart);
                myCustomLine.LinePen.Width = 3;
    
                myCustomLine.Add(0, 2, System.Drawing.Drawing2D.DashStyle.Solid);
                myCustomLine.Add(1, 5, System.Drawing.Drawing2D.DashStyle.DashDot);
                myCustomLine.Add(2, 8, System.Drawing.Drawing2D.DashStyle.DashDotDot);
                myCustomLine.Add(3, 1, System.Drawing.Drawing2D.DashStyle.Dot);
                myCustomLine.Add(4, 4, System.Drawing.Drawing2D.DashStyle.Dash);
            }
Can you please, tell us if previous code help you to solve your problem?
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

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Specifying distinct line style between points

Post by BenW » Wed Nov 02, 2011 4:54 pm

Hi Sandra.

Thanks very much for the clarification. Your change does mean that the sample application now works, but sadly because of the V2 limitation, doesn't solve the problem in our application.

Can you explain why both these lines of code are required:

g.Pen.Style = (System.Drawing.Drawing2D.DashStyle)penStyles[valueIndex];
this.LinePen.Style = g.Pen.Style;

If either one is commented out it just reverts to a solid line. What exactly is the logic behind this?

Is there a relatively simple V2 Steema TeeChart souce code change that will overcome this issue (rather than having to upgrade to V4)?

Regards,
Ben.

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

Re: Specifying distinct line style between points

Post by Sandra » Fri Nov 04, 2011 2:25 pm

Hello Ben,

Please, take a look in the answer there is in the thread.

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