Page 1 of 1
TSquarifiedMapSeries Add values
Posted: Thu Dec 12, 2024 8:30 pm
by 16599012
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,
Re: TSquarifiedMapSeries Add values
Posted: Fri Dec 13, 2024 8:06 am
by yeray
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;
Re: TSquarifiedMapSeries Add values
Posted: Fri Dec 13, 2024 4:11 pm
by 16599012
Hi Yeray,
Thanks
- Capture d’écran 2024-12-13 170414.png (93.57 KiB) Viewed 5484 times
Best regards,
Re: TSquarifiedMapSeries Add values
Posted: Fri Dec 13, 2024 5:40 pm
by 16599012
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 (11.73 KiB) Viewed 5467 times
Thanks,
Re: TSquarifiedMapSeries Add values
Posted: Mon Dec 16, 2024 7:48 am
by yeray
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 (7.81 KiB) Viewed 4004 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;
Re: TSquarifiedMapSeries Add values
Posted: Mon Dec 16, 2024 7:56 pm
by 16599012
Perfect,
Thanks Yeray
Re: TSquarifiedMapSeries Add values
Posted: Mon Dec 16, 2024 7:59 pm
by yeray
Hello Merops,
You're welcome!