Page 1 of 1

Palette no longer applied by default to new series

Posted: Wed Oct 08, 2008 8:46 pm
by 9641603
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

Posted: Thu Oct 09, 2008 8:31 am
by narcis
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.

Posted: Thu Oct 09, 2008 6:29 pm
by 9641603
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

Posted: Thu Oct 09, 2008 6:33 pm
by 9641603
One more thought: should I set series.Color to clTeeColor? If so, in which namespace can I find its declaration?

Best,
Michal

Posted: Fri Oct 10, 2008 9:04 am
by narcis
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.

Posted: Fri Oct 10, 2008 8:38 pm
by 9641603
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

Posted: Mon Oct 13, 2008 9:29 am
by narcis
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!

Posted: Tue Oct 14, 2008 5:47 pm
by 9641603
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

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

Posted: Fri Oct 17, 2008 4:47 pm
by 9641603
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

Posted: Tue Oct 21, 2008 8:42 am
by narcis
Hi Michal,

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

Thanks in advance.

Posted: Tue Oct 21, 2008 3:09 pm
by 9641603
Hi Narcís,

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

Best,
Michal

Posted: Wed Oct 22, 2008 8:03 am
by narcis
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.

Posted: Thu Oct 23, 2008 8:09 am
by narcis
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 ] );
                        }