Hello, I am trying to create my own javascript map with the choropleth starter code. This is my data:
countries,visits
United States,1918
Trinidad And Tobago,631
Denmark,129
Germany,20
India,18
Finland,2
Romania,1
Canada,1
And this is my code
<script>
Plotly.d3.csv('https://riverside.rocks/analytics-csv.php', function(err, rows){
function unpack(rows, key) {
return rows.map(function(row) { return row[key]; });
}
var data = [{
type: 'choropleth',
locationmode: 'country names',
locations: unpack(rows, 'countries'),
z: unpack(rows, 'countries'),
text: unpack(rows, 'visits'),
autocolorscale: true
}];
var layout = {
title: 'Locations of traffic to riverside.rocks',
geo: {
projection: {
type: 'robinson'
}
}
};
Plotly.newPlot("c", data, layout, {showLink: false});
});
</script>
<div id="c"><!-- Plotly chart will be drawn inside this DIV --></div>
For some reason, this shows an empty chart and one lone error in the console:
What am I doing wrong here?