@opendata-ai/openchart-core 6.10.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +89 -12
- package/dist/index.js +16 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/layout/__tests__/chrome.test.ts +15 -0
- package/src/layout/chrome.ts +6 -4
- package/src/types/__tests__/gradient.test.ts +95 -0
- package/src/types/index.ts +6 -0
- package/src/types/layout.ts +17 -8
- package/src/types/spec.ts +93 -2
package/dist/index.d.ts
CHANGED
|
@@ -180,6 +180,65 @@ interface ColumnConfig {
|
|
|
180
180
|
type MarkType = 'bar' | 'line' | 'area' | 'point' | 'circle' | 'arc' | 'text' | 'rule' | 'tick' | 'rect' | 'lollipop';
|
|
181
181
|
/** @deprecated Use MarkType instead. Kept for internal migration references. */
|
|
182
182
|
type ChartType = MarkType;
|
|
183
|
+
/** A single color stop in a gradient definition. */
|
|
184
|
+
interface GradientStop {
|
|
185
|
+
/** Position along the gradient, 0 to 1. */
|
|
186
|
+
offset: number;
|
|
187
|
+
/** CSS color string at this stop. */
|
|
188
|
+
color: string;
|
|
189
|
+
/** Opacity at this stop, 0 to 1. Maps to SVG stop-opacity. */
|
|
190
|
+
opacity?: number;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Linear gradient definition.
|
|
194
|
+
* Coordinates are in [0,1] normalized space relative to the mark's bounding box
|
|
195
|
+
* (maps to SVG gradientUnits="objectBoundingBox").
|
|
196
|
+
*/
|
|
197
|
+
interface LinearGradient {
|
|
198
|
+
gradient: 'linear';
|
|
199
|
+
/** Color stops from start to end. */
|
|
200
|
+
stops: GradientStop[];
|
|
201
|
+
/** Start x coordinate (0-1). Default: 0. */
|
|
202
|
+
x1?: number;
|
|
203
|
+
/** Start y coordinate (0-1). Default: 0. */
|
|
204
|
+
y1?: number;
|
|
205
|
+
/** End x coordinate (0-1). Default: 0. */
|
|
206
|
+
x2?: number;
|
|
207
|
+
/** End y coordinate (0-1). Default: 1 (top-to-bottom). */
|
|
208
|
+
y2?: number;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Radial gradient definition.
|
|
212
|
+
* Coordinates are in [0,1] normalized space relative to the mark's bounding box.
|
|
213
|
+
*/
|
|
214
|
+
interface RadialGradient {
|
|
215
|
+
gradient: 'radial';
|
|
216
|
+
/** Color stops from inner to outer. */
|
|
217
|
+
stops: GradientStop[];
|
|
218
|
+
/** Inner circle center x (0-1). Default: 0.5. */
|
|
219
|
+
x1?: number;
|
|
220
|
+
/** Inner circle center y (0-1). Default: 0.5. */
|
|
221
|
+
y1?: number;
|
|
222
|
+
/** Inner circle radius (0-1). Default: 0. */
|
|
223
|
+
r1?: number;
|
|
224
|
+
/** Outer circle center x (0-1). Default: 0.5. */
|
|
225
|
+
x2?: number;
|
|
226
|
+
/** Outer circle center y (0-1). Default: 0.5. */
|
|
227
|
+
y2?: number;
|
|
228
|
+
/** Outer circle radius (0-1). Default: 0.5. */
|
|
229
|
+
r2?: number;
|
|
230
|
+
}
|
|
231
|
+
/** A gradient definition, either linear or radial. */
|
|
232
|
+
type GradientDef = LinearGradient | RadialGradient;
|
|
233
|
+
/** Type guard: check if a value is a GradientDef object. */
|
|
234
|
+
declare function isGradientDef(value: unknown): value is GradientDef;
|
|
235
|
+
/**
|
|
236
|
+
* Extract a single representative color from a fill value.
|
|
237
|
+
* Returns the fill directly if it's a string, or the last stop color
|
|
238
|
+
* if it's a gradient. Used by tooltips, labels, legends, and voronoi
|
|
239
|
+
* overlays that need a flat color.
|
|
240
|
+
*/
|
|
241
|
+
declare function getRepresentativeColor(fill: string | GradientDef): string;
|
|
183
242
|
/**
|
|
184
243
|
* Mark definition object with visual properties.
|
|
185
244
|
*
|
|
@@ -214,8 +273,8 @@ interface MarkDef {
|
|
|
214
273
|
filled?: boolean;
|
|
215
274
|
/** Default opacity (0-1). */
|
|
216
275
|
opacity?: number;
|
|
217
|
-
/** Default fill color. */
|
|
218
|
-
fill?: string;
|
|
276
|
+
/** Default fill color or gradient. */
|
|
277
|
+
fill?: string | GradientDef;
|
|
219
278
|
/** Default stroke color. */
|
|
220
279
|
stroke?: string;
|
|
221
280
|
/** Default stroke width. */
|
|
@@ -756,6 +815,8 @@ interface ChartSpec {
|
|
|
756
815
|
theme?: ThemeConfig;
|
|
757
816
|
/** Dark mode behavior. Defaults to "off". */
|
|
758
817
|
darkMode?: DarkMode;
|
|
818
|
+
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
819
|
+
watermark?: boolean;
|
|
759
820
|
/** Series names to hide from rendering. Hidden series remain in the legend but are visually dimmed. */
|
|
760
821
|
hiddenSeries?: string[];
|
|
761
822
|
/** Per-series visual overrides, keyed by series name (the color field value). */
|
|
@@ -795,6 +856,8 @@ interface TableSpec {
|
|
|
795
856
|
theme?: ThemeConfig;
|
|
796
857
|
/** Dark mode behavior. */
|
|
797
858
|
darkMode?: DarkMode;
|
|
859
|
+
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
860
|
+
watermark?: boolean;
|
|
798
861
|
/** Enable client-side search/filter. */
|
|
799
862
|
search?: boolean;
|
|
800
863
|
/** Pagination configuration. True for defaults, or an object with pageSize. */
|
|
@@ -860,6 +923,8 @@ interface GraphSpec {
|
|
|
860
923
|
theme?: ThemeConfig;
|
|
861
924
|
/** Dark mode behavior. */
|
|
862
925
|
darkMode?: DarkMode;
|
|
926
|
+
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
927
|
+
watermark?: boolean;
|
|
863
928
|
}
|
|
864
929
|
/**
|
|
865
930
|
* Resolution strategy for shared resources across layers.
|
|
@@ -906,6 +971,8 @@ interface LayerSpec {
|
|
|
906
971
|
theme?: ThemeConfig;
|
|
907
972
|
/** Dark mode behavior. Defaults to "off". */
|
|
908
973
|
darkMode?: DarkMode;
|
|
974
|
+
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
975
|
+
watermark?: boolean;
|
|
909
976
|
/** Resolution strategy for shared scales/axes/legends. */
|
|
910
977
|
resolve?: ResolveConfig;
|
|
911
978
|
/** Hidden series names. */
|
|
@@ -964,6 +1031,8 @@ interface SankeySpec {
|
|
|
964
1031
|
theme?: ThemeConfig;
|
|
965
1032
|
/** Dark mode behavior. Defaults to "off". */
|
|
966
1033
|
darkMode?: DarkMode;
|
|
1034
|
+
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
1035
|
+
watermark?: boolean;
|
|
967
1036
|
/** Animation configuration for entrance animations. */
|
|
968
1037
|
animation?: AnimationSpec;
|
|
969
1038
|
/**
|
|
@@ -1680,8 +1749,8 @@ interface AreaMark {
|
|
|
1680
1749
|
path: string;
|
|
1681
1750
|
/** SVG path string for just the top boundary (for stroking the data line only). */
|
|
1682
1751
|
topPath: string;
|
|
1683
|
-
/** Fill color. */
|
|
1684
|
-
fill: string;
|
|
1752
|
+
/** Fill color or gradient. */
|
|
1753
|
+
fill: string | GradientDef;
|
|
1685
1754
|
/** Fill opacity. */
|
|
1686
1755
|
fillOpacity: number;
|
|
1687
1756
|
/** Optional stroke for the top boundary. */
|
|
@@ -1721,8 +1790,8 @@ interface RectMark {
|
|
|
1721
1790
|
width: number;
|
|
1722
1791
|
/** Height. */
|
|
1723
1792
|
height: number;
|
|
1724
|
-
/** Fill color. */
|
|
1725
|
-
fill: string;
|
|
1793
|
+
/** Fill color or gradient. */
|
|
1794
|
+
fill: string | GradientDef;
|
|
1726
1795
|
/** Stroke color. */
|
|
1727
1796
|
stroke?: string;
|
|
1728
1797
|
/** Stroke width. */
|
|
@@ -1764,8 +1833,8 @@ interface ArcMark {
|
|
|
1764
1833
|
startAngle: number;
|
|
1765
1834
|
/** End angle in radians. */
|
|
1766
1835
|
endAngle: number;
|
|
1767
|
-
/** Fill color. */
|
|
1768
|
-
fill: string;
|
|
1836
|
+
/** Fill color or gradient. */
|
|
1837
|
+
fill: string | GradientDef;
|
|
1769
1838
|
/** Stroke color (usually white for slice separation). */
|
|
1770
1839
|
stroke: string;
|
|
1771
1840
|
/** Stroke width. */
|
|
@@ -1791,8 +1860,8 @@ interface PointMark {
|
|
|
1791
1860
|
cy: number;
|
|
1792
1861
|
/** Radius in pixels. */
|
|
1793
1862
|
r: number;
|
|
1794
|
-
/** Fill color. */
|
|
1795
|
-
fill: string;
|
|
1863
|
+
/** Fill color or gradient. */
|
|
1864
|
+
fill: string | GradientDef;
|
|
1796
1865
|
/** Stroke color. */
|
|
1797
1866
|
stroke: string;
|
|
1798
1867
|
/** Stroke width. */
|
|
@@ -2065,6 +2134,8 @@ interface ChartLayout {
|
|
|
2065
2134
|
};
|
|
2066
2135
|
/** Resolved animation config. Present only when animation is enabled. */
|
|
2067
2136
|
animation?: ResolvedAnimation;
|
|
2137
|
+
/** Whether the tryOpenData.ai watermark is enabled. */
|
|
2138
|
+
watermark: boolean;
|
|
2068
2139
|
}
|
|
2069
2140
|
/** A resolved column definition with computed properties. */
|
|
2070
2141
|
interface ResolvedColumn {
|
|
@@ -2225,6 +2296,8 @@ interface TableLayout {
|
|
|
2225
2296
|
theme: ResolvedTheme;
|
|
2226
2297
|
/** Resolved animation config. Present only when animation is enabled. */
|
|
2227
2298
|
animation?: ResolvedAnimation;
|
|
2299
|
+
/** Whether the tryOpenData.ai watermark is enabled. */
|
|
2300
|
+
watermark: boolean;
|
|
2228
2301
|
}
|
|
2229
2302
|
/** A resolved graph node with computed position and visual properties. */
|
|
2230
2303
|
interface GraphNodeLayout {
|
|
@@ -2394,6 +2467,8 @@ interface SankeyLayout {
|
|
|
2394
2467
|
};
|
|
2395
2468
|
/** Resolved animation config. Present only when animation is enabled. */
|
|
2396
2469
|
animation?: ResolvedAnimation;
|
|
2470
|
+
/** Whether the tryOpenData.ai watermark is enabled. */
|
|
2471
|
+
watermark: boolean;
|
|
2397
2472
|
}
|
|
2398
2473
|
/** Function signature for text measurement provided by adapters. */
|
|
2399
2474
|
type MeasureTextFn = (text: string, fontSize: number, fontWeight?: number) => {
|
|
@@ -2421,6 +2496,8 @@ interface CompileOptions {
|
|
|
2421
2496
|
* before calling compile. The engine always receives a resolved boolean.
|
|
2422
2497
|
*/
|
|
2423
2498
|
darkMode?: boolean;
|
|
2499
|
+
/** Whether to show the tryOpenData.ai watermark. Defaults to true. */
|
|
2500
|
+
watermark?: boolean;
|
|
2424
2501
|
/**
|
|
2425
2502
|
* Real text measurement function provided by the adapter.
|
|
2426
2503
|
* Uses a hidden canvas or DOM element for accurate text dimensions.
|
|
@@ -2616,7 +2693,7 @@ declare function resolveTheme(userTheme?: ThemeConfig, base?: Theme): ResolvedTh
|
|
|
2616
2693
|
* @param chromeMode - Chrome display mode: full, compact (title only), or hidden.
|
|
2617
2694
|
* @param padding - Override padding (for scaled padding from dimensions).
|
|
2618
2695
|
*/
|
|
2619
|
-
declare function computeChrome(chrome: Chrome | undefined, theme: ResolvedTheme, width: number, measureText?: MeasureTextFn, chromeMode?: ChromeMode, padding?: number): ResolvedChrome;
|
|
2696
|
+
declare function computeChrome(chrome: Chrome | undefined, theme: ResolvedTheme, width: number, measureText?: MeasureTextFn, chromeMode?: ChromeMode, padding?: number, watermark?: boolean): ResolvedChrome;
|
|
2620
2697
|
|
|
2621
2698
|
/**
|
|
2622
2699
|
* Estimate the rendered width of a text string.
|
|
@@ -2963,4 +3040,4 @@ declare function scatterChart(data: DataRow[], x: FieldRef, y: FieldRef, options
|
|
|
2963
3040
|
*/
|
|
2964
3041
|
declare function dataTable(data: DataRow[], options?: TableBuilderOptions): TableSpec;
|
|
2965
3042
|
|
|
2966
|
-
export { type A11yMetadata, type AggregateOp, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationOffset, type AnnotationPosition, type ArcMark, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, type BarColumnConfig, type BarTableCell, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_PALETTE, CHART_ENCODING_RULES, CHART_TYPES, type CalculateExpression, type CalculateTransform, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type ChartType, type Chrome, type ChromeDefaults, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type Condition, type ConditionalValueDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type FieldPredicate, type FieldRef, type FieldType, type FilterPredicate, type FilterTransform, type FlagTableCell, GRAPH_ENCODING_RULES, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type ImageColumnConfig, type ImageTableCell, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LayerSpec, type LayoutStrategy, type LegendConfig, type LegendEntry, type LegendLayout, type LegendPosition, type LineMark, type LogicalAnd, type LogicalNot, type LogicalOr, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type NodeOverride, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type Point, type PointMark, type RangeAnnotation, type Rect, type RectMark, type RefLineAnnotation, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedColumn, type ResolvedLabel, type ResolvedTheme, type RuleMarkLayout, SEQUENTIAL_PALETTES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleType, type SequentialPalette, type SeriesStyle, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, type TableBuilderOptions, type TableCell, type TableCellBase, type TableLayout, type TableRow, type TableSpec, type TableSpecWithoutData, type TextAnnotation, type TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeSpacing, type TickMarkLayout, type TimeUnit, type TimeUnitTransform, type TooltipContent, type TooltipField, type Transform, type VizSpec, abbreviateNumber, adaptColorForDarkMode, adaptTheme, areaChart, barChart, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeLabelBounds, contrastRatio, dataTable, detectCollision, donutChart, dotChart, elementRef, estimateTextWidth, findAccessibleColor, formatDate, formatNumber, generateAltText, generateAriaLabels, generateDataTable, getBreakpoint, getHeightClass, getLayoutStrategy, inferFieldType, isChartSpec, isConditionalDef, isEncodingChannel, isGraphSpec, isLayerSpec, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, lineChart, meetsAA, pieChart, resolveCollisions, resolveMarkDef, resolveMarkType, resolveTheme, scatterChart, simulateColorBlindness };
|
|
3043
|
+
export { type A11yMetadata, type AggregateOp, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationOffset, type AnnotationPosition, type ArcMark, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, type BarColumnConfig, type BarTableCell, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_PALETTE, CHART_ENCODING_RULES, CHART_TYPES, type CalculateExpression, type CalculateTransform, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type ChartType, type Chrome, type ChromeDefaults, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type Condition, type ConditionalValueDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type FieldPredicate, type FieldRef, type FieldType, type FilterPredicate, type FilterTransform, type FlagTableCell, GRAPH_ENCODING_RULES, type GradientDef, type GradientStop, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type ImageColumnConfig, type ImageTableCell, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LayerSpec, type LayoutStrategy, type LegendConfig, type LegendEntry, type LegendLayout, type LegendPosition, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type NodeOverride, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type Point, type PointMark, type RadialGradient, type RangeAnnotation, type Rect, type RectMark, type RefLineAnnotation, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedColumn, type ResolvedLabel, type ResolvedTheme, type RuleMarkLayout, SEQUENTIAL_PALETTES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleType, type SequentialPalette, type SeriesStyle, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, type TableBuilderOptions, type TableCell, type TableCellBase, type TableLayout, type TableRow, type TableSpec, type TableSpecWithoutData, type TextAnnotation, type TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeSpacing, type TickMarkLayout, type TimeUnit, type TimeUnitTransform, type TooltipContent, type TooltipField, type Transform, type VizSpec, abbreviateNumber, adaptColorForDarkMode, adaptTheme, areaChart, barChart, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeLabelBounds, contrastRatio, dataTable, detectCollision, donutChart, dotChart, elementRef, estimateTextWidth, findAccessibleColor, formatDate, formatNumber, generateAltText, generateAriaLabels, generateDataTable, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, inferFieldType, isChartSpec, isConditionalDef, isEncodingChannel, isGradientDef, isGraphSpec, isLayerSpec, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, lineChart, meetsAA, pieChart, resolveCollisions, resolveMarkDef, resolveMarkType, resolveTheme, scatterChart, simulateColorBlindness };
|
package/dist/index.js
CHANGED
|
@@ -161,6 +161,14 @@ var elementRef = {
|
|
|
161
161
|
};
|
|
162
162
|
|
|
163
163
|
// src/types/spec.ts
|
|
164
|
+
function isGradientDef(value) {
|
|
165
|
+
return typeof value === "object" && value !== null && "gradient" in value && "stops" in value && (value.gradient === "linear" || value.gradient === "radial");
|
|
166
|
+
}
|
|
167
|
+
function getRepresentativeColor(fill) {
|
|
168
|
+
if (typeof fill === "string") return fill;
|
|
169
|
+
const stops = fill.stops;
|
|
170
|
+
return stops.length > 0 ? stops[stops.length - 1].color : "#000000";
|
|
171
|
+
}
|
|
164
172
|
function isEncodingChannel(def) {
|
|
165
173
|
if (!def) return false;
|
|
166
174
|
return "field" in def && !("condition" in def);
|
|
@@ -1100,7 +1108,7 @@ function estimateLineCount(text, style, maxWidth, _measureText) {
|
|
|
1100
1108
|
}
|
|
1101
1109
|
return lines;
|
|
1102
1110
|
}
|
|
1103
|
-
function computeChrome(chrome, theme, width, measureText, chromeMode = "full", padding) {
|
|
1111
|
+
function computeChrome(chrome, theme, width, measureText, chromeMode = "full", padding, watermark = true) {
|
|
1104
1112
|
if (!chrome || chromeMode === "hidden") {
|
|
1105
1113
|
return { topHeight: 0, bottomHeight: 0 };
|
|
1106
1114
|
}
|
|
@@ -1154,7 +1162,7 @@ function computeChrome(chrome, theme, width, measureText, chromeMode = "full", p
|
|
|
1154
1162
|
const topHeight = hasTopChrome ? topY - pad2 + theme.spacing.chromeToChart - chromeGap : 0;
|
|
1155
1163
|
if (chromeMode === "compact") {
|
|
1156
1164
|
let compactBottom = 0;
|
|
1157
|
-
if (width >= BRAND_MIN_WIDTH) {
|
|
1165
|
+
if (watermark && width >= BRAND_MIN_WIDTH) {
|
|
1158
1166
|
const brandHeight = estimateTextHeight(BRAND_FONT_SIZE, 1);
|
|
1159
1167
|
compactBottom = theme.spacing.chartToFooter + brandHeight + pad2;
|
|
1160
1168
|
}
|
|
@@ -1164,7 +1172,8 @@ function computeChrome(chrome, theme, width, measureText, chromeMode = "full", p
|
|
|
1164
1172
|
...topElements
|
|
1165
1173
|
};
|
|
1166
1174
|
}
|
|
1167
|
-
const
|
|
1175
|
+
const shouldReserveBrandWidth = watermark && width >= BRAND_MIN_WIDTH;
|
|
1176
|
+
const bottomMaxWidth = maxWidth - (shouldReserveBrandWidth ? BRAND_RESERVE_WIDTH : 0);
|
|
1168
1177
|
const bottomElements = {};
|
|
1169
1178
|
let bottomHeight = 0;
|
|
1170
1179
|
const bottomItems = [];
|
|
@@ -1215,7 +1224,7 @@ function computeChrome(chrome, theme, width, measureText, chromeMode = "full", p
|
|
|
1215
1224
|
bottomHeight += height + chromeGap;
|
|
1216
1225
|
}
|
|
1217
1226
|
bottomHeight -= chromeGap;
|
|
1218
|
-
if (width >= BRAND_MIN_WIDTH) {
|
|
1227
|
+
if (watermark && width >= BRAND_MIN_WIDTH) {
|
|
1219
1228
|
const brandHeight = estimateTextHeight(BRAND_FONT_SIZE, 1);
|
|
1220
1229
|
const contentBelowFirstItem = bottomHeight - theme.spacing.chartToFooter;
|
|
1221
1230
|
if (brandHeight > contentBelowFirstItem) {
|
|
@@ -1223,7 +1232,7 @@ function computeChrome(chrome, theme, width, measureText, chromeMode = "full", p
|
|
|
1223
1232
|
}
|
|
1224
1233
|
}
|
|
1225
1234
|
bottomHeight += pad2;
|
|
1226
|
-
} else if (width >= BRAND_MIN_WIDTH) {
|
|
1235
|
+
} else if (watermark && width >= BRAND_MIN_WIDTH) {
|
|
1227
1236
|
const brandHeight = estimateTextHeight(BRAND_FONT_SIZE, 1);
|
|
1228
1237
|
bottomHeight = theme.spacing.chartToFooter + brandHeight + pad2;
|
|
1229
1238
|
}
|
|
@@ -2782,10 +2791,12 @@ export {
|
|
|
2782
2791
|
getBreakpoint,
|
|
2783
2792
|
getHeightClass,
|
|
2784
2793
|
getLayoutStrategy,
|
|
2794
|
+
getRepresentativeColor,
|
|
2785
2795
|
inferFieldType,
|
|
2786
2796
|
isChartSpec,
|
|
2787
2797
|
isConditionalDef,
|
|
2788
2798
|
isEncodingChannel,
|
|
2799
|
+
isGradientDef,
|
|
2789
2800
|
isGraphSpec,
|
|
2790
2801
|
isLayerSpec,
|
|
2791
2802
|
isRangeAnnotation,
|