dc-js / dc.leaflet.js

DC charts using Leaflet maps
Apache License 2.0
52 stars 24 forks source link

A note regarding the dimension creation of markerChart #36

Open akuji1993 opened 7 years ago

akuji1993 commented 7 years ago

I have now spent 4 or 5 days, figuring out (two times) how you have to create the geo dimension to make it work with markerChart. I thought that the geo attribute of my data object has to look like this:

{ geo: {lat: 23.2323, lng:34.2323}}

The solution is that the object you give the dimension a geo object on your data object that is formatted like this:

geo: "343.34343, 34.23232"

BUT! This alone still does not make the graph show the map markers. You ALSO need to have a lat and a lng attribute on your data object. So completely your data object has to look like this:

[... , {geo: "34.34343, 23.2323", lat: 34.34343, lng: 23.2323, value: 5000}, ... ]

THEN the markers show up on the map, in this case showing the grouped data for the attribute value. Note, that lat and lng have to be Numbers and geo has to be a String!

I believe this should be noted in the documentation somewhere, because it just drove me nuts for the second time now, because of course I forgot how to fix it.