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

Specifying distinct line style between points

Post by BenW » Fri Oct 22, 2010 5:44 am

Hello.

We have a new customer requirement that we're trying to implement. We're using a line series and we need to be able to dynamically specify the style (dash, dot, solid) for each line that is used to 'connect' each point in the line series.

Is this possible in the same way that the color of the line (ColorEach) is dynamically configurable between each point?

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 » Fri Oct 22, 2010 10:06 am

Hello Ben,

I recommend use different series for do as you want, as do in below example:

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

       private void InitializeChart()
        {
            tChart1.Aspect.View3D = 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);
            Steema.TeeChart.Styles.Line series3 = new Steema.TeeChart.Styles.Line(tChart1.Chart);

            series1.FillSampleValues(25);
            series2.DataSource= series1;
            series3.DataSource= series1;
            for(int i=0; i<series1.Count;i  )
            {
                series1.LinePen.Style = System.Drawing.Drawing2D.DashStyle.Solid;
                series2.LinePen.Style = System.Drawing.Drawing2D.DashStyle.Dot;
                series3.LinePen.Style = System.Drawing.Drawing2D.DashStyle.Dash;
                if (i <= (series1.Count) / 3)
                {
                    series2.SetNull(i);
                    series3.SetNull(i);
                }
                else if ((i > (series1.Count) / 3) && (i <= (series1.Count) / 2))
                {
                    series1.SetNull(i 1);
                    series3.SetNull(i);
                }
                else if ((i > (series1.Count) / 2) && i <= series1.Count - 1) 
                {
                    series1.SetNull(i);
                    series2.SetNull(i 1);
                }

            }
Could you please, tell us if code works fine for you?

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 » Fri Oct 22, 2010 4:39 pm

Hi Sandra.

Thanks for the suggestion, but I was hoping there was a more elegant (or rather readily implemenable) way of addressing this against a single line series rather than introducing 3 series to represent one. I was hoping in the same way that there is a ColorEachLine capability, that there was a corresponding StyleEachLine feature - seems reasonable for line series, I think...

