Closed ghost closed 8 years ago
Hi @smilefishes, yes! You can bring your own data in any format. The key is in providing the right "value" accessor:
var cartogram = d3.cartogram()
.value(function(feature) {
// return a value for each feature here
});
For instance, if you have your data in JSON as an object that maps feature IDs to numeric values, you could do this:
var data = {
AL: 20,
CA: 100,
FL: 50
// ...
};
cartogram.value(function(feature) {
return data[feature.id] || 0;
});
Feel free to re-open this issue with a more specific question if you still need help.
thanks a lot! It really works!
for example ,can I use static data in the .html file?