ordinal interval#849
Conversation
|
Taking a bit more time than expected because it has implications on the warnings; for example if you have a date interval on x you don't want a warning that the dates are unexpected in an ordinal scale. |
|
A few more suggestions, maybe for a fast follow:
|
Should this be a more general error if you have a Very High Cardinality Domain (VHCD) on an ordinal scale? Or maybe just for a point or band scale? I think it’d be pretty easy to add this check in the scale constructor when the domain is not set explicitly.
If x has interval: 1, then it will have a default transform of Math.floor, so you shouldn’t get any fractional values in the domain (unless you set the domain explicitly).
Yeah, I think this is a general confusion around scale transforms, which is that they happen after any mark data transforms. It might be better if they happened before instead, but I don’t think that’s possible (since the scale options aren’t exposed to mark data transforms). I think maybe we just live with this one. |
* Specifying a scale interval shows the intent of having ordinal numerical or ordinal dates: suppress warning. Side note: if a numeric interval was specified, string numerics have already been coerced to numbers by the scale transform; so this in fact only has consequences for ordinal dates, such as in the downloads-ordinal test plot. * document scale intervals * test plot with year intervals * Update src/scales.js Co-authored-by: Mike Bostock <mbostock@gmail.com> * Update src/scales.js Co-authored-by: Mike Bostock <mbostock@gmail.com> * Update src/scales.js Co-authored-by: Mike Bostock <mbostock@gmail.com> * d3.utcDay-like intervals do not parse string dates * reusable interval option * When the interval option is applied on a quantitative scale, generate the ticks with the interval; also set the tickFormat so that we don't show 1.0, 2.0, 3.0 if the interval is an integer. * tests * normalize intervals lists a few TODOs re: the default tick format: - we don't want decimal notation if the interval is specified as an integer - we don't want months to appear if the interval is specified as d3.utcYear - we don't want years to appear with commas (#768) * formatDefault for ordinal scales * Update README * call maybeInterval sooner * tabular-nums for interval’d ordinal axes Co-authored-by: Mike Bostock <mbostock@gmail.com>
48166af to
51741f4
Compare
|
This should be ready to go. |
|
Excellent! The only thing I don't like is the formatting of integers as 1.0, 2.0 etc in the test/output/integerInterval.svg plot. I hoped we could use the interval to infer that the format should not include the decimal dot—but that will be for another issue. |
* bail out if the inferred ordinal domain has more than 10k values (see #849 (comment)) * only on point and band scales * only throw an error for position scales * apply review suggestion: key as first argument to ScaleO * shorter error message Co-authored-by: Mike Bostock <mbostock@gmail.com>
* bail out if the inferred ordinal domain has more than 10k values (see observablehq/plot#849 (comment)) * only on point and band scales * only throw an error for position scales * apply review suggestion: key as first argument to ScaleO * shorter error message Co-authored-by: Mike Bostock <mbostock@gmail.com>
* bail out if the inferred ordinal domain has more than 10k values (see observablehq/plot#849 (comment)) * only on point and band scales * only throw an error for position scales * apply review suggestion: key as first argument to ScaleO * shorter error message Co-authored-by: Mike Bostock <mbostock@gmail.com>
Fixes #513.
When a scale has an interval option, interval.floor is used as the scale transform, and then for ordinal scales, the domain is computed using interval.range(min, max), ensuring that gaps are shown and that ordinal values appear in the intended order.