Hello,
with TeeChart 8.06 / Delphi2010 / Windows XP I am having this problem:
- clone a chart
- Axis label color always goes to black on the cloned chart (I might be able to live with that, but see next issue)
- Cannot change the cloned axis label color by using code (LeftAxis.LabelsFont.Color := ... ) or with the TChartEditor. The editor shows the color change, but on the screen the font shows black.
Can you please give me a way to get the label color changed on the cloned chart. An example set of colors that I need to work with include: chart panel of Black, axis label font color of white.
Thanks,
Dan
p.s. I am cloning the chart by using Chart.Assign(source chart) . It appears that the problem is associated with the assigning of the Axes - if no Chart Assigning is done, the properties can be manipulated. However, Assigning the source chart or some equivalent is the preferred approach; many complex charts would otherwise have to be built by hand.
Cloned chart axis label color problem
Re: Cloned chart axis label color problem
Hi Dan,
I'm trying to reproduce the problem but I can't with the following code. Could you please modify it until we can reproduce the problem here?
I'm trying to reproduce the problem but I can't with the following code. Could you please modify it until we can reproduce the problem here?
Code: Select all
uses series;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.AddSeries(TLineSeries.Create(self));
Chart1[0].FillSampleValues();
Chart1.Left:=400;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
with TChart.Create(self) do
begin
Parent:=Form1;
Assign(Chart1);
AddSeries(TPointSeries.Create(self));
Series[0].FillSampleValues();
Axes.Left.LabelsFont.Color:=clWhite;
end;
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Cloned chart axis label color problem
Thanks, Yeray
Here is my version of your code. The most significant difference is that I am cloning the series from the source existing chart.
It is also necessary to repeatedly re-set the cloned chart each time the source chart changes. I do that by destroying the clone and re-creating.
In our testing, it seems that the Assign of the chart is where the problem begins - usually we can get different results by using, or not using Assign although we need to use Assign or some equivalent if possible.
Under just the right the circumstances I can control the labelsfont color on the first time only. (see notes)
Often you can see the assigned color in the chart editor, but it displays black in the chart itself.
My final solution must work for DBCharts as well.
Thanks, Dan.
private
FChartNew : TChart;
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
begin
// if not Assigned(FChartNew) then
// begin
// ChartSource.AddSeries(TPointSeries.Create(self));
// ChartSource.Series[0].FillSampleValues();
// end;
if Assigned(FChartNew) then
FreeAndNil(FChartNew);
FChartNew := TChart.Create(Self);
FChartNew.Parent := Self;
FChartNew.Width := ChartSource.Width;
FChartNew.Height := ChartSource.Height;
FChartNew.Top := ChartSource.Top + ChartSource.Height;
FChartNew.Assign(ChartSource); {Assign seems to be a significant part of the problem}
FChartNew.Legend.Visible := False;
For i := 0 to ChartSource.SeriesCount - 1 do
begin
CloneChartSeries(ChartSource.Series).ParentChart := FChartNew;
FChartNew.Series.DataSource := ChartSource.Series;
end;
FChartNew.LeftAxis.LabelsFont.Color := clRed; {may display properly only the first time - see FormCreate}
FChartNew.BottomAxis.LabelsFont.Color := clRed;
{If done with bar series, the grid and left axis may also be incomplete}
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{if the series are added here, the label font color will fail each time. Also if created in the IDE.
if added on the button click, will fail only on the second time}
ChartSource.AddSeries(TPointSeries.Create(self));
ChartSource.Series[0].FillSampleValues();
end;
Here is my version of your code. The most significant difference is that I am cloning the series from the source existing chart.
It is also necessary to repeatedly re-set the cloned chart each time the source chart changes. I do that by destroying the clone and re-creating.
In our testing, it seems that the Assign of the chart is where the problem begins - usually we can get different results by using, or not using Assign although we need to use Assign or some equivalent if possible.
Under just the right the circumstances I can control the labelsfont color on the first time only. (see notes)
Often you can see the assigned color in the chart editor, but it displays black in the chart itself.
My final solution must work for DBCharts as well.
Thanks, Dan.
private
FChartNew : TChart;
procedure TForm1.Button1Click(Sender: TObject);
var
i : Integer;
begin
// if not Assigned(FChartNew) then
// begin
// ChartSource.AddSeries(TPointSeries.Create(self));
// ChartSource.Series[0].FillSampleValues();
// end;
if Assigned(FChartNew) then
FreeAndNil(FChartNew);
FChartNew := TChart.Create(Self);
FChartNew.Parent := Self;
FChartNew.Width := ChartSource.Width;
FChartNew.Height := ChartSource.Height;
FChartNew.Top := ChartSource.Top + ChartSource.Height;
FChartNew.Assign(ChartSource); {Assign seems to be a significant part of the problem}
FChartNew.Legend.Visible := False;
For i := 0 to ChartSource.SeriesCount - 1 do
begin
CloneChartSeries(ChartSource.Series).ParentChart := FChartNew;
FChartNew.Series.DataSource := ChartSource.Series;
end;
FChartNew.LeftAxis.LabelsFont.Color := clRed; {may display properly only the first time - see FormCreate}
FChartNew.BottomAxis.LabelsFont.Color := clRed;
{If done with bar series, the grid and left axis may also be incomplete}
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
{if the series are added here, the label font color will fail each time. Also if created in the IDE.
if added on the button click, will fail only on the second time}
ChartSource.AddSeries(TPointSeries.Create(self));
ChartSource.Series[0].FillSampleValues();
end;
Re: Cloned chart axis label color problem
Hi Dan,
I could reproduce the problem with the v8.06 but noticed that it seems to fork fine with the latest sources. So the next v8 maintenance release should fix it.
I could reproduce the problem with the v8.06 but noticed that it seems to fork fine with the latest sources. So the next v8 maintenance release should fix it.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |