Jump to content
Software FX Community

Setting map data with the API


espranzani
 Share

Recommended Posts

Hello, I'm using the trial version of the ChartFX and Map extensions for a project for my company.  We are using it to evaluate if it will meet our needs and the needs of our clients.  We manipulate the data before binding to the charts, which is why for what we are doing, using the API is the best option for setting the data.  I'm having a difficult time finding good examples of how the map extension is used and of the couple that I did find, they use txt files for the data source.  I am using the .net 6.2 software, Visual Studio, c#.  I attempted using the following code, for example, to do the same as the WorldPopSample (in fact, I tried to modify that exact sample) by doing the following code, but it doesn't seem to be mapping it to the correct continents.  What am I doing wrong? 

 Also, it mentions this in the API reference: "By default, Chart FX Maps assumes that labels passed with chart data match the text labels that exist in the configured SVG MapSource. For instances when these labels do not correspond, a conversion table is used to connect the data labels to SVG labels. This table is referred to as the LabelLinks collection."  How do I know what the map's key to a particular country is, so I can reference it correctly.

Any help is much appreciated!

 //Set Continental Map

map1.MapSource = "World\\ContinentalOutline.svg";

// Set the data source to populate the map

map1.OpenData(COD.Values, 1, 1);

map1.Value[0,0] = 793627;

map1.LabelLinks[0].DataText = "Africa";

map1.Value[0,1] = 3672342;

map1.LabelLinks[1].DataText = "Asia";

map1.Value[0,2] = 314113;

map1.LabelLinks[2].DataText = "North America";

map1.Value[0,3] = 480867;

map1.LabelLinks[3].DataText = "South America";

map1.Value[0,4] = 727304;

map1.LabelLinks[4].DataText = "Europe";

map1.Value[0,5] = 30521;

map1.LabelLinks[5].DataText = "Oceania";

map1.CloseData(COD.Values);

//map1.DataSource = new TextProvider("../../../../WorldPopData/continentalPopData.txt"); //commented out the use of a txt file

 

Link to comment
Share on other sites

I finally figured this out on my own.  I didn't realize you set the label the same way you do with a chart:

map1.AxisX.Label[0] = "Africa";

 It wasn't obvious to me that the axis was still something you used in the map object.

 Thanks to anyone who might have looked into this.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...