0

I am adding tipsy to Mike Bostock’s chloropeth map using this: http://bl.ocks.org/ilyabo/1373263. I added another column to my csv titled “county_name.” The tooltip works fine if I try to retrieve the id using k.id but when I try k.county_name I get undefined.

   $('svg path').tipsy({
            gravity: 's',
            html: true,
            title: function () {
                var k = this.__data__;
                return 'Hi there! My county is ' + k.county_name;
            }
        });

I am loading the csv data with this and I can get different ids to show up but I have only been able to show one county name at a time by manually setting it. I'm at a loss as to how to match up the id with the county_name.

var county;

d3.csv("unemployment2.csv", function (data) {
    dataset = data;
    county = data[0].county_name;
    console.log(county);
});
B T
  • 151
  • 1
  • 6
  • 15
  • AFTER loading the data, did you log the data variable to the console to see if county_name is really part of it? – FernOfTheAndes Mar 06 '14 at 19:28
  • There's no county name information in the JSON for that example. – Lars Kotthoff Mar 06 '14 at 19:30
  • I'm using a CSV file structured like Mike Bostock's TSV file except that I added a "county_name" column with all the data after the "rate" column, but I can't access "county_name" to write it to the console. – B T Mar 06 '14 at 19:49
  • If you're using a chloropleth map example like [this one](http://bl.ocks.org/mbostock/4060606), then the data joined to the path elements is the GeoJSON data, not the data from the csv. You'll need to add an extra step to grab the correct data element from your hashmap based on the id, and then grab the name from that. – AmeliaBR Mar 07 '14 at 03:32

0 Answers0