Series marks with semi-transparent background

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
EdDressel
Newbie
Newbie
Posts: 32
Joined: Mon Dec 10, 2018 12:00 am

Series marks with semi-transparent background

Post by EdDressel » Mon Nov 04, 2019 9:00 pm

I would like to add a semi-transparent background to some marks on a chart, but keep the font non-transparent. The only setting I find for this is Series.Marks.Transparency, but it does both the background and the font.

Can this be achieved?

Thank you,

Ed Dressel
Thanks,

Ed Dressel

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

Re: Series marks with semi-transparent background

Post by Yeray » Fri Nov 08, 2019 1:56 pm

Hello,

You could use events to draw the brush with transparency and draw the marks without brush later:

Code: Select all

uses Series;

type TChartSeriesAccess=class(TChartSeries);

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=False;
  Chart1.Legend.Hide;

  with TBarSeries(Chart1.AddSeries(TBarSeries)) do
  begin
    Marks.Shadow.Hide;
    Marks.Transparency:=50;

    FillSampleValues;
  end;

  Chart1.OnBeforeDrawSeries:=SeriesBeforeDraw;
  Chart1.OnAfterDraw:=ChartAfterDraw;
end;

procedure TForm1.SeriesBeforeDraw(Sender: TObject);
begin
  if (Chart1.SeriesCount>0) and (Chart1[0] is TBarSeries) then
  begin
    with TBarSeries(Chart1[0]) do
    begin
      Marks.Brush.Style:=bsSolid;
      Marks.Transparency:=50;
      Marks.Pen.Hide;
      Marks.Font.Color:=clNone;
    end;
  end;
end;

procedure TForm1.ChartAfterDraw(Sender: TObject);
begin
  if (Chart1.SeriesCount>0) and (Chart1[0] is TBarSeries) then
    with TBarSeries(Chart1[0]) do
    begin
      Marks.Transparency:=0;
      Marks.Brush.Clear;
      Marks.Pen.Show;
      Marks.Font.Color:=clBlack;
      TChartSeriesAccess(Chart1[0]).DrawMarks;
    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