TSquarifiedMapSeries Add values

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Merops
Newbie
Newbie
Posts: 4
Joined: Thu Nov 14, 2024 12:00 am

TSquarifiedMapSeries Add values

Post by Merops » Thu Dec 12, 2024 8:30 pm

Hi,

I am trying to add values ​​in TSquarifiedMapSeries.

Code: Select all

Series1: TSquarifiedMapSeries;
....

   Series1.Add(500,'Value1',clGreen);
   Series1.Add(250,'Value2',clBlue);
But the graph remains empty, do you have an example?

Thanks for your help.

Franck,

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

Re: TSquarifiedMapSeries Add values

Post by Yeray » Fri Dec 13, 2024 8:06 am

Hello,

Sure, here you have a simple example:

Code: Select all

uses Chart, TeeSquarifiedMap;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
var t : Integer;
const numValues=10;
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;
  Chart1.Align:=alClient;
  Chart1.View3D:=False;

  with TSquarifiedMapSeries(Chart1.AddSeries(TSquarifiedMapSeries)) do
  begin
    // Add the top-most item
    AddItem(-1,0,'Root');

    // Add children
    for t:=0 to numValues-1 do
        AddItem(0,Random(1000),IntToStr(t));

    FinishData;
  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

Merops
Newbie
Newbie
Posts: 4
Joined: Thu Nov 14, 2024 12:00 am

Re: TSquarifiedMapSeries Add values

Post by Merops » Fri Dec 13, 2024 4:11 pm

Hi Yeray,

Thanks ;-)
Capture d’écran 2024-12-13 170414.png
Capture d’écran 2024-12-13 170414.png (93.57 KiB) Viewed 5297 times
Best regards,

Merops
Newbie
Newbie
Posts: 4
Joined: Thu Nov 14, 2024 12:00 am

Re: TSquarifiedMapSeries Add values

Post by Merops » Fri Dec 13, 2024 5:40 pm

Do you know how to remove the "Root" element from the legend ? It distorts the display of the % .

I have 30% and 20% instead of 60% and 40%:
Capture d’écran 2024-12-13 183908.png
Capture d’écran 2024-12-13 183908.png (11.73 KiB) Viewed 5280 times
Thanks,

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

Re: TSquarifiedMapSeries Add values

Post by Yeray » Mon Dec 16, 2024 7:48 am

Hello,
Merops wrote:
Fri Dec 13, 2024 5:40 pm
Do you know how to remove the "Root" element from the legend ? It distorts the display of the % .
The easiest way I can think on is to duplicate the SquarifiedMapSeries; the second one without the root element so it won't be drawn in the chart but can be drawn in the legend.
Merops wrote:
Fri Dec 13, 2024 5:40 pm
I have 30% and 20% instead of 60% and 40%:
Try setting Totalize:=False before calling FinishData.

Here a simple example:
SquarifiedMap.png
SquarifiedMap.png (7.81 KiB) Viewed 3817 times

Code: Select all

uses Chart, TeEngine, TeeSquarifiedMap;

var Chart1: TChart;

procedure TForm1.FormCreate(Sender: TObject);
var t: Integer;
    squari: TSquarifiedMapSeries;
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;
  Chart1.Align:=alClient;
  Chart1.View3D:=False;

  squari:=TSquarifiedMapSeries(Chart1.AddSeries(TSquarifiedMapSeries));
  squari.AddItem(-1,0,'Root');
  squari.AddItem(0,200,'ValueA');
  squari.AddItem(0,300,'ValueB');
  squari.Totalize:=False;
  squari.FinishData;
  squari.ShowInLegend:=False; // as per default
  squari.Marks.Style:=smsLabelPercentValue;
  squari.Marks.MultiLine:=True;

  with TSquarifiedMapSeries(Chart1.AddSeries(TSquarifiedMapSeries)) do
  begin
    for t:=1 to Chart1[0].Count-1 do
    begin
      AddItem(0, squari.Values[t], squari.Labels[t]);
      ValueColor[Count-1]:=OperaPalette[t];
    end;

    ShowInLegend:=True;
  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

Merops
Newbie
Newbie
Posts: 4
Joined: Thu Nov 14, 2024 12:00 am

Re: TSquarifiedMapSeries Add values

Post by Merops » Mon Dec 16, 2024 7:56 pm

Perfect,
Thanks Yeray :D

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

Re: TSquarifiedMapSeries Add values

Post by Yeray » Mon Dec 16, 2024 7:59 pm

Hello Merops,

You're welcome! :D
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