Basic Treemap

The basic Treemap requires `items`, a key accessor function, a value accessor function, and a color mapping function.

It renders a hierarchical data structure as a set of nested rectangles.

Usage

<Treemap
  {items}
  {keyToColorFn}
  {keyToColorLabelFn}
  valueAccessor={getDocCount}
/>

Props

items

    (12) [ {…} ,{…} ,{…} ,{…} ,{…} , ]
    • 0: { key: "2007 onwards" ,doc_count: 21230 }
    • 1: { key: "1950-1966" ,doc_count: 15088 }
    • 2: { key: "England and Wales: before 1900" ,doc_count: 12206 }
    • 3: { key: "1965-1975" ,doc_count: 10334 }
    • 4: { key: "1930-1949" ,doc_count: 7671 }
    • 5: { key: "1983-1991" ,doc_count: 5652 }
    • 6: { key: "1900-1929" ,doc_count: 5572 }
    • 7: { key: "1976-1983" ,doc_count: 4656 }
    • 8: { key: "1996-2002" ,doc_count: 3708 }
    • 9: { key: "1991-1998" ,doc_count: 3464 }
    • 10: { key: "2003-2007" ,doc_count: 2769 }
    • 11: { key: "Scotland: before 1919" ,doc_count: 1836 }
    • length: 12

keyToColorFn

    ƒ scale(d)
    • length: 1
    • name: "scale"
    • prototype: { constructor: ƒ }
    • [[Function]]: function scale(d) { let i = index.get(d); if (i === undefined) { if (unknown !== implicit) return unknown; index.set(d, i = domain.push(d) - 1); } return range[i % range.length]; }
    • [[Prototype]]: ƒ ()

keyToColorLabelFn

    ƒ scale(d)
    • length: 1
    • name: "scale"
    • prototype: { constructor: ƒ }
    • [[Function]]: function scale(d) { let i = index.get(d); if (i === undefined) { if (unknown !== implicit) return unknown; index.set(d, i = domain.push(d) - 1); } return range[i % range.length]; }
    • [[Prototype]]: ƒ ()

valueAccessor

    ƒ (b)
    • length: 1
    • prototype: { constructor: ƒ }
    • [[Function]]: function (b) { return isRightCurry ? fn.call(this, b, a) : fn.call(this, a, b); }
    • [[Prototype]]: ƒ ()
2007 onwards21230 1950-196615088 England and Wales: before 190012206 1965-197510334 1930-19497671 1983-19915652 1900-19295572 1976-19834656 1996-20023708 1991-19983464 2003-20072769 Scotland: before 19191836