Page 1 of 1

Mark Text not persisted when assign to another chart

Posted: Wed Mar 02, 2005 7:29 pm
by 9333098
I'm assigning a chart to another temporary invisible chart for printing from. I've changed the main chart's mark's text in OnGetMarkText. The original, not the changed text, is what is printed from the second chart.

Is there a way to access the actual mark's text and assign that to the new chart ? Perhaps expose the second chart's series OnGetMarkText event and change it there or access the second chart's mark's DrawText method ? Or create the second chart then change its mark text from the main chart's series OnGetMarkText event ?

Steve

Posted: Thu Mar 03, 2005 12:00 pm
by narcis
Hi Steve,

You have to do it "manually". One easy way to do this is assigning the cloned series OnGetMarkText event to the original series event like shown below.

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  i: integer;
begin
  Series1.FillSampleValues();

  InvChart.FreeAllSeries;
  InvChart.Assign(Chart1);
  for i:=0 to Chart1.SeriesCount-1 do
    begin
      CloneChartSeries(Chart1[i]).ParentChart:=InvChart;
      InvChart[i].OnGetMarkText:=Chart1[i].OnGetMarkText;
    end;
end;

procedure TForm1.Series1GetMarkText(Sender: TChartSeries;
  ValueIndex: Integer; var MarkText: String);
begin
  MarkText:='Mark '+IntToStr(ValueIndex);
end;