Showing map series on x-z plane

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Michael Heinrich
Newbie
Newbie
Posts: 20
Joined: Thu Feb 04, 2010 12:00 am

Showing map series on x-z plane

Post by Michael Heinrich » Fri Aug 26, 2011 8:41 am

Hi,

Is it possible to show a map series (normally shown on the x-y plane) on the x-z plane? I want to be able to show a map in 3d and then place another series on top of it using bars to show a numerical value for that shape. Like a bar showing the population densitity of an area, the average power usage, etc. I have created a screen shot using a 3d bar series for the 'map' (in this case all squares) and a 3d bar series showing the values for that area.

Kind regards,
Michael.
Attachments
3dchart.png
3d chart of two 3d bar series
3dchart.png (31.92 KiB) Viewed 9972 times

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

Re: Showing map series on x-z plane

Post by Yeray » Mon Aug 29, 2011 3:06 pm

Hello Michael,

I've been trying to prepare an example with the actual features in TeeChart but it wouldn't be easy. I'd let you know if I achieve to get an acceptable example.
On the other hand, I've added it to the wish list to be implemented in future releases (TV52015714).
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

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

Re: Showing map series on x-z plane

Post by Yeray » Tue Aug 30, 2011 3:12 pm

Hello Michael,

I finally got something that looks quite well:

Code: Select all

uses TeCanvas;

var Map1: TWorldSeries;
    Sizes: array of Double;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.Legend.Visible:=false;
  Chart1.Aspect.Orthogonal:=false;
  Chart1.Aspect.Elevation:=50;
  Chart1.Axes.Depth.Visible:=true;
  Chart1.Axes.Bottom.ZPosition:=100;
  Chart1.Axes.Left.ZPosition:=100;
  Chart1.Axes.Bottom.Grid.Visible:=false;
  Chart1.Axes.Left.Grid.Visible:=false;
  Chart1.Axes.Depth.Grid.Visible:=false;
  Chart1.Walls.Bottom.Visible:=false;
  Chart1.Walls.Left.Visible:=false;
  ScrollBar1.Max:=360;
  ScrollBar1.Position:=Chart1.Aspect.Elevation;

  Chart1.Axes.Depth.SetMinMax(-200,0);

  Map1:=Chart1.AddSeries(TWorldSeries) as TWorldSeries;
  Map1.Map:=wmEurope15;
  Map1.ColorEachPoint:=true;

  SetLength(Sizes, Map1.Count);
  for i:=0 to High(Sizes) do
    Sizes[i]:=Random()*100;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var i: Integer;
    XVal, YVal: Integer;
begin
  for i:=0 to Map1.Count-1 do
  begin
    XVal:=Map1.Shapes[i].Bounds.Left + ((Map1.Shapes[i].Bounds.Right-Map1.Shapes[i].Bounds.Left) div 2);
    YVal:=Map1.Shapes[i].Bounds.Top + ((Map1.Shapes[i].Bounds.Bottom-Map1.Shapes[i].Bounds.Top) div 2);
    Chart1.Canvas.Brush.Color:=Map1.ValueColor[i];
    Chart1.Canvas.Cube(XVal-5, XVal+5, YVal-5, YVal+5, Chart1.Axes.Depth.IEndPos-Chart1.Axes.Depth.CalcSizeValue(Sizes[i]), Chart1.Axes.Depth.IEndPos);
  end;
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis; Series: TChartSeries;
  ValueIndex: Integer; var LabelText: string);
begin
  if Sender = Chart1.Axes.Depth then
  begin
    LabelText:=FloatToStr(Abs(StrToFloat(LabelText)));
  end;
end;
Attachments
Maps&Bars.png
Maps&Bars.png (14.91 KiB) Viewed 9881 times
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

Michael Heinrich
Newbie
Newbie
Posts: 20
Joined: Thu Feb 04, 2010 12:00 am

Re: Showing map series on x-z plane

Post by Michael Heinrich » Thu Sep 08, 2011 7:42 am

Hello Yeray,

Sorry for not responding sooner, had some time off.
The solution you have provided will help me along the way. I am going to have to add features a normal bar series has but I think this is usable. I'll let you know once I have added your solution to my code. Thanks for the code example and the effort. It is quite an out of the box solution.

Thanks,
Michael.

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

Re: Showing map series on x-z plane

Post by Yeray » Thu Sep 08, 2011 7:56 am

Hello Michael,

I'm really glad to hear you found it satisfying!
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