如何让美国各州进入 Google 可视化等值线
How to get US states on a Google visualization choropleth
我正在尝试对美国各州的药物死亡率进行统计。
但是,我无法让州寄宿生出现,只有阿拉斯加和夏威夷,我似乎无法弄清楚为什么。
不过,这还是有点新,所以希望有人能帮忙!
这是我的代码:
google.load("visualization", "1", {'packages':["geochart"]});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Region', 'Age-adjusted mortality rate per 100,000'],
['Alaska', 16.8],
['Alabama', -8],
['Arizona', 6],
['Arkansas', -24],
['California', 12],
['Colorado', -3],
['Connecticut', 3],
['Delaware', 28],
['Florida', 15],
['Georgia', 4],
['Hawaii', 35],
['Idaho', 12],
['Illinois', -12],
['Indiana', 6],
['Iowa', -3],
['Kansas', 12],
['Kentucky', 26],
['Louisiana', 3],
['Maine', 15],
['Maryland', 9],
['Massachusetts', 0],
['Michigan', 13],
['Minnesota', 5],
['Mississippi', 10],
['Missouri', 12],
['Montana', -1],
['Nebraska', -29],
['Nevada', 6],
['New Hampshire', 32],
['New Jersey', null],
['New Mexico', 33],
['New York', -14],
['North Carolina', 12],
['North Dakota', 18],
['Ohio', -20],
['Oklahoma', -13],
['Oregon', 35],
['Pennsylvania ', 32],
['Rhode Island', -25],
['South Carolina', -22],
['South Dakota', 14],
['Tennessee', 8],
['Texas', -1],
['Utah', -21],
['Vermont', -2],
['Virginia', -16],
['Washington', 0],
['West Virginia', 15],
['Wisconsin', -5],
['Wyoming', 8]
]);
var options = {
region: 'US',
colorAxis: {colors: ['#00853f', 'black', '#e31b23']},
backgroundColor: '#81d4fa',
datalessRegionColor: '#f8bbd0',
defaultColor: '#f5f5f5'
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
};
</script>
谢谢!
我想你正在寻找:resolution: 'provinces'
google.load("visualization", "1", {'packages':["geochart"]});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Region', 'Age-adjusted mortality rate per 100,000'],
['Alaska', 16.8],
['Alabama', -8],
['Arizona', 6],
['Arkansas', -24],
['California', 12],
['Colorado', -3],
['Connecticut', 3],
['Delaware', 28],
['Florida', 15],
['Georgia', 4],
['Hawaii', 35],
['Idaho', 12],
['Illinois', -12],
['Indiana', 6],
['Iowa', -3],
['Kansas', 12],
['Kentucky', 26],
['Louisiana', 3],
['Maine', 15],
['Maryland', 9],
['Massachusetts', 0],
['Michigan', 13],
['Minnesota', 5],
['Mississippi', 10],
['Missouri', 12],
['Montana', -1],
['Nebraska', -29],
['Nevada', 6],
['New Hampshire', 32],
['New Jersey', null],
['New Mexico', 33],
['New York', -14],
['North Carolina', 12],
['North Dakota', 18],
['Ohio', -20],
['Oklahoma', -13],
['Oregon', 35],
['Pennsylvania ', 32],
['Rhode Island', -25],
['South Carolina', -22],
['South Dakota', 14],
['Tennessee', 8],
['Texas', -1],
['Utah', -21],
['Vermont', -2],
['Virginia', -16],
['Washington', 0],
['West Virginia', 15],
['Wisconsin', -5],
['Wyoming', 8]
]);
var options = {
region: 'US',
colorAxis: {colors: ['#00853f', 'black', '#e31b23']},
backgroundColor: '#81d4fa',
datalessRegionColor: '#f8bbd0',
defaultColor: '#f5f5f5',
resolution: 'provinces'
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
};
<script src="https://www.google.com/jsapi"></script>
<div id="geochart-colors" style="width: 900px; height: 500px;"></div>
我正在尝试对美国各州的药物死亡率进行统计。 但是,我无法让州寄宿生出现,只有阿拉斯加和夏威夷,我似乎无法弄清楚为什么。 不过,这还是有点新,所以希望有人能帮忙!
这是我的代码:
google.load("visualization", "1", {'packages':["geochart"]});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Region', 'Age-adjusted mortality rate per 100,000'],
['Alaska', 16.8],
['Alabama', -8],
['Arizona', 6],
['Arkansas', -24],
['California', 12],
['Colorado', -3],
['Connecticut', 3],
['Delaware', 28],
['Florida', 15],
['Georgia', 4],
['Hawaii', 35],
['Idaho', 12],
['Illinois', -12],
['Indiana', 6],
['Iowa', -3],
['Kansas', 12],
['Kentucky', 26],
['Louisiana', 3],
['Maine', 15],
['Maryland', 9],
['Massachusetts', 0],
['Michigan', 13],
['Minnesota', 5],
['Mississippi', 10],
['Missouri', 12],
['Montana', -1],
['Nebraska', -29],
['Nevada', 6],
['New Hampshire', 32],
['New Jersey', null],
['New Mexico', 33],
['New York', -14],
['North Carolina', 12],
['North Dakota', 18],
['Ohio', -20],
['Oklahoma', -13],
['Oregon', 35],
['Pennsylvania ', 32],
['Rhode Island', -25],
['South Carolina', -22],
['South Dakota', 14],
['Tennessee', 8],
['Texas', -1],
['Utah', -21],
['Vermont', -2],
['Virginia', -16],
['Washington', 0],
['West Virginia', 15],
['Wisconsin', -5],
['Wyoming', 8]
]);
var options = {
region: 'US',
colorAxis: {colors: ['#00853f', 'black', '#e31b23']},
backgroundColor: '#81d4fa',
datalessRegionColor: '#f8bbd0',
defaultColor: '#f5f5f5'
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
};
</script>
谢谢!
我想你正在寻找:resolution: 'provinces'
google.load("visualization", "1", {'packages':["geochart"]});
google.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
var data = google.visualization.arrayToDataTable([
['Region', 'Age-adjusted mortality rate per 100,000'],
['Alaska', 16.8],
['Alabama', -8],
['Arizona', 6],
['Arkansas', -24],
['California', 12],
['Colorado', -3],
['Connecticut', 3],
['Delaware', 28],
['Florida', 15],
['Georgia', 4],
['Hawaii', 35],
['Idaho', 12],
['Illinois', -12],
['Indiana', 6],
['Iowa', -3],
['Kansas', 12],
['Kentucky', 26],
['Louisiana', 3],
['Maine', 15],
['Maryland', 9],
['Massachusetts', 0],
['Michigan', 13],
['Minnesota', 5],
['Mississippi', 10],
['Missouri', 12],
['Montana', -1],
['Nebraska', -29],
['Nevada', 6],
['New Hampshire', 32],
['New Jersey', null],
['New Mexico', 33],
['New York', -14],
['North Carolina', 12],
['North Dakota', 18],
['Ohio', -20],
['Oklahoma', -13],
['Oregon', 35],
['Pennsylvania ', 32],
['Rhode Island', -25],
['South Carolina', -22],
['South Dakota', 14],
['Tennessee', 8],
['Texas', -1],
['Utah', -21],
['Vermont', -2],
['Virginia', -16],
['Washington', 0],
['West Virginia', 15],
['Wisconsin', -5],
['Wyoming', 8]
]);
var options = {
region: 'US',
colorAxis: {colors: ['#00853f', 'black', '#e31b23']},
backgroundColor: '#81d4fa',
datalessRegionColor: '#f8bbd0',
defaultColor: '#f5f5f5',
resolution: 'provinces'
};
var chart = new google.visualization.GeoChart(document.getElementById('geochart-colors'));
chart.draw(data, options);
};
<script src="https://www.google.com/jsapi"></script>
<div id="geochart-colors" style="width: 900px; height: 500px;"></div>