Accepted answer

Lots of ways to do this; here's a couple examples. The first uses d3.nest and turns the data into an array of arrays with the outer key being the name of the fruit. The second is a little hand-rolled code, which returns an object with properties of each fruit. What works best really depends on your larger use case.

<!DOCTYPE html>

    <script data-require="d3@4.0.0" data-semver="4.0.0" src=""></script>

    var data = [{
        "Fruits": 5,
        "Stores": 22,
        "Names of Fruits": "oranges"
      }, {
        "Fruits": 100,
        "Stores": 3,
        "Names of Fruits": "apple"
        "Fruits": 10,
        "Stores": 300,
        "Names of Fruits": "pear"

        "Fruits": 10,
        "Stores": 300,
        "Names of Fruits": "apple"
        .key(function(d) { return d["Names of Fruits"]; })
    var rv = {};
      if (!rv[d["Names of Fruits"]]) rv[d["Names of Fruits"]] = [];
      rv[d["Names of Fruits"]].push(d);


Related Query