Page 1 of 1

Cloned chart axis label color problem

Posted: Mon Jan 04, 2010 6:24 pm
by 10049005
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.

Re: Cloned chart axis label color problem

Posted: Tue Jan 05, 2010 2:35 pm
by yeray
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?

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;

Re: Cloned chart axis label color problem

Posted: Tue Jan 05, 2010 7:02 pm
by 10049005
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;

Re: Cloned chart axis label color problem

Posted: Thu Jan 07, 2010 1:05 pm
by yeray
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.