Note we have an existing (and functionaly rich) implementation of line series (we call them Trends and Plots) which allows customers to retrieve and Trend/Plot their data for up to 12 pens, concurrently. Using your suggested method would mean our series count would go up to a maximum of 12 x 3 = 36 line series to accomodate the 12 pens. I'm also wondering how this would impact things and if your solution would work seamlessly for panning and zooming and other such features that we've implemented (interpolation, legend information presentation, etc). Right now we have work arounds for several Steema bugs (we're currently locked in to using runtime version 2.0.3203.23272 of the .NET TeeChart), and so I was hoping the solution for this feature wouldn't impact existing functionality too much, but having to introduce 3 series per pen and manage the additional functionality around them is not quite meeting that expectation...

Is this perhaps a reasonable feature that you could look to incorporating into the TeeChart product?

Kind 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 » Mon Oct 25, 2010 8:45 am

Hello BenW,

I have added your request in the feature request list with number [TF02015235] to be considered for inclusion in future versions of TeeChart.Net.
On the other hand, could you please, tell us which bugs do you have pending,that you are still using version 2 of TeeChart.Net?

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 » Mon Oct 25, 2010 4:24 pm

Hi Sandra.

Thank you for adding this request.

Please understand our current delivery schedule means that this particular feature has already been promised to an exisiting high profile customer of ours. Is it possible that this feature can be made available as soon as is possible? Our current commited schedule means that we planned to have this feature ready by early to mid December 2010, ready for Q/A and then subsequent delivery to our customer. This feature is very important to them, and in conjunction with specifying the line color will allow them to readily determine the data quailty of the charted points. Are there perhaps any other techniques that you can suggest that will allow us to relay the information they require in place of changing the line style for each line? That is, for each line displayed the current expectation is that we're able to control the line color and style between 2 data points. We can control the color, but not the line style, but is there another attribute (i.e. indicator that has at least 3 distinct states) that can be used instead of the line style to provide an alternative data quality indication?

Please let me know if there are any options for helping us with this situation.

With regards to the existing bugs that we've have to 'work around', they are as follows:

TF02013562
TF02012863
TF02012153

Kind Regards,
Ben.

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

Re: Specifying distinct line style between points

Post by BenW » Mon Oct 25, 2010 8:45 pm

Hi Sandra.

Further to my last email, as a result of Steema issue TF02012153, we use the GetPointerStyle event to work around it. In looking at the event handler we've implemented for this, I had an idea to see if the series.LinePen.Style property could be set dynamically in the event handler, resulting in having the desired control over the line style for each line drawn between points. To my extreme joy, it actually did work and so via the event handler, I was able to specify distinct and different line styles for each line drawn.

Can you please confirm that this is something that is supported by Steema (i.e. also in TeeChart versions > V2.0) and is something that will continue to work?

The event handler code (modified) that illustrates this is included below.

thanks,
Ben


void lineSeries_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
{
lock (seriesUpdateLock)
{
// Get the Data Quality lists for this series...
Hashtable thisSeriesDQColorList = this.trendDQColorsForSeries[series] as Hashtable;
Hashtable thisSeriesDQLineStyleList = this.trendDQLineStyleForSeries[series] as Hashtable;

if (thisSeriesDQColorList != null &&
thisSeriesDQLineStyleList != null)
{
if (e.ValueIndex >= 0 &&
series != null &&
e.ValueIndex < thisSeriesDQColorList.Count &&
e.ValueIndex < thisSeriesDQLineStyleList.Count)
{

series.Pointer.Color = thisSeriesDQColorList[e.ValueIndex];
series.Pointer.Pen.Color = thisSeriesDQColorList[e.ValueIndex];

// Set the line style for each line drawn
series.LinePen.Style = thisSeriesDQLineStyleList[e.ValueIndex];
}
}
}
}

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

Re: Specifying distinct line style between points

Post by Narcís » Tue Oct 26, 2010 8:41 am

Hi Ben,
Please understand our current delivery schedule means that this particular feature has already been promised to an exisiting high profile customer of ours. Is it possible that this feature can be made available as soon as is possible? Our current commited schedule means that we planned to have this feature ready by early to mid December 2010, ready for Q/A and then subsequent delivery to our customer. This feature is very important to them, and in conjunction with specifying the line color will allow them to readily determine the data quailty of the charted points. Are there perhaps any other techniques that you can suggest that will allow us to relay the information they require in place of changing the line style for each line? That is, for each line displayed the current expectation is that we're able to control the line color and style between 2 data points. We can control the color, but not the line style, but is there another attribute (i.e. indicator that has at least 3 distinct states) that can be used instead of the line style to provide an alternative data quality indication?

Please let me know if there are any options for helping us with this situation.
The easiest and quickest option I can think of would be creating a new series style derived from existing ones with a pen style valuelist and overriding DrawValue method, something like the RectangleBubble example here. For example:

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();
        }

        public 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.Empty);            
        }

        public override void DrawValue(int valueIndex)
        {
            g.Pen.Style = (System.Drawing.Drawing2D.DashStyle)penStyles[valueIndex];
            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);
        }
    }
TF02013562
This hasn't been fixed yet but you can add a ColorLine at axis maximum as a workaround.
TF02012863
This was fixed in mid 2008 for TeeChart for .NET v3.
TF02012153
As discussed here, this was not considered a bug. However, another argument was added to GetPointer style (e.Color) so that you can also change pointer's color in this event. This was added in v3 as you can see in 7th November 2007 release notes at the version info page.
Further to my last email, as a result of Steema issue TF02012153, we use the GetPointerStyle event to work around it. In looking at the event handler we've implemented for this, I had an idea to see if the series.LinePen.Style property could be set dynamically in the event handler, resulting in having the desired control over the line style for each line drawn between points. To my extreme joy, it actually did work and so via the event handler, I was able to specify distinct and different line styles for each line drawn.

Can you please confirm that this is something that is supported by Steema (i.e. also in TeeChart versions > V2.0) and is something that will continue to work?
This probably works because at each call of this event you are setting the pen for the next point which will be plotted in the series. This task is not what this event was designed for so we can not promise this will always be this way. If you send attach a simple example project we can run "as-is" we will be glad to check if it works with latest TeeChart .NET release. Anyway, I think the easiest and most consistent solution is my custom series suggestion.
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

Re: Specifying distinct line style between points

Post by BenW » Tue Oct 26, 2010 9:04 pm

Hi Narcís, I hope you're well!

