Page 1 of 1

Showing map series on x-z plane

Posted: Fri Aug 26, 2011 8:41 am
by 10555193
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.

Re: Showing map series on x-z plane

Posted: Mon Aug 29, 2011 3:06 pm
by yeray
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).

Re: Showing map series on x-z plane

Posted: Tue Aug 30, 2011 3:12 pm
by yeray
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;

Re: Showing map series on x-z plane

Posted: Thu Sep 08, 2011 7:42 am
by 10555193
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.

Re: Showing map series on x-z plane

Posted: Thu Sep 08, 2011 7:56 am
by yeray
Hello Michael,

I'm really glad to hear you found it satisfying!