using a vectormap with JSON data
Not sure if this is the correct forum for this,
I'm using a the vectormap plug in which I got working, I'm able to hard code colors for states with no problem, however, I need to color each state based on data that is coming from the DB in JSON format.
here is the code I'm using that is hard coding the state colors:
- jQuery('#vmap').vectorMap({
map: 'usa_en',
showTooltip: true,
selectedColor: null,
hoverColor: '#1a75ff',
color: '#ffffff',
showLabels: true,
backgroundColor: null,
borderWidth: 4,
colors: {
ct: '#33A5FF',
- de: '#ff5733;
},
onRegionClick: function(event, code, region){
event.preventDefault();
}
});
I want to make the states a different color. Has anyone made the colors for the states dynamic?
my JSON looks like this:
- {
"d": {
"results": [
{
"State": "CT",
"Governor": "Malloy",
"GovParty": "D",
"StateSen_Total_D": "17",
"StateSen_Total_R": "16",
},
{
"State": "DE",
"Governor": "Carney",
"GovParty": "D",
"StateSen_Total_D": "8",
"StateSen_Total_R": "12",
}
]
}
}
I need to check the StateSent_Total values and if one is greater then the other, I need to make the state either blue or red.