Page 1 of 1

THighLow & Smoothing

Posted: Fri Oct 15, 2010 10:31 am
by 10552947
Is there an option to get a highlow bar with smoothed low and smooth high curve automatically without adding more points??
Right now the dark red highlow it's not smooth at all (see example)
example.jpg
example.jpg (73.27 KiB) Viewed 2876 times
Cheers
Karsten

BCB5 & TChart 8.04 VCL

Re: THighLow & Smoothing

Posted: Mon Oct 18, 2010 1:49 pm
by 10050769
Hello Karsten,

Sorry for the delay. I recommend three options for solve your problem:
  • - Using GDI+ canvas, you can find an example in Demo of TeeChartVCL, concretely in Canvas/GDI+Canvas.
    - Using AntiAlias canvas, you find an example in Demo Canavas/AntiAlias
    - Using Tool Anti-Alias. There is an example to Tools/AntiAlias Filter in Demo Project of TeeCharVCL
I hope will helps.

Thanks,

Re: THighLow & Smoothing

Posted: Mon Oct 18, 2010 2:16 pm
by yeray
Hi Karsten,

Another option could be using 2 TSmoothing functions, one for the High Line and one for the Low line. The Smoothing function, however, uses more points internally.
Here it is an example:

Code: Select all

uses Series, ErrorBar, TeeSpline, TeeSeriesBandTool;

procedure TForm1.FormCreate(Sender: TObject);
var HighLow: THighLowSeries;
    Fast1, Fast2, dummy: TFastLineSeries;
    Smooth1, Smooth2: TSmoothingFunction;
    SeriesBand1: TSeriesBandTool;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  HighLow:=Chart1.AddSeries(THighLowSeries) as THighLowSeries;
  HighLow.FillSampleValues();
  HighLow.Brush.Style:=bsSolid;

  Smooth1:=TSmoothingFunction.Create(self);
  Smooth2:=TSmoothingFunction.Create(self);

  Fast1:=Chart1.AddSeries(TFastLineSeries) as TFastLineSeries;
  Fast2:=Chart1.AddSeries(TFastLineSeries) as TFastLineSeries;
  dummy:=TFastLineSeries.Create(self);
  Fast1.FunctionType:=Smooth1;
  Fast2.FunctionType:=Smooth2;
  Fast1.Color:=clBlack;
  Fast2.Color:=clBlack;

  dummy.XValues.Value:=HighLow.XValues.Value;
  dummy.YValues.Value:=HighLow.LowValues.Value;
  dummy.XValues.Count:=HighLow.XValues.Count;
  dummy.YValues.Count:=HighLow.YValues.Count;

  Fast1.DataSource:=HighLow;
  Fast2.DataSource:=dummy;

  HighLow.Active:=false;

  SeriesBand1:=Chart1.Tools.Add(TSeriesBandTool) as TSeriesBandTool;
  SeriesBand1.Series:=Fast1;
  SeriesBand1.Series2:=Fast2;
  SeriesBand1.Brush.BackColor:=HighLow.Color;
end;