Jump to content
Software FX Community

Maps help - unable to format labels and apply conditional attributes


LSUgirl

Recommended Posts

I'm creating a new map with a single series (number of students per state).  I can see the data in the data grid.  I'm trying to change the label to display the number of students when hovering over a state.  I also want to change the state color based on the number of students in that state.  I can't seem to make either of these happen.

My aspx page:

<chartfx7:Chart ID="Chart1" runat="server" Height="499px"

RandomData-Points="48" RandomData-Style="Labels" Width="793px" PlotAreaColor="Transparent">

<Series>

<chartfx7:SeriesAttributes />

</Series>

<SpecialObjects>

<chartfx.webforms.adornments.imageborder assemblyname="ChartFX.WebForms.Adornments"

color="109, 125, 138"></chartfx.webforms.adornments.imageborder>

</SpecialObjects>

<DataGrid Visible="True" />

<LegendBox Visible="False">

</LegendBox>

</chartfx7:Chart>

<chartfxmaps:Map ID="Map1" runat="server" ChartId="Chart1">

</chartfxmaps:Map>

My aspx.cs page:

DataTable myDataTable = DB_state.SelectTable();

Chart1.DataSourceSettings.Fields.Add(

new FieldMap("short_desc", FieldUsage.Label));Chart1.DataSourceSettings.Fields.Add(new FieldMap("nbr_stds", FieldUsage.Value));

 

Chart1.AllSeries.PointLabels.Visible = true;Chart1.AllSeries.PointLabels.Format = "%v";

 

//Create conditional attributesConditionalAttributes cond1 = new ConditionalAttributes();cond1.Color = Color.Red;

cond1.Condition.To = 500;

Chart1.ConditionalAttributes.Add(cond1);

ConditionalAttributes cond2 = new ConditionalAttributes();cond2.Color = Color.Yellow;

cond2.Condition.From = 500;

cond2.Condition.To = 2000;

Chart1.ConditionalAttributes.Add(cond2);

ConditionalAttributes cond3 = new ConditionalAttributes();cond3.Color = Color.Green;

cond3.Condition.From = 2000;

Chart1.ConditionalAttributes.Add(cond3);

 

Map1.MapSource =

"US\\USA-StatesAbrev.svg";

Chart1.DataSource = myDataTable;

Link to comment
Share on other sites

The code looks ok. The problem may be with the data. The labels in your data need to match the label keys in the map. In this particular map the labels must be the state abbreviations (e.g. NY, FL, GA, etc.).

Please Export this chart to a binary file (Export method) and attach it to your posting. If the map contains data that is private, you can send it as a private message to me.

An alternative to this is to produce a sample program, with dummy data, that reproduces the problem.

Link to comment
Share on other sites

I can see that I have some value for Puerto Rico and the Virgin Islands (to name a few).  I guess those are messing with the map.  ???  I guess there isn't a US territories map???

 Noticing that, I trimmed the data down to a few states (not a great example since I need all the states) to see if I could get the label and conditional attributes to work.  They still don't.  Do you have to have a value for every state?  Do you have to have 50 values (no more, no less)???

 sample data

 nbr_stds

CA    3934

TX    2758

FL    2428

NY    2152

GA    2028

PA    2018

WA    1538

OK    1201

IL    1115

MO    1111

MI    1093

MD    1028

Link to comment
Share on other sites

The problem is your data labels have a bunch of white spaces at the end. You need to trim those labels before feeding them to the chart.

Your data does not have top contain all regions (states) and it may contain regions that don't exist in the map. Both situations are perfectly fine.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...