Hello Uli,
UliBru wrote:THorizLineSeries seems not to work properly.
This is what I get with TeeChart v2017.22 and the code below:
- Project2_2017-07-12_08-24-01.png (13.76 KiB) Viewed 10994 times
Code: Select all
uses Series;
var Series1, Series2: THorizLineSeries;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=False;
Series1:=Chart1.AddSeries(THorizLineSeries) as THorizLineSeries;
Series2:=Chart1.AddSeries(THorizLineSeries) as THorizLineSeries;
Chart1.Axes.Bottom.Logarithmic := true;
Chart1.Axes.Bottom.SetMinMax(10, 10000);
Chart1.Axes.Left.SetMinMax(-6, 6);
Series1.Pointer.Visible := true;
Series2.DataSource := Series1;
Series2.Color := clRed;
Series1.Clear;
Series1.AddXY(10,2,'',clTeeColor);
Series1.AddXY(32,2,'',clTeeColor);
Series1.AddXY(600,2.5,'',clTeeColor);
Series1.AddXY(1000,0,'',clTeeColor);
Series1.AddXY(2000,-2,'',clTeeColor);
Series1.AddXY(8000,-1.5,'',clTeeColor);
Series1.AddXY(10000,-1.5,'',clTeeColor);
Series2.CheckDataSource;
Series2.Smoothed := true;
end;
UliBru wrote:Code: Select all
Series2.XValues.Order:=loNone;
Series2.HasZValues:=True;
seems to work.
But adding e.g. another point by
Code: Select all
Series1.AddXY(1300,-1.2,'',clTeeColor);
between X=1000 and X=2000 (is ascending X sequence) creates a picture like
So the smoothing seems to have some tendency for oscillations.
I'm not sure why this is happening but it seems the BSpline is giving a different result when using those series values and when transforming those values to screen pixels.
You can use the TBSpline as follows to use pixel values, transform the result back to axis values to add them into Series2:
- Project2_2017-07-12_10-33-47.png (13.94 KiB) Viewed 10994 times
Code: Select all
uses Series, TeeSpLine;
var Series1, Series2: TLineSeries;
procedure TForm1.FormCreate(Sender: TObject);
var BSpline : TBSpline;
i: Integer;
ParameterValue : single;
V : TVertex;
begin
Chart1.View3D:=False;
Series1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
Series2:=Chart1.AddSeries(TLineSeries) as TLineSeries;
Chart1.Axes.Bottom.Logarithmic := true;
Chart1.Axes.Bottom.SetMinMax(10, 10000);
Chart1.Axes.Left.SetMinMax(-6, 6);
Series1.Pointer.Visible := true;
Series1.AddXY(10,2,'',clTeeColor);
Series1.AddXY(32,2,'',clTeeColor);
Series1.AddXY(600,2.5,'',clTeeColor);
Series1.AddXY(1000,0,'',clTeeColor);
Series1.AddXY(1300,-1.2,'',clTeeColor);
Series1.AddXY(2000,-2,'',clTeeColor);
Series1.AddXY(8000,-1.5,'',clTeeColor);
Series1.AddXY(10000,-1.5,'',clTeeColor);
Chart1.Draw;
BSpline:=TBSpline.Create;
for i:=0 to Series1.Count-1 do
BSpline.AddPoint(Series1.CalcXPos(i), Series1.CalcYPos(i));
BSpline.Interpolated:=True;
BSpline.Fragments:=64;
Series2.Color:=clRed;
Series2.XValues.Order:=loNone;
For i:=0 to BSpline.Fragments do
begin
ParameterValue:=(i/BSpline.Fragments);
V:=BSpline.Value(ParameterValue);
with Series2 do
AddXY(GetHorizAxis.CalcPosPoint(Round(V.X)),GetVertAxis.CalcPosPoint(Round(V.Y)));
end;
end;;