Hello,
I am currently using Google Charts (https://developers.google.com/chart/int ... y/geochart) to draw a map chart, the example is very simple to setup, I am even using it in Delphi using TWebBrowser and TPageProducer.
I am trying to do the same in Delphi using TChart (for Offline clients), and I am facing the following difficulties:
1 - How to setup the values for the countries: The data I have is very simple, Country and a number (This should be the Z value in TChart), but I found that I have multiple countries in the data section, so if I have [USA, 30], how should I set this up?
2 - Hovering over a country should show a simple tooltip value (Country name and the value), my search lead me to .NET samples only so far
3 - One more question, do I need to supply any shape files (or manually add any resource files) to my VCL application to use the map series.
Any help or simple demo using one map series.
Map Series Demo Similar to Google Charts
Re: Map Series Demo Similar to Google Charts
Hello,
Here a simple example:
Take a look at the TeeMaps demo included with the installation in the "\Examples\TeeMaps" folder.
Once a map is loaded, the series has a "Labels" array you can use to search for the index of a country. Then you can use that index to update the series MandatoryValueList array with the desired values.nader wrote:1 - How to setup the values for the countries: The data I have is very simple, Country and a number (This should be the Z value in TChart), but I found that I have multiple countries in the data section, so if I have [USA, 30], how should I set this up?
Here a simple example:
Code: Select all
type
TCountry = class
Name: String;
Value: Double;
end;
implementation
{$R *.dfm}
uses TeeWorldSeries;
var MyCountries: array of TCountry;
Series1: TWorldSeries;
procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
Chart1.View3D:=False;
Chart1.Legend.Visible:=False;
Series1:=TWorldSeries.Create(self);
Chart1.AddSeries(Series1);
Series1.Map:=TWorldMap(6);
//populate array of countries with random values
SetLength(MyCountries,16);
j:=0;
for i:=0 to Series1.Count-1 do
begin
if (j=0) or (MyCountries[j-1].Name<>Series1.Labels[i]) then
begin
MyCountries[j]:=TCountry.Create;
MyCountries[j].Name:=Series1.Labels[i];
MyCountries[j].Value:=random*20;
Inc(j);
end;
end;
end;
//use array of countries to populate series
procedure TForm1.Button1Click(Sender: TObject);
var i, j: Integer;
begin
for i:=0 to Series1.Count-1 do
begin
for j:=0 to High(MyCountries) do
begin
if Series1.Labels[i]=MyCountries[j].Name then
begin
Series1.MandatoryValueList[i]:=MyCountries[j].Value;
break;
end;
end;
end;
Chart1.Repaint;
end;
You can use the TMarksTipTool. This adds the tool and sets it to show both the label and the value:nader wrote:2 - Hovering over a country should show a simple tooltip value (Country name and the value), my search lead me to .NET samples only so far
Code: Select all
(Chart1.Tools.Add(TMarksTipTool) as TMarksTipTool).Style:=smsLabelValue;
You can either use any of the maps included with TeeChart or you can load your shape files.nader wrote:3 - One more question, do I need to supply any shape files (or manually add any resource files) to my VCL application to use the map series.
Take a look at the TeeMaps demo included with the installation in the "\Examples\TeeMaps" folder.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Map Series Demo Similar to Google Charts
Thank you,
Actually I came here to answer my own question
I figured it out, and I have an identical chart to what is offered by Google running offline, Awesome!
The only suggestion I have is related to the country name, it is better to have support for ISO country codes.
Thank you so much
Nader
Actually I came here to answer my own question
I figured it out, and I have an identical chart to what is offered by Google running offline, Awesome!
The only suggestion I have is related to the country name, it is better to have support for ISO country codes.
Thank you so much
Nader
Re: Map Series Demo Similar to Google Charts
I found the code too as part of the Shape object
Thanks
Thanks
Re: Map Series Demo Similar to Google Charts
Hello,
I'm glad to hear all works as desired!
I'm glad to hear all works as desired!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |