TeeChart。在甘特系列的顶部绘制网格线
TeeChart. Draw grid lines on the top of Gantt series
我正在使用甘特图系列在图表上显示区域。问题是该系列绘制在图表网格的顶部。
我想在网格顶部绘制法线系列,在其后面绘制甘特图系列。如果没有 OnAfterDraw,是否可以使用标准的 TChart 功能?
您可以在 OnBeforeDrawAxes
处绘制 TGanttSeries
,然后在 OnBeforeDrawSeries
处将其隐藏,最后在 OnAfterDraw
处再次显示以用于下一个绘制周期:
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TGanttSeries;
Series2: TLineSeries;
procedure FormCreate(Sender: TObject);
procedure Chart1BeforeDrawAxes(Sender: TObject);
procedure Chart1BeforeDrawSeries(Sender: TObject);
procedure Chart1AfterDraw(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type TCustomSeriesAccess=class(TCustomSeries);
procedure TForm1.Chart1BeforeDrawAxes(Sender: TObject);
begin
TCustomSeriesAccess(Series1).DrawAllValues;
end;
procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
begin
Series1.Visible:=False;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
Series1.Visible:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Draw;
end;
我正在使用甘特图系列在图表上显示区域。问题是该系列绘制在图表网格的顶部。
我想在网格顶部绘制法线系列,在其后面绘制甘特图系列。如果没有 OnAfterDraw,是否可以使用标准的 TChart 功能?
您可以在 OnBeforeDrawAxes
处绘制 TGanttSeries
,然后在 OnBeforeDrawSeries
处将其隐藏,最后在 OnAfterDraw
处再次显示以用于下一个绘制周期:
type
TForm1 = class(TForm)
Chart1: TChart;
Series1: TGanttSeries;
Series2: TLineSeries;
procedure FormCreate(Sender: TObject);
procedure Chart1BeforeDrawAxes(Sender: TObject);
procedure Chart1BeforeDrawSeries(Sender: TObject);
procedure Chart1AfterDraw(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type TCustomSeriesAccess=class(TCustomSeries);
procedure TForm1.Chart1BeforeDrawAxes(Sender: TObject);
begin
TCustomSeriesAccess(Series1).DrawAllValues;
end;
procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
begin
Series1.Visible:=False;
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
Series1.Visible:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.Draw;
end;