Coloring point symbols on a line series.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Thu Mar 29, 2007 10:30 am

Hi BenW

You can change the color of Pointers in the "GetPointerStyle" event as below code:

Code: Select all

private void line1_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
        {     
            switch (e.ValueIndex)
            {
                case 0: 
                   series.Pointer.Color = System.Drawing.Color.Blue;
                    break;
                case 1: 
                   series.Pointer.Color = System.Drawing.Color.Red;
                    break;
                case 2:
                   series.Pointer.Color = System.Drawing.Color.Yellow;
                    break;
                default: 
                   series.Pointer.Color = System.Drawing.Color.Green;
                    break;
            }
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

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

Post by BenW » Thu Mar 29, 2007 6:49 pm

Hello,

This solution nearly works, but there is a bug, either in my code or the Steema Teechart code ??

I have uploaded my test app that demonstrates this,it in a zip file called SteemaIssue1.zip. I uploaded it to the file server, and the upload program indicated a successful upload, so hopefully have it.

If you run this application, and on the resulting windows form you execute the following sequence:

1. set value field to 2, set color field to red and click Add. Observe Triangle added and colored blue - good so far.
2. Set value field to 4, set color field to green and click Add. Observe first point triangle is now DarkOrange (should be blue according to the code in the line_GetPointerStyle(...) event handler). and second triangle is blue.
3. Set value field to 6, set color field to blue and click Add. Observe first point triangle is yellow, second point triangle is blue and third point triangle is DarkOrange.

If you keep on adding points (my code purges the oldest points after 5 points have been added), you'll noitice that the coloring of the triangles is correct except for the first point (i.e. Index 0), always. It seems as though this first point is always treated as the last index, reflected by the color it is being painted.

Note I have used the latest code (build 2.0.2586.24030), but this made no difference.

Can you confirm whether this is an issue with my code, or if this is an actual bug in the Steema TeeChart implementation.

thanks,
Ben.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Fri Mar 30, 2007 10:44 am

Hi BenW

I could reproduce the issue here and this seems to be a bug. I've added it (TF02012153) to our defect list to be fixed for future releases.

In the meantime, for each event call you can use e.ValueIndex to set the pointer color for the next point that will be drawn; and the first point you can put the color in the "Form1_Load" event and in the default value of the switch in the "GetPointerStyle" event.

You can do something similiar as below code:

Code: Select all

private void Form1_Load(object sender, EventArgs e)
        {
            this.line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            this.line.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(line_GetPointerStyle);
          
            line.Pointer.Visible = true;
            line.Pointer.Color = PointerColor;
            line.FillSampleValues(5);
        }

        private System.Drawing.Color PointerColor = System.Drawing.Color.Blue;

        void line_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
        {
            switch (e.ValueIndex)
            {
                case 0:
                    series.Pointer.Color = System.Drawing.Color.DarkOrange;
                    break;
                case 1:
                    series.Pointer.Color = System.Drawing.Color.Yellow;
                    break;
                case 2:
                    series.Pointer.Color = System.Drawing.Color.Green;
                    break;
                case 3:
                    series.Pointer.Color = System.Drawing.Color.DarkTurquoise;
                    break;
                default:
                    series.Pointer.Color = PointerColor;
                    break;
            }
        }
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

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

Post by BenW » Fri Mar 30, 2007 2:47 pm

Thanks, but sadly this example is only useful as an example and oversimplies my actual required usage. The issue is that as new data values come in (could be one value, could be several at once), I sequence through each new value and Add it to the series. As part of the processing the color to set the symbol/line to also is contained in the set of data being received and processed. So there are three questions that come out of this:

1. When exactly does the line_GetPointerStyle event handler get called? That is, does it get called immediately after I've called the Add() method on the series and before the next value is added to the series - guaranteed?
2. What is the best mechanism for passing the color derived from the data recieved at the time the Add() method is called against the series, to the the line_GetPointerStyle() method? Is there a recommended way of synchronising context data that is established at the time a new point is added to a series with the associated call to line_GetPointerStyle() for that specific point added, so that code in line_GetPointerStyle() can be gauranteed to be using the correct associated color?
3. Can you give me an ETA for the fix for the issue I've submitted. We have released product that relies on this feature, and right now it means that the feature is unusable without this fix, unless a suitable workaround can be established....

thanks,
Ben.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Mon Apr 02, 2007 10:51 am

Hi BenW

For the question 1, yes the "GetPointerStyle" event, was called as you've said.

For the question 2, we have done an array in order to synchronize the colors of the Add method with the colors of the event as you can see in the below code.

For the question 3, we can't know when the bug will be fixed. Please be aware at this forum for new release announcements and what's implemented/fixed on them. In the meantime you can use something similar as below code, here it's working fine.

Code: Select all

private System.Drawing.Color[] PointColors; 

        private void Form1_Load(object sender, EventArgs e)
        {
            this.line = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            this.line.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(line_GetPointerStyle);
          
            PointColors= new System.Drawing.Color[5];

            PointColors[0] = System.Drawing.Color.Blue;
            PointColors[1] = System.Drawing.Color.DarkOrange;
            PointColors[2] = System.Drawing.Color.Yellow;
            PointColors[3] = System.Drawing.Color.Green;
            PointColors[4] = System.Drawing.Color.DarkTurquoise;

            line.Pointer.Visible = true;
            line.Pointer.Color = PointColors[0];
          
        }

        void line_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
        {
            if (e.ValueIndex == line.Count-1)
                series.Pointer.Color = PointColors[0];
            else
                series.Pointer.Color = PointColors[e.ValueIndex+1];
        }


        int[] array = new int[7] { 2, 4, 6, 8, 10, 12, 14 };
        int value = 0;

        private void button1_Click_1(object sender, EventArgs e)
        {
            if ( line.Count < PointColors.Length)
                line.Add(value, array[++value % 7], PointColors[line.Count]);
        }
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

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

Post by BenW » Mon Apr 02, 2007 3:15 pm

OK thanks.

With regard to item three, I've already implemented a solution ( a hashtable of List<Color> objects indexed by series, because we can have several simultaneous series active), and the solution works well, however, when you say 'it works here' I'm assuming you're not refering to the bug.

Is there a work around that can be used where essentially the first point is active (i.e. it's in the list of points to be displayed), and so it will be painted the wrong color (as per the bug), but we can somehow hide it, so that it is invisible to the user?

Also, where should I look to be notified of new releases, and more specifically to determine if this bug has been addressed in that release?

Ben.

Regards,
Ben.

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

Post by Narcís » Mon Apr 02, 2007 3:36 pm

Hi BenW,
Is there a work around that can be used where essentially the first point is active (i.e. it's in the list of points to be displayed), and so it will be painted the wrong color (as per the bug), but we can somehow hide it, so that it is invisible to the user?
Edu's code snippet is also a workaround to the bug. Have you tried using this code at your end?
Also, where should I look to be notified of new releases, and more specifically to determine if this bug has been addressed in that release?
New release announcements are posted at this forum with its respective release notes where all new additions, fixed bugs and enhancements are listed.
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

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

Post by BenW » Mon Apr 02, 2007 8:28 pm

This solution won't work for us, because it assumes that the first and last points are the same color. The last point in the series list is actually the most recent point to be trended, and indicates the current state of the entity being trended.

One other workaround might be to add a dummy point after the next update arrives (i.e. the dummy point is a duplicate of the new point) so that when the event is fired, it executes the line_GetPointerStyle() code to paint the first marker based on the color of the last additional dummy marker, and also the actual last marker ( the one just before the dummy marker) will be drawn in the correct color, but somehow have the series ignore the last dummy value so that it does not appear on the trend ??

Ben.

Edu
Advanced
Posts: 206
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia

Post by Edu » Tue Apr 03, 2007 7:50 am

Hi Ben

This happens because the array is finished, but you can put more colors in the array. You should put as much colors as points.
Best Regards,
Edu

Steema Support Central
http://support.steema.com/

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

Post by BenW » Tue Apr 03, 2007 2:38 pm

Yes, there are as many colos in the List<Color> object as points in the series, but the most recent point added to the series won't be colored in the correct color when line_GetPointerStyles is called:

For example, consider the case where the series contains 2 points and my List<Color> object (call it myColors) contains two entries, the first one being Color.Blue and the second one being Color.Green. This means that the first marker should be colored Blue and the second marker should be colored Green.

The event handler looks like:

Code: Select all

void line_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e) 
        { 
            if (e.ValueIndex == line.Count-1) 
                series.Pointer.Color = myColor[0];
            else 
                series.Pointer.Color = myColor[e.ValueIndex+1]; 
        } 

The line_GetPointerStyle() event handler will be called twice once with an e.ValueIndex of 0 and once with an e.ValueIndex of 1.

On the first call to it, e.ValueIndex will be 0 and so the following line will be executed in the event handler:

Code: Select all

series.Pointer.Color = myColor[e.ValueIndex+1]; 
resulting in the first marker being drawn in Green (not Blue).

On the second call to it, e.ValueIndex will be 1 which is one less than the series.Count value, and so in the event handler the following line will be executed:

Code: Select all

series.Pointer.Color = myColor[0];
...resulting in the last marker being painted Blue (not Green)

Do you agree?

Ben.

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

Post by Narcís » Wed Apr 04, 2007 7:32 am

Hi Ben,
Do you agree?


No. Maybe we haven't explained this well, and I'd like to apologize if that's the case, but I also have the impression that you didn't test the workaround we suggested.

Going back to the root of the bug, which is that the GetPointerStyle event is not setting the color for the pointer being processed, it is setting the color for the next point to be drawn. Having that in mind, we looked for a workaround to achieve what you requested using this buggy event behavior.

Could you please test the code snippet Edu posted and let us know if it works fine at your end?

Thanks in advance.
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

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

Post by BenW » Wed Apr 04, 2007 3:26 pm

Hello Narcís,

After integrating Edu's suggestion, it does seem that the first marker is now being displayed correctly (although not straight away, but probably after the next tchart refresh).

I guess the problem was one of understanding the root of the bug (as you explained in your previous email), and that further the logic in the buggy event handler must be wrapping around to paint the first marker in the color of the last marker - correct? (this is the bit I was having trouble with in rationalizing, after dry running Edu's code in my mind)

Anyways when TF02012153 is resolved, I'm assuming that the code in the event handler can revert to looking like:

Code: Select all

void line_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e) 
        { 
                series.Pointer.Color = myColor[e.ValueIndex]; 
        }


Are you able to give me a fix date for TF02012153, so that I can coordinate this with our release schedule?

Regards,
Ben.

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

Post by Narcís » Thu Apr 05, 2007 7:21 am

Hello Ben,
After integrating Edu's suggestion, it does seem that the first marker is now being displayed correctly (although not straight away, but probably after the next tchart refresh).
Chart doesn't need to be refreshed here using latest maintenance release available at the client area. Edu already posted full project code so you can test it at your end.
Anyways when TF02012153 is resolved, I'm assuming that the code in the event handler can revert to looking like:
Yes, that's expected behavior.
Are you able to give me a fix date for TF02012153, so that I can coordinate this with our release schedule?
Sorry but I'm afraid we can't give you this information for now. Please be aware a this forum for new release announcements and what's being implemented and fixed on them.
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

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

Issue TF02012153

Post by BenW » Sun Sep 16, 2007 5:05 pm

Hello,

Can you let me know if this issue (TF02012153) has been addressed as yet?

We have been patient in awaiting a fix for this, and have had to release product with the suggested workaround. Although the workaround does work, there are some side effects, which our customers will definitely voice their concerns over. Some of the side effects are:

1. When the GetPointerStyleEvent handler is called, I have to update the symbol in addition to the color for the point. The update of the symbol does not have the workaround applied to it, but the color does. This results in the symbol for the pen in the Legend sometimes being the wrong symbol, because the last time the GetPointerStyleEvent handler is called (when ever it does get called, say after another window has passed over the chart), the very last action is to drawn the first symbol. This is obviously very confusing to our customers.

2. Some times, the call to the GetPointerStyleEvent handler does not occur until some time after the initial (incorrect draw) which means that the incorrect trace (where the first color is drawn as the last color), hangs around indicating invalid data. Of course in our critical realtime applications, this is quite the concern.

Please let me know the status of this issue as it is very important to us.

Kind Regards,
Ben.

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

Post by Narcís » Mon Sep 17, 2007 8:53 am

Hi Ben,

The issue hasn't been fixed yet. It's a high-priority item on our bug list to be fixed for new releases.
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

Post Reply