Registriert seit: 6. Apr 2005
10.109 Beiträge
|
Re: TChart werte anzeigen
19. Sep 2005, 10:33
Hallo René,
ich würde es ungefähr so machen:
Delphi-Quellcode:
interface
...
type
TMainForm = class(TForm)
TheChart: TChart;
ActionButton: TButton;
procedure FormCreate(Sender: TObject);
private
procedure ActionButtonClick(Sender: TObject);
procedure AppShowHint(var HintStr: string; var CanShow: boolean; var HintInfo: THintInfo);
end;
var
MainForm: TMainForm;
implementation
{$R *.dfm}
procedure TMainForm.ActionButtonClick(Sender: TObject);
var
bs: TBarSeries;
i: integer;
begin
bs := TBarSeries.Create(myChart);
TheChart.AddSeries(bs);
with bs do begin
Add(40, 'labelA', clRed);
Add(50, 'labelB', clGreen);
Add(70, 'labelC', clBlue);
Add(30, 'labelD', clYellow);
end;
with bs do
for i := 0 to Count - 1 do
XLabel[i] := IntToStr(i * 100);
end;
procedure TMainForm.FormCreate(Sender: TObject);
begin
Application.OnShowHint := AppShowHint;
end;
procedure TMainForm.AppShowHint(var HintStr: string; var CanShow: boolean;
var HintInfo: THintInfo);
var
part: TChartClickedPart;
index: integer;
c: TChart;
cs: TChartSeries;
begin
if (hintinfo.HintControl is TChart) then
begin
c := TChart(HintInfo.HintControl);
c.CalcClickedPart(HintInfo.CursorPos, part);
if Assigned(part.ASeries) then begin
cs := part.ASeries;
index := cs.GetCursorValueIndex;
if index >= 0 then
HintStr := cs.YValueToText(cs.YValues[index]);
HintInfo.ReshowTimeout := 50;
end;
end;
end;
end.
Grüße vom marabu
ValueMarkText() durch YValueToText() ersetzt
|
|
Zitat
|