for NaN, y1 and y2 with sort is different from y #2172
-
I was wondering why y2: (d) => isNaN(d.population) ? -Infinity : d.population to fake the minimum or maximum, but feel like abusing the property, or maybe I misunderstood how timeseries = [
{year: 2014, population: 7295.290765},
{year: 2015, population: 7379.797139},
{year: 2016, population: 7464.022049},
{year: 2017, population: 7547.858925},
{year: 2018, population: NaN},
{year: 2019, population: 7713.468100},
{year: 2020, population: 7794.798739}
]; Plot.barY(timeseries, {
x: "year",
y: "population",
sort: { x: "y" }
}).plot() Plot.barY(timeseries, {
x: "year",
y1: 0,
y2: (d) => d.population,
sort: {
x: "y2" // "y"
}
}).plot() |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
The difference is that if you specify (Note that it is not "minimum" nor "maximum": Plot and D3 put invalid values at the end when they sort. For instance if you say |
Beta Was this translation helpful? Give feedback.
The difference is that if you specify
y
you get implicit stacking, and the invalid datum is stacked as a rectangle of height equal to 0. Whereas if you specifyy2
, there is no stacking, thus y2 is NaN and the invalid datum is discarded. The difference is visible if you setstroke: "red", inset: -1,
.(Note that it is not "minimum" nor "maximum": Plot and D3 put invalid values at the end when they sort. For instance if you say
sort: { x: "-y2" }
to sort by descending y2, the invalid datum will still be to the right.)