Marks not working as expected with TChartShapes

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Charlie SEI
Newbie
Newbie
Posts: 11
Joined: Thu Dec 05, 2019 12:00 am

Marks not working as expected with TChartShapes

Post by Charlie SEI » Tue Jan 14, 2020 7:05 pm

Hi!

I am making a chart using TChartShapes to create a Marginal Abatement Cost Curves (a series of rectangles showing costs and avoided carbon dioxide for a range of different measures). Its a pretty standard type of chart in my field. TChartShape series seemed like the best way to do this and they generally work very nicely.

However, I would like to label each block using Marks but TeeChart insists on showing two marks for each shape at two corners of each shape. See attached picture.

Can you offer some advice on how to fix this problem? Many thanks in advance.

I'm using Delphi 10.3.3 (32-bit) in Windows 10 using VCL version of TeeChart Pro v2019.27.

Below is code to demonstrate problem:

Code: Select all

procedure TForm19.MACCBtnClick(Sender: TObject);

var
  Series: TChartShape;

  procedure _AddSer(x0, x1, y0, y1: double; name: string);

  begin

    Series := TChartShape.Create(Chart1);
    Series.Style := chasRectangle;
    Series.Title := name;
    Series.x0 := x0;
    Series.x1 := x1;
    Series.y0 := y0;
    Series.y1 := y1;
    Series.Color := clTeeColor; 
    Series.ColorEachPoint := true;
    Series.Pen.Color := clGray;
    Series.Pen.Visible := false;
    Series.Marks.Style :=  smsLabelOrValue; 
    Series.Marks.Visible := true;  //Shows 2 marks per shape
    Chart1.AddSeries(Series);
  end;

begin
  Chart1.Axes.Left.Minimum := -500;
  Chart1.Axes.Left.Maximum := 500;
  Chart1.Axes.Bottom.Minimum := 0;
  Chart1.Axes.Bottom.Maximum := 100000;
  Chart1.FreeAllSeries;
  _AddSer(0, 2000, 0, -400, 'Methane Leaks');
  _AddSer(2001, 5000, 0, -200, 'Forestry');
  _AddSer(5001, 8000, 0, -30, 'Efficient AC');
  _AddSer(8001, 20000, 0, 40, 'Efficient Motors');
  _AddSer(20001, 30000, 0, 50, 'Wind');
  _AddSer(30001, 70000, 0, 350, 'Solar');
  _AddSer(70001, 80000, 0, 370, 'Carnon Capture and Storage');
  _AddSer(80001, 100000, 0, 450, 'Electric Vehicles');
end;
Attachments
MACC Curve using shape chart.jpg
MACC Curve using shape chart.jpg (63.12 KiB) Viewed 13851 times

Charlie SEI
Newbie
Newbie
Posts: 11
Joined: Thu Dec 05, 2019 12:00 am

Re: Marks not working as expected with TChartShapes

Post by Charlie SEI » Fri Jan 24, 2020 5:15 pm

Does anyone from STEEMA review or respond to messages on this forum?

Marc
Site Admin
Site Admin
Posts: 1272
Joined: Thu Oct 16, 2003 4:00 am
Location: Girona
Contact:

Re: Marks not working as expected with TChartShapes

Post by Marc » Thu Jan 30, 2020 3:06 pm

Hello,

Sorry for the delay with this reply.

You could set the text for the shape and leave Marks.Visible False.

eg.

Code: Select all

Series.Font.Color := clWhite;
Series.Text.Add('my text');
Regards,
Marc Meumann
Steema Support

Post Reply