Palette no longer applied by default to new series

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Palette no longer applied by default to new series

Post by Michal Blazejczyk » Wed Oct 08, 2008 8:46 pm

Hi,

I'm using ApplyPalette() to apply a custom color palette to my charts. The way it used to work is that every new Point or Bar plot added to the chart had a different color from the palette. Now I've upgraded TeeChart to a more recent version (3.5.3188.18561), and the palette doesn't seem to work anymore: if I add more than one series, they all have the same color - the first color from the palette.

How can I make the series color to be automatic again?

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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 Oct 09, 2008 8:31 am

Hi Michal,

The example at All Features\Welcome !\Themes\Custom Palettes in the features demo, available at TeeChart's program group, works fine for me here. Does it work 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

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Thu Oct 09, 2008 6:29 pm

Hi Narcis,

Yes, it works in the demo. But it's broken in my code. Here's what I'm doing:
- Creating a chart.
- Applying a template to it using chart.Import.Template.Load().
- Apply the palette: ColorPalettes.ApplyPalette().
- Find a template series in the chart.
- Clone the template series: templateSeries.Clone().
- Configure the cloned series.
- Add the cloned series to the chart: chart.Series.Add().
- Remove the template series: chart.Series.Remove( templateSeries ).
This sequence of calls results in the colors not being applied properly. I'm thinking that maybe some setting gets cloned that causes this?

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Thu Oct 09, 2008 6:33 pm

One more thought: should I set series.Color to clTeeColor? If so, in which namespace can I find its declaration?

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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

Post by Narcís » Fri Oct 10, 2008 9:04 am

Hi Michal,

Thanks for the information. Could you please send us a simple example project we can run "as-is" to reproduce the problem here?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.
One more thought: should I set series.Color to clTeeColor? If so, in which namespace can I find its declaration?
No, this constant only exists in TeeChart VCL. I think you shouldn't change series.Color.
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

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Fri Oct 10, 2008 8:38 pm

Hi,

I uploaded a sample project - file TeeChartSeriesColorsBug.zip - through the web page.

Run the program, click on "Go", and browse for file pcaplot.ten, included in the ZIP.

I'm looking forward to hearing from you :)

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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 Oct 13, 2008 9:29 am

Hi Michal,

Thanks for the example project.

I think a couple things were missing, setting ColorEach=true for the series and refreshing the chart. Actually, refreshing the chart is not strictly necessary in that case. So, changing your code as shown in the code snippet below works fine for me here.

Code: Select all

                    chart.Import.Template.Load( dlg.FileName );

                    Steema.TeeChart.Themes.ColorPalettes.ApplyPalette( chart.Chart, PlotPalette );

										//Code added by Steema Software
										foreach (Steema.TeeChart.Styles.Series s in chart.Series)
										{
											s.ColorEach = true;
										}
										//chart.Refresh();
										//End code added by Steema Software

										chart.Legend.Shadow.Visible = false;

                    chart.Zoom.Allow = false;
Hope this helps!
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

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Tue Oct 14, 2008 5:47 pm

Hi Narcís,

ColorEach is not what I'm aiming at. I would like that all points in a given series have the same color, but that this color be different for different series.

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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 Oct 15, 2008 9:24 am

Hi Michal,

In that case you need to assign the color from the palette to each series, for example:

Code: Select all

                    chart.Import.Template.Load( dlg.FileName );

										//Steema.TeeChart.Themes.ColorPalettes.ApplyPalette( chart.Chart, PlotPalette );

										//Code added by Steema Software
										for (int i = 0; i < chart.Series.Count; i++)
										{
											if (i < PlotPalette.Length)
											{
												chart[i].Color = PlotPalette[i];	
											}											
										}
										//End code added by Steema Software
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

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Fri Oct 17, 2008 4:47 pm

Hi Narcís,

But this used to happen automatically... So you are saying that now it has to be done manually? (I'm asking because I want to be sure before I go on and modify a whole bunch of code...)

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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

Post by Narcís » Tue Oct 21, 2008 8:42 am

Hi Michal,

Do you know in which exact version it was working before so that I can check it here?

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

Michal Blazejczyk
Newbie
Newbie
Posts: 64
Joined: Fri Jun 16, 2006 12:00 am

Post by Michal Blazejczyk » Tue Oct 21, 2008 3:09 pm

Hi Narcís,

It was 3.2.3016.15521. I just tried it, and it does color the series automatically.

Best,
Michal
Best,
Michal Blazejczyk
Lead Programmer
Genome Quebec

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 Oct 22, 2008 8:03 am

Hi Michal,

Thanks for the information. I've been able to get it working with the version you mentioned so I've added the issue (TF02013474) to the bug list to be fixed for next 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

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 Oct 23, 2008 8:09 am

Hi Michal,

After investigating the issue here we found this is because Clone method was enhanced and now clones series correctly. This means that you need to call ApplyPalette method after series have been added to the chart, for example:

Code: Select all

                        for( int seriesIndex = 0; seriesIndex < 3; ++seriesIndex )
                        {
                            Steema.TeeChart.Styles.Points3D series = templateSeries.Clone() as Steema.TeeChart.Styles.Points3D;

                            // This code is supposed to fix the Clone() that doesn't clone everything.
                            series.Clear();
                            series.LinePen.Visible = false;
                            series.Pointer.Style = templateSeries.Pointer.Style;
                            series.Pointer.HorizSize = templateSeries.Pointer.HorizSize;
                            series.Pointer.VertSize = templateSeries.Pointer.VertSize;
                            series.Pointer.Pen.Visible = templateSeries.Pointer.Pen.Visible;
                            series.ShowInLegend = true;

                            series.Marks.Transparent = templateSeries.Marks.Transparent;
                            series.Marks.Shadow.Visible = templateSeries.Marks.Shadow.Visible;
                            series.Marks.Arrow.Visible = templateSeries.Marks.Arrow.Visible;
                            series.Marks.Arrow.Color = templateSeries.Marks.Arrow.Color;
                            series.Marks.ArrowLength = templateSeries.Marks.ArrowLength;

                            chart.Series.Add( series );
														Steema.TeeChart.Themes.ColorPalettes.ApplyPalette(chart.Chart, PlotPalette);

                            series.Add( dataX[ seriesIndex ], dataY[ seriesIndex ], dataZ[ seriesIndex ] );
                        }
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