You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We might also want a warning for line and area marks when a channel is temporal but not in monotonic order (within a series). But you’ll presumably want a way to disable it in some rare cases and I’m not sure how we’d do that, unless maybe the mark can check if the sort option is null.
Warning for the cases where mark data is not parallel to facet data. I.e., cases that are warned about here:
When the include or exclude facet mode is chosen, the mark data must be parallel to the facet data: the mark data must have the same length and order as the facet data. If the data are not parallel, then the wrong data may be shown in each facet. The default auto therefore requires strict equality (===) for safety, and using the facet data as mark data is recommended when using the exclude facet mode. (To construct parallel data safely, consider using array.map on the facet data.)
It would be great to surface a warning when someone uses Plot.barY with a continuous x (which results in over-labeling the ticks on the x axis).
.
Relatedly Plot.barX with a continuous y. Maybe even Plot.groupX with a continuous x and Plot.groupY with a continuous y (nudging them towards binning continuous values)?
if(values.some(isTemporal))warn(`Warning: some data associated with the ${key} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(type)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(type)}".`);
elseif(values.some(isTemporalString))warn(`Warning: some data associated with the ${key} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${formatScaleType(type)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(type)}".`);
elseif(values.some(isNumericString))warn(`Warning: some data associated with the ${key} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${formatScaleType(type)}" scale. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${key} scale to "${formatScaleType(type)}".`);
I recall considering this warning earlier, and I think I didn’t do it because the default x channel for Plot.barY is indexOf which is numeric. We wouldn’t want the barY shorthand to generate a warning. That said, we could be more selective in our warning:
If the channel is numeric and there are any gaps between numbers? Though this would require detecting when the numbers are integers, and presumably would want to support both ascending and descending sequences. Alternatively we could just special-case 0, 1, 2, 3, … but that seems like cheating.
If the channel is numeric and there are more than TK distinct values (high cardinality)?
Or more generally if there are more than TK distinct values?
Related #74 which is also about high-cardinality ordinal domains. Though that’s not the only problem here—the other reason we want to warn about numeric data being treated as ordinal is that it makes it hard to see missing values (gaps in the data).
Thanks for elaborating @mbostock -- agreed that we don't want the shorthand to generate a warning. I think If the channel is numeric and there are any gaps between numbers? would still miss the common case of too many ticks being drawn (as you noted, #74). I'm not sure if there's a simple way to check if the shorthand is being used (e.g., if the channel was set explicitly or not), but perhaps we could provide a warning if the channel is numeric and it was explicitly declared (using a string or function?).
perhaps we could provide a warning if the channel is numeric and it was explicitly declared
Generally speaking we try to do the opposite, which is to declare warnings in cases where the Plot specification is ambiguous (underspecified), such as when the scale type is not explicitly declared. This provides a consistent way to suppress warnings by stating more explicitly what you intend to happen (you always add to a specification to suppress a warning, not remove). In other words I don’t think we should give the shorthand a special exemption around this error; if you specify x: (d, i) => i explicitly then I wouldn’t want a warning either.
Just wanted to add to @kentr 's suggestion above that we provide a warning when the arrays aren't strictly equal (which happens if you apply the same filter function to the facet and mark data). Example notebook here: https://observablehq.com/d/a869f84e397d44b7
It would be nice if there were a warning attached to any plot that has a Plot.geo mark but has not specified a projection, instructing the user to specify projection: null to disable the warning. Right now making a plot with Plot.geo(geojson).plot() produces an empty plot.
I mentioned this on the d3js slack and @Fil added some nuance:
Note that you can use Plot.geo in conjunction with a dot mark (or any other mark that defines x and y scales); in that case the geo will be projected onto the x/y coordinate system. The warning would only be necessary if there is geo and no projection nor x/y scales.
can cause the JavaScript engine to run out of memory. The interval is interpreted as 1 millisecond, which causes d3-array to produce an array of size 172,800,000.
Activity
mbostock commentedon Mar 2, 2022
We might also want a warning for line and area marks when a channel is temporal but not in monotonic order (within a series). But you’ll presumably want a way to disable it in some rare cases and I’m not sure how we’d do that, unless maybe the mark can check if the sort option is null.
kentr commentedon Mar 7, 2022
Suggestion:
Warning for the cases where mark data is not parallel to facet data. I.e., cases that are warned about here:
mkfreeman commentedon Mar 16, 2022
It would be great to surface a warning when someone uses
Plot.barYwith a continuousx(which results in over-labeling the ticks on the x axis).
.Relatedly
Plot.barXwith a continuousy. Maybe evenPlot.groupXwith a continuousxandPlot.groupYwith a continuousy(nudging them towards binning continuous values)?mbostock commentedon Mar 16, 2022
@mkfreeman Here’s an example of the pattern you describe:
The warning would be triggered by
values.some(isNumeric)here:plot/src/scales.js
Lines 150 to 152 in 66142e2
I recall considering this warning earlier, and I think I didn’t do it because the default x channel for Plot.barY is
indexOfwhich is numeric. We wouldn’t want the barY shorthand to generate a warning. That said, we could be more selective in our warning:Related #74 which is also about high-cardinality ordinal domains. Though that’s not the only problem here—the other reason we want to warn about numeric data being treated as ordinal is that it makes it hard to see missing values (gaps in the data).
mkfreeman commentedon Mar 17, 2022
Thanks for elaborating @mbostock -- agreed that we don't want the shorthand to generate a warning. I think If the channel is numeric and there are any gaps between numbers? would still miss the common case of too many ticks being drawn (as you noted, #74). I'm not sure if there's a simple way to check if the shorthand is being used (e.g., if the channel was set explicitly or not), but perhaps we could provide a warning if the channel is numeric and it was explicitly declared (using a string or function?).
mbostock commentedon Mar 17, 2022
Generally speaking we try to do the opposite, which is to declare warnings in cases where the Plot specification is ambiguous (underspecified), such as when the scale type is not explicitly declared. This provides a consistent way to suppress warnings by stating more explicitly what you intend to happen (you always add to a specification to suppress a warning, not remove). In other words I don’t think we should give the shorthand a special exemption around this error; if you specify
x: (d, i) => iexplicitly then I wouldn’t want a warning either.mkfreeman commentedon Jul 26, 2022
Just wanted to add to @kentr 's suggestion above that we provide a warning when the arrays aren't strictly equal (which happens if you apply the same filter function to the facet and mark data). Example notebook here: https://observablehq.com/d/a869f84e397d44b7
Fil commentedon Aug 30, 2022
yurivish commentedon Dec 13, 2022
It would be nice if there were a warning attached to any plot that has a
Plot.geomark but has not specified a projection, instructing the user to specifyprojection: nullto disable the warning. Right now making a plot withPlot.geo(geojson).plot()produces an empty plot.I mentioned this on the d3js slack and @Fil added some nuance:
mwaibel-go commentedon Mar 17, 2026
mwaibel-go commentedon Aug 10, 2026
I’m not sure if this is too deep in the realm of developer stupidity to warrant a warning, but this definition:
can cause the JavaScript engine to run out of memory. The interval is interpreted as 1 millisecond, which causes d3-array to produce an array of size 172,800,000.