|
Solution:
|
The whole
trick of AddNull (or AddNullXY) method is they set value's color to clNone (see the
AddNull and AddNullXY function definition bellow): Function TChartSeries.AddNull(Const ALabel:String):Longint;
begin
result:=Add( 0, ALabel, clNone );
end;
Function TChartSeries.AddNullXY(Const X,Y:Double; Const
ALabel:String):Longint;
begin
result:=AddXY(X,Y,ALabel,clNone );
end;
The TFastLineSeries.DrawValue method draws all point with the
same color and therefore all points are drawn in SeriesColor. The solution is (again) to
override DrawValue method and differentiate between "normal"
(ValueColor<>clNone) and "null" (ValueColor:=clNone) points.
procedure TMyFastLineSeries.DrawValue(ValueIndex:LongInt);
Var X : Longint;
Y : Longint;
tmpX : Longint;
tmpY : Longint;
tmp3D : Boolean;
tmpC : TColor;
Begin
X:=CalcXPos(ValueIndex);
Y:=CalcYPos(ValueIndex);
tmpColor:=ValueColor[ValueIndex];
tmp3D:=ParentChart.View3D;
// the whole trick of null value is it's Color=clNone
if (OldColor=clNone) or (tmpColor=clNone) then
begin
OldX:=X;
OldY:=Y;
end;
With ParentChart.Canvas do
begin
if ValueIndex=FirstValueIndex then
if (ValueIndex>0) then
begin
tmpX:=CalcXPos(ValueIndex-1);
tmpY:=CalcYPos(ValueIndex-1);
tmpC:=ValueColor[ValueIndex-1];
if (tmpColor=clNone) or (tmpC=clNone) then
if tmp3D then MoveTo3D(X,Y,MiddleZ) else MoveTo(X,Y)
else
if tmp3D then LineWithZ(tmpX,tmpY,X,Y,MiddleZ)
else Line(tmpX,tmpY,X,Y)
end
else
if tmp3D then MoveTo3D(X,Y,MiddleZ) else MoveTo(X,Y)
else
if (X<>OldX) or (Y<>OldY) then
if tmp3D then LineTo3D(X,Y,MiddleZ) else LineTo(X,Y)
else
begin
MoveTo(X,Y);
OldColor:=tmpColor;
Exit;
end
end;
OldX:=X;
OldY:=Y;
OldColor:=tmpColor;
End;
|