United States of America - Highmaps
Highmaps demo
by Geo George
HTML
<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="https://code.highcharts.com/mapdata/countries/us/us-all.js"></script>
<div id="container"></div>
CSS
#container {
height: 500px;
min-width: 310px;
max-width: 800px;
margin: 0 auto;
}
.loading {
margin-top: 10em;
text-align: center;
color: gray;
}
JavaScript
// Prepare demo data
// Data is joined to map using value of 'hc-key' property by default.
// See API docs for 'joinBy' for more info on linking data and map.
var data =[
{
"code":"ME",
"color":"#CC6600"
},
{
"code":"NH",
"color":"#CC6600"
},
{
"code":"MA",
"color":"#CC6600"
},
{
"code":"CT",
"color":"#CC6600"
},
{
"code":"NJ",
"color":"#CC6600"
},
{
"code":"PA",
"color":"#CC6600"
},
{
"code":"DE",
"color":"#CC6600"
},
{
"code":"MD",
"color":"#CC6600"
},
{
"code":"VA",
"color":"#CC6600"
},
{
"code":"PA",
"color":"#CC6600"
},
{
"code":"KY",
"color":"#CC6600"
},
{
"code":"SC",
"color":"#CC6600"
},
{
"code":"GA",
"color":"#CC6600"
}
]
// Create the chart
Highcharts.mapChart('container', {
chart: {
map: 'countries/us/us-all'
},
title: {
text: 'Highmaps basic demo'
},
subtitle: {
text: 'Source map: <a href="http://code.highcharts.com/mapdata/countries/us/us-all.js">United States of America</a>'
},
legend:{
enabled: false
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
series: [{
data: data,
color:"blue",
joinBy: ['postal-code', 'code'],
dataLabels: {
enabled: true,
format: '{point.name}'
}
}, {
name: 'Separators',
type: 'mapline',
data: Highcharts.geojson(Highcharts.maps['countries/us/us-all'], 'mapline'),
color: 'silver',
showInLegend: false,
enableMouseTracking: false
}]
});