Thanks for your suggestion, but integrating your solution would mean some significant additional work/rework, and given that the GetPointerStyle event handler solution I'm using works well (meaning one line code change to something that is already implemented), then in the interests of minimizing rework and reducing change risk, etc, etc, I'd like to go with the that one. As such I will take you up on your kind offer of verifying if the solution still works under V3.0. I have uploaded 2 files.

LineStyleTest is a zip file containing the VS2k5 project that will allow you to build a small test application that uses my solution. LineStyleV2Appearance is a bitmap image of how it looks under V2.0 on my machine. The important thing to verify is that the line colors and styles are sequentially being sequenced (as shown in the attached bitmap) between Red, Green and Orange, and Dash, Dot and Solid respectively.

Kind Regards,
Ben.

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

Re: Specifying distinct line style between points

Post by Narcís » Wed Oct 27, 2010 7:25 am

Hi Ben,

Where did you send the files? I can't find them attached to your post nor at the upload page using your forums contact e-mail address.

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

Re: Specifying distinct line style between points

Post by BenW » Wed Oct 27, 2010 4:00 pm

Hi Narcís.

Oops I tried to upload them again and I noticed an error telling me that the files were too big. I've paired the content down and will upload them in a single zip file (LineStyleTest.zip) which contains both the VS2K5 project and LineStyleV2Appearance bitmap.

Sorry for the confusion.

Regards,
Ben.
Attachments
LineStyleTest.zip
(43.73 KiB) Downloaded 836 times

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

Re: Specifying distinct line style between points

Post by Narcís » Thu Oct 28, 2010 3:53 pm

Hi Ben,

Thanks for the files. I found a bug in v3 and v4 which didn't let the series being painted which is that setting Legend.Text hides the series, for example:

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        private void InitializeChart()
        {
            Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
            line1.FillSampleValues();

            tChart1.Legend.Text = "legend";
        }
This is a bug which I have added as a high-priority issue (TF02015257) to the defect list to be fixed. So in your project I had to comment in the line that set Legend.Text.

Having said that I got little bit different output in v3 and v2010 (aka v4) than in v2 where I get this:
Ben2.png
Ben2.png (32.8 KiB) Viewed 18092 times
While in v2010 I get this:
Ben2010.png
Ben2010.png (45.69 KiB) Viewed 18094 times
You'll notice line colours are shifted one position to the right. This is most likely due to the implementation of TF02012153 in v3 which I pointed you before. So in TeeChart 2010 you will have to tweak GetPointerStyle implementation a little bit to get what you have in v2.

Considering all that's been discussed here I think the simplest implementation and stabler solution is using a custom series as in the example I wrote.
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

Re: Specifying distinct line style between points

Post by BenW » Thu Oct 28, 2010 5:11 pm

Hi Narcís.

As usual thanks for your diligent verfication!

I think we're in good shape as the dynamic linestyle capability still works in both V3 and V4. I do agree with your 'best solution' comment, however time/resources is of this essence currently and the simpler, more established fix is the best fit for us right now...

I am a little confused about something though; are you saying that TF02012153 has been addressed in V4, but not in V3?

We are definitely planning to upgrade to the latest version of Steema Teechart (at some juncture in our busy schedule), and that would be V4, correct? Is there a V5 looming on the horizon?

Kind Regards,
Ben.

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

Re: Specifying distinct line style between points

Post by Narcís » Mon Nov 01, 2010 6:04 pm

Hi Ben,
I am a little confused about something though; are you saying that TF02012153 has been addressed in V4, but not in V3?
No, TF02012153 was a feature request implemented in v3 and therefore inherited in v4. So in that sense both version behave the same way.
We are definitely planning to upgrade to the latest version of Steema Teechart (at some juncture in our busy schedule), and that would be V4, correct? Is there a V5 looming on the horizon?
Yes, it's v4 "aka" v2010. I don't think there's a v5 planned for now due to the new subscription license system for v4.
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

Re: Specifying distinct line style between points

Post by BenW » Mon Nov 01, 2010 7:45 pm

Thanks for the update Narcís.

Regards,
Ben.

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

Re: Specifying distinct line style between points

Post by Narcís » Mon Nov 08, 2010 10:32 am

Hi Ben,

Regarding TF02015257, we found that you should use Legend.Title.Text instead of Legend.Text, for example:

Code: Select all

            tChart1.Legend.Title.Text = "legend";
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