Can Teechart use Cylinder Candle series?
customize every cylinder color (use Gradient)
How to implement this function?
JoJo
Candle series question
Candle series question
- Attachments
-
- K_Bar.png (2.23 KiB) Viewed 1737 times
Re: Candle series question
Hi JoJo,
I'm afraid that this style isn't available for TCandleSeries. Right now, you could use TBar3DSeries and draw the two vertical lines with custom drawing techniques. For example:
I'm afraid that this style isn't available for TCandleSeries. Right now, you could use TBar3DSeries and draw the two vertical lines with custom drawing techniques. For example:
Code: Select all
uses TeCanvas;
const nValues=5;
var CandleDates, CandleClose, CandleHigh, CandleLow, CandleOpen: array of double;
procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
tmp: double;
StartX: TDateTime;
begin
SetLength(CandleDates, nValues);
SetLength(CandleClose, nValues);
SetLength(CandleHigh, nValues);
SetLength(CandleLow, nValues);
SetLength(CandleOpen, nValues);
Series1.XValues.DateTime:=true;
Series1.BarStyle:=bsCilinder;
Series1.Marks.Visible:=false;
Series1.Pen.Visible:=false;
StartX:=Now;
for i:=0 to nValues-1 do
begin
CandleDates[i]:=StartX-nValues+i+1;
CandleClose[i]:=random*25;
CandleHigh[i]:=random*25+25;
CandleLow[i]:=random*25+50;
CandleOpen[i]:=random*25+75;
end;
With Series1.XValues do
begin
Value:=TChartValues(CandleDates);
Count:=nValues;
Modified:=True;
end;
With Series1.YValues do
begin
Value:=TChartValues(CandleLow);
Count:=nValues;
Modified:=True;
end;
With Series1.OffsetValues do
begin
Value:=TChartValues(CandleHigh);
Count:=nValues;
Modified:=True;
end;
Chart1.Axes.Left.SetMinMax(0,100);
Chart1.Chart3DPercent:=100;
Chart1.Aspect.Orthogonal:=false;
Chart1.Legend.Visible:=false;
end;
procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
var i: Integer;
begin
for i:=0 to Chart1[0].Count-1 do
DrawLine(Chart1[0].XValue[i], CandleHigh[i], CandleClose[i]);
end;
procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i: Integer;
begin
for i:=0 to Chart1[0].Count-1 do
DrawLine(Chart1[0].XValue[i], CandleLow[i], CandleOpen[i]);
end;
procedure TForm1.DrawLine(XVal, YStartVal, YEndVal: double);
var XPos, Y0Pos, Y1Pos: Integer;
tmpPoints: TPointArray;
begin
SetLength(tmpPoints,2);
XPos:=Chart1.Axes.Bottom.CalcXPosValue(XVal);
Y0Pos:=Chart1.Axes.Left.CalcYPosValue(YStartVal);
Y1Pos:=Chart1.Axes.Left.CalcYPosValue(YEndVal);
Chart1.Canvas.Pen.Color:=Chart1[0].Color;
tmpPoints[0]:=Point(XPos,Y0Pos);
tmpPoints[1]:=Point(XPos,Y1Pos);
tmpPoints:=Chart1.Canvas.Calc3DPoints(tmpPoints,(Chart1[0].EndZ - Chart1[0].StartZ) div 2);
Chart1.Canvas.Line(tmpPoints[0],tmpPoints[1]);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |