OHLC transparency problem

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
sswang
Newbie
Newbie
Posts: 24
Joined: Wed Mar 28, 2012 12:00 am

OHLC transparency problem

Post by sswang » Wed Mar 11, 2015 1:28 am

Hi,

I'm trying to enable transparency property of OHLC,
but seeing unexpected Hi-Low line reveal in the center of candle. (pic. attached)

How can I keep a "plain transparency" without seeing the middle part of the line in the candle body?
I'm a source user, please advice if source modification is required. Thanks!
Attachments
OHLC.png
OHLC.png (25.6 KiB) Viewed 4600 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: OHLC transparency problem

Post by Yeray » Wed Mar 11, 2015 11:52 am

Hello,

I'm afraid in this case you should draw the lines manually. Ie:

Code: Select all

uses Math;

var Series1: TCandleSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  Series1:=Chart1.AddSeries(TCandleSeries) as TCandleSeries;
  Series1.UpCloseColor:=RGB(29, 123, 99);
  Series1.FillSampleValues();
  Series1.HighLowPen.Visible:=false;
  Series1.HighLowColor:=cbSameAsCandle;
  Series1.Transparency:=50;

  Series1.OnGetPointerStyle:=Series1GetPointerStyle;
end;

function TForm1.Series1GetPointerStyle(Sender: TChartSeries;
  ValueIndex: Integer): TSeriesPointerStyle;
var tmpX, tmpOpen, tmpClose, tmpHigh, tmpLow: Integer;

  procedure drawLine(FromY: Integer);
  var ToY: Integer;
  begin
    ToY:=Min(tmpOpen, tmpClose);
    if (FromY<ToY) then
    begin
      if Sender.ParentChart.View3D then
        Sender.ParentChart.Canvas.VertLine3D(tmpX,FromY,ToY,Sender.MiddleZ)
      else
        Sender.ParentChart.Canvas.DoVertLine(tmpX,FromY,ToY);
    end
    else
    begin
      ToY:=Max(tmpOpen, tmpClose);
      if (FromY>ToY) then
        if Sender.ParentChart.View3D then
          Sender.ParentChart.Canvas.VertLine3D(tmpX,FromY,ToY,Sender.MiddleZ)
        else
          Sender.ParentChart.Canvas.DoVertLine(tmpX,FromY,ToY);
    end;
  end;

begin
  if (Sender is TCandleSeries) and (ValueIndex>-1) and (ValueIndex<Sender.Count) then
  begin
    with (Sender as TCandleSeries) do
    begin
      tmpX:=CalcXPos(ValueIndex);
      tmpOpen:=CalcYPosValue(OpenValues[ValueIndex]);
      tmpClose:=CalcYPosValue(CloseValues[ValueIndex]);
      tmpHigh:=CalcYPosValue(HighValues[ValueIndex]);
      tmpLow:=CalcYPosValue(LowValues[ValueIndex]);

      if HighLowColor=cbUseColor then
        if HighLowPen.Color=clTeeColor then
          Chart1.Canvas.Pen.Color:=Pen.Color
        else
          Chart1.Canvas.Pen.Color:=HighLowPen.Color
      else
        if tmpOpen<tmpClose then
          Chart1.Canvas.Pen.Color:=DownCloseColor
        else
          Chart1.Canvas.Pen.Color:=UpCloseColor;

      drawLine(tmpHigh);
      drawLine(tmpLow);
    end;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply