d3 / d3-shape

Graphical primitives for visualization, such as lines and areas.
https://d3js.org/d3-shape
ISC License
2.48k stars 308 forks source link

Possible typing issue or a missing example (How to write a custom accessor?) #180

Closed GiridharKarnik closed 3 years ago

GiridharKarnik commented 3 years ago

the default types only work with data containing a subarray of 2 elements. The example talks about writing a custom accessor

const data = [
  {date: new Date(2007, 3, 24), value: 93.24},
  {date: new Date(2007, 3, 25), value: 95.35},
  {date: new Date(2007, 3, 26), value: 98.84},
  {date: new Date(2007, 3, 27), value: 99.92},
  {date: new Date(2007, 3, 30), value: 99.80},
  {date: new Date(2007, 4,  1), value: 99.47},
];

const area = d3.area()
    .x(d => x(d.date))
    .y1(d => y(d.value))
    .y0(y(0));

This does not work with the existing types at @types/d3-shape

GiridharKarnik commented 3 years ago

stupid question :facepalm: