diff --git a/src/plot.d.ts b/src/plot.d.ts index 05fc238dc5..e7fd5016f5 100644 --- a/src/plot.d.ts +++ b/src/plot.d.ts @@ -4,6 +4,8 @@ import type {Data, MarkOptions, Markish} from "./mark.js"; import type {ProjectionFactory, ProjectionImplementation, ProjectionName, ProjectionOptions} from "./projection.js"; import type {Scale, ScaleDefaults, ScaleName, ScaleOptions} from "./scales.js"; +type ScaleLegendOptions = ScaleOptions & Omit; + export interface PlotOptions extends ScaleDefaults { // dimensions @@ -199,7 +201,7 @@ export interface PlotOptions extends ScaleDefaults { * If the *x* scale is present, and an *x*-axis mark is not included in marks, * an implicit *x*-axis will be rendered below other marks. */ - x?: ScaleOptions; + x?: ScaleLegendOptions; /** * Options for the vertical position *y* scale. The *y* scale defaults to the @@ -211,7 +213,7 @@ export interface PlotOptions extends ScaleDefaults { * If the *y* scale is present, and a *y*-axis mark is not included in marks, * an implicit *y*-axis will be rendered below other marks. */ - y?: ScaleOptions; + y?: ScaleLegendOptions; /** * Options for the radius (size) *r* scale for dots or Point geos. The *r* @@ -228,7 +230,7 @@ export interface PlotOptions extends ScaleDefaults { * * [1]: https://github.com/observablehq/plot/issues/236 */ - r?: ScaleOptions; + r?: ScaleLegendOptions; /** * Options for the *color* scale for fill or stroke. The *color* scale @@ -244,7 +246,7 @@ export interface PlotOptions extends ScaleDefaults { * scale associated with a channel by specifying the value as a {value, scale} * object. */ - color?: ScaleOptions; + color?: ScaleLegendOptions; /** * Options for the *opacity* scale for fill or stroke opacity. The *opacity* @@ -257,7 +259,7 @@ export interface PlotOptions extends ScaleDefaults { * override the scale associated with a channel by specifying the value as a * {value, scale} object. */ - opacity?: ScaleOptions; + opacity?: ScaleLegendOptions; /** * Options for the categorical *symbol* scale for dots. The *symbol* scale @@ -270,7 +272,7 @@ export interface PlotOptions extends ScaleDefaults { * override the scale associated with a channel by specifying the value as a * {value, scale} object. */ - symbol?: ScaleOptions; + symbol?: ScaleLegendOptions; /** * Options for the *length* scale for vectors. The *length* scale defaults to @@ -279,7 +281,7 @@ export interface PlotOptions extends ScaleDefaults { * range is chosen such that the median of values has a length of 12 pixels, * but no value has a length greater than 60 pixels. */ - length?: ScaleOptions; + length?: ScaleLegendOptions; /** * Options for projection; one of: @@ -302,13 +304,13 @@ export interface PlotOptions extends ScaleDefaults { * Options for the horizontal facet position *fx* scale. If present, the *fx* * scale is always a *band* scale. */ - fx?: ScaleOptions; + fx?: ScaleLegendOptions; /** * Options for the vertical facet position *fy* scale. If present, the *fy* * scale is always a *band* scale. */ - fy?: ScaleOptions; + fy?: ScaleLegendOptions; /** * Options for faceting, including shorthand options for the *fx* and *fy* @@ -385,12 +387,12 @@ export interface PlotFacetOptions { /** * Default axis grid for fx and fy scales; typically set to true to enable. */ - grid?: ScaleOptions["grid"]; + grid?: ScaleLegendOptions["grid"]; /** * Default axis label for fx and fy scales; typically set to null to disable. */ - label?: ScaleOptions["label"]; + label?: ScaleLegendOptions["label"]; } /** diff --git a/test/output/colorLegendLarge.html b/test/output/colorLegendLarge.html new file mode 100644 index 0000000000..d6b92257e1 --- /dev/null +++ b/test/output/colorLegendLarge.html @@ -0,0 +1,47 @@ +
+ + + A + + B + + C + + D + + E + + F + + G + + H + + I + + J +
\ No newline at end of file diff --git a/test/output/colorLegendLargeChart.html b/test/output/colorLegendLargeChart.html new file mode 100644 index 0000000000..fd10602176 --- /dev/null +++ b/test/output/colorLegendLargeChart.html @@ -0,0 +1,100 @@ +
+
+ + + A + + B + + C + + D + + E + + F + + G + + H + + I + + J +
+ + + + A + B + C + D + E + F + G + H + I + J + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/test/plots/legend-color.ts b/test/plots/legend-color.ts index 744e850f4f..489ca415ae 100644 --- a/test/plots/legend-color.ts +++ b/test/plots/legend-color.ts @@ -62,6 +62,28 @@ export function colorLegendOrdinalScheme() { return Plot.legend({color: {type: "ordinal", domain: "ABCDEFGHIJ", scheme: "rainbow"}}); } +export function colorLegendLarge() { + return Plot.legend({ + color: {type: "ordinal", domain: "ABCDEFGHIJ", scheme: "rainbow"}, + className: "legend", + style: {fontSize: "16px"} + }); +} + +export function colorLegendLargeChart() { + return Plot.plot({ + color: { + legend: true, + type: "ordinal", + scheme: "rainbow", + className: "legend", + style: {fontSize: "16px"} + }, + style: {fontSize: "7px"}, + marks: [Plot.cell("ABCDEFGHIJ", {x: Plot.identity, fill: Plot.identity})] + }); +} + export function colorLegendOrdinalSchemeRamp() { return Plot.legend({color: {type: "ordinal", domain: "ABCDEFGHIJ", scheme: "rainbow"}, legend: "ramp"}); }