Chart component related
Q: How can I change the type of a Series programmatically?
DELPHI CODE: Var MySeries:TChartSeries; MySeries:=Series1; ChangeSeriesType( MySeries, TBarSeries ); CBUILDER CODE: ChangeSeriesType( Series1, __classid(TBarSeries) ); Q: How to copy a Chart onto another Chart ?
DELPHI CODE: procedure TForm1.BitBtn1Click(Sender: TObject); var t:Integer; begin With Form2 do begin Chart2.FreeAllSeries; Chart2.Assign(Self.Chart1); { duplicate the Series and values } for t:=0 to Self.Chart1.SeriesCount-1 do CloneChartSeries(Self.Chart1[t]).ParentChart:=Chart2; Show; end; end; CBUILDER CODE: void __fastcall TForm1::BitBtn1Click(TObject *Sender) { Form2->Chart2->FreeAllSeries(); Form2->Chart2->Assign(this->Chart1); duplicate the Series and values for (int t=0;t<=this->Chart1->SeriesCount()-1;t++) CloneChartSeries(this->Chart1->Series[t])->ParentChart=Form2->Chart2; Form2->Show(); } Q: How to clear the Chart BackImage background picture ?
DELPHI CODE: Chart1.BackImage.Assign(nil); CBUILDER CODE: Chart1->BackImage->Assign(NULL); (Contributed by Manolis Afentakis)Q: How to save Chart definitions to file and load Chart definitions from file?Use the TeeStore.pas unit and the methods LoadChartFromFile... SaveChartToFile: DELPHI CODE: Uses TeeStore; procedure TForm1.BtnSaveClick(Sender: TObject); begin SaveChartToFile(Chart1,'c:\temp\test.tee'); end; procedure TForm1.BtnLoadClick(Sender: TObject); var tmpChart:TCustomChart; begin Chart1.Free; //assuming Chart1 is already on the Form tmpChart:=TChart.Create(Self); LoadChartfromFile(tmpChart,'c:\temp\test.tee); Chart1 := tmpChart as TChart; Chart1.Parent:=Self; end; |