@opendata-ai/openchart-core 8.5.2 → 8.6.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 +123 -3
- package/dist/index.js +44 -3
- package/dist/index.js.map +1 -1
- package/dist/styles.css.map +1 -1
- package/package.json +1 -1
- package/schema/chart.schema.json +1486 -71
- package/schema/vizspec.schema.json +6342 -3475
package/dist/index.d.ts
CHANGED
|
@@ -720,6 +720,13 @@ interface RectMark {
|
|
|
720
720
|
fill: string | GradientDef;
|
|
721
721
|
/** Resolved fill pattern. Present only when `mark.fillPattern: 'auto'` assigned one. */
|
|
722
722
|
pattern?: ResolvedFillPattern;
|
|
723
|
+
/**
|
|
724
|
+
* Fill opacity, independent of stroke. Omitted means fully opaque; the
|
|
725
|
+
* renderer emits no `fill-opacity` attribute in that case, so an ordinary
|
|
726
|
+
* bar's serialized SVG is unchanged. Set by the binned-bar renderer when
|
|
727
|
+
* color groups overlap at the same x.
|
|
728
|
+
*/
|
|
729
|
+
fillOpacity?: number;
|
|
723
730
|
/** Stroke color. */
|
|
724
731
|
stroke?: string;
|
|
725
732
|
/** Stroke width. */
|
|
@@ -2670,8 +2677,12 @@ interface ColumnConfig {
|
|
|
2670
2677
|
* - 'waffle': unit grids ("x of 100") for part-to-whole counts
|
|
2671
2678
|
* - 'calendar': GitHub-style calendar heatmap (weeks x weekdays, daily dates)
|
|
2672
2679
|
* - 'parliament': hemicycle seat-dot chart for election/legislature results
|
|
2680
|
+
* - 'histogram': binned bars over a continuous field; sugar for a bar with
|
|
2681
|
+
* `x.bin` + `y: { aggregate: 'count' }`
|
|
2682
|
+
* - 'density': kernel density estimate drawn as a filled curve; sugar for an
|
|
2683
|
+
* area over a density transform
|
|
2673
2684
|
*/
|
|
2674
|
-
type MarkType = 'bar' | 'line' | 'area' | 'point' | 'circle' | 'arc' | 'text' | 'rule' | 'tick' | 'rect' | 'lollipop' | 'beeswarm' | 'range' | 'waffle' | 'calendar' | 'parliament';
|
|
2685
|
+
type MarkType = 'bar' | 'line' | 'area' | 'point' | 'circle' | 'arc' | 'text' | 'rule' | 'tick' | 'rect' | 'lollipop' | 'beeswarm' | 'range' | 'waffle' | 'calendar' | 'parliament' | 'histogram' | 'density';
|
|
2675
2686
|
/** A single color stop in a gradient definition. */
|
|
2676
2687
|
interface GradientStop {
|
|
2677
2688
|
/** Position along the gradient, 0 to 1. */
|
|
@@ -2824,6 +2835,43 @@ interface MarkDef {
|
|
|
2824
2835
|
filled?: boolean;
|
|
2825
2836
|
/** Default opacity (0-1). */
|
|
2826
2837
|
opacity?: number;
|
|
2838
|
+
/**
|
|
2839
|
+
* Fill opacity (0-1), independent of stroke (Vega-Lite aligned).
|
|
2840
|
+
*
|
|
2841
|
+
* On a binned bar with more than one color group this defaults to 0.55 so
|
|
2842
|
+
* overlapping distributions stay readable; set it explicitly to override.
|
|
2843
|
+
* On an area, setting it switches the fill from the default gradient to a
|
|
2844
|
+
* flat translucent series color — gradients and overlapping fills don't mix.
|
|
2845
|
+
*/
|
|
2846
|
+
fillOpacity?: number;
|
|
2847
|
+
/**
|
|
2848
|
+
* Number of bins. Only meaningful when `type` is `'histogram'`; desugars to
|
|
2849
|
+
* `x.bin.maxbins`. Defaults to 20. For a fixed bin width or a pinned
|
|
2850
|
+
* extent, write `x.bin` directly — it is the canonical form and takes
|
|
2851
|
+
* precedence over this shorthand.
|
|
2852
|
+
*/
|
|
2853
|
+
binCount?: number;
|
|
2854
|
+
/**
|
|
2855
|
+
* Plot each group's share of its own total instead of a raw count. Only
|
|
2856
|
+
* meaningful when `type` is `'histogram'`. Makes two distributions of very
|
|
2857
|
+
* different size directly comparable.
|
|
2858
|
+
*/
|
|
2859
|
+
normalize?: boolean;
|
|
2860
|
+
/**
|
|
2861
|
+
* Gaussian kernel bandwidth. Only meaningful when `type` is `'density'`.
|
|
2862
|
+
* Omitted uses Silverman's rule of thumb.
|
|
2863
|
+
*/
|
|
2864
|
+
bandwidth?: number;
|
|
2865
|
+
/**
|
|
2866
|
+
* Draw the cumulative distribution instead of the density. Only meaningful
|
|
2867
|
+
* when `type` is `'density'`.
|
|
2868
|
+
*/
|
|
2869
|
+
cumulative?: boolean;
|
|
2870
|
+
/**
|
|
2871
|
+
* Number of points the density curve is evaluated at. Only meaningful when
|
|
2872
|
+
* `type` is `'density'`. Defaults to 200.
|
|
2873
|
+
*/
|
|
2874
|
+
steps?: number;
|
|
2827
2875
|
/** Default fill color or gradient. */
|
|
2828
2876
|
fill?: string | GradientDef;
|
|
2829
2877
|
/** Default stroke color. */
|
|
@@ -4276,6 +4324,25 @@ interface WaffleEncoding<TData extends DataRow = DataRow> extends Encoding<TData
|
|
|
4276
4324
|
interface ParliamentEncoding<TData extends DataRow = DataRow> extends Encoding<TData> {
|
|
4277
4325
|
color: EncodingChannel<TData> | ConditionalValueDef<TData>;
|
|
4278
4326
|
}
|
|
4327
|
+
/**
|
|
4328
|
+
* Encoding for histogram marks (binned bars over a continuous field).
|
|
4329
|
+
* - `x`: required quantitative, the raw values to bin (not pre-binned)
|
|
4330
|
+
* - `y`: optional; defaults to the per-bin count
|
|
4331
|
+
* - `color`: optional grouping. Groups overlap at the same bins rather than
|
|
4332
|
+
* dodging or stacking, so two distributions can be compared by shape.
|
|
4333
|
+
*/
|
|
4334
|
+
interface HistogramEncoding<TData extends DataRow = DataRow> extends Encoding<TData> {
|
|
4335
|
+
x: EncodingChannel<TData>;
|
|
4336
|
+
}
|
|
4337
|
+
/**
|
|
4338
|
+
* Encoding for density marks (kernel density estimates).
|
|
4339
|
+
* - `x`: required quantitative, the raw values to estimate over
|
|
4340
|
+
* - `y`: computed by the density transform, not authored
|
|
4341
|
+
* - `color`: optional grouping, one translucent curve per group
|
|
4342
|
+
*/
|
|
4343
|
+
interface DensityEncoding<TData extends DataRow = DataRow> extends Encoding<TData> {
|
|
4344
|
+
x: EncodingChannel<TData>;
|
|
4345
|
+
}
|
|
4279
4346
|
/**
|
|
4280
4347
|
* Encoding for calendar marks (GitHub-style calendar heatmaps).
|
|
4281
4348
|
* - `x`: required (temporal, daily dates, one row per day)
|
|
@@ -4629,6 +4696,16 @@ type ChartSpec<TData extends DataRow = DataRow> = (BaseChartSpec<TData> & {
|
|
|
4629
4696
|
type: 'parliament';
|
|
4630
4697
|
});
|
|
4631
4698
|
encoding: ParliamentEncoding<TData>;
|
|
4699
|
+
}) | (BaseChartSpec<TData> & {
|
|
4700
|
+
mark: 'histogram' | (MarkDef & {
|
|
4701
|
+
type: 'histogram';
|
|
4702
|
+
});
|
|
4703
|
+
encoding: HistogramEncoding<TData>;
|
|
4704
|
+
}) | (BaseChartSpec<TData> & {
|
|
4705
|
+
mark: 'density' | (MarkDef & {
|
|
4706
|
+
type: 'density';
|
|
4707
|
+
});
|
|
4708
|
+
encoding: DensityEncoding<TData>;
|
|
4632
4709
|
});
|
|
4633
4710
|
/** Row density for tables. Maps to 40 / 48 / 56px row heights. */
|
|
4634
4711
|
type TableDensity = 'condensed' | 'regular' | 'relaxed';
|
|
@@ -5398,6 +5475,49 @@ interface TimeUnitTransform {
|
|
|
5398
5475
|
field: string;
|
|
5399
5476
|
as: string;
|
|
5400
5477
|
}
|
|
5478
|
+
/**
|
|
5479
|
+
* Density transform: kernel density estimate over a quantitative field
|
|
5480
|
+
* (Vega-Lite aligned).
|
|
5481
|
+
*
|
|
5482
|
+
* Produces a new dataset — one row per evaluation point, per group — rather
|
|
5483
|
+
* than adding fields to the input rows. The output is what an area mark plots.
|
|
5484
|
+
*/
|
|
5485
|
+
interface DensityTransform {
|
|
5486
|
+
/** Field of raw values to estimate the density of. */
|
|
5487
|
+
density: string;
|
|
5488
|
+
/** Group the estimate by these fields; one curve per group. */
|
|
5489
|
+
groupby?: string[];
|
|
5490
|
+
/** Gaussian kernel bandwidth. Omitted or 0 uses Silverman's rule of thumb. */
|
|
5491
|
+
bandwidth?: number;
|
|
5492
|
+
/** [min, max] to evaluate over. Defaults to the data extent, padded to close the tails. */
|
|
5493
|
+
extent?: [number, number];
|
|
5494
|
+
/** Emit the cumulative distribution instead of the density. */
|
|
5495
|
+
cumulative?: boolean;
|
|
5496
|
+
/** Scale the curve by the group's row count instead of integrating to 1. */
|
|
5497
|
+
counts?: boolean;
|
|
5498
|
+
/** Number of evaluation points. Default 200. */
|
|
5499
|
+
steps?: number;
|
|
5500
|
+
/** Output field names. Default ['value', 'density']. */
|
|
5501
|
+
as?: [string, string];
|
|
5502
|
+
}
|
|
5503
|
+
/**
|
|
5504
|
+
* Join-aggregate transform: compute group summaries and write them back onto
|
|
5505
|
+
* every row of the group (VL aligned).
|
|
5506
|
+
*
|
|
5507
|
+
* The difference from `AggregateTransform` is the row count: `aggregate`
|
|
5508
|
+
* collapses a group to one row, `joinaggregate` keeps every row and adds the
|
|
5509
|
+
* group's summary as a new field. That is what makes "this row's value as a
|
|
5510
|
+
* share of its group's total" expressible — compute the total, then divide.
|
|
5511
|
+
*/
|
|
5512
|
+
interface JoinAggregateTransform {
|
|
5513
|
+
joinaggregate: Array<{
|
|
5514
|
+
op: AggregateOp;
|
|
5515
|
+
field: string;
|
|
5516
|
+
as: string;
|
|
5517
|
+
}>;
|
|
5518
|
+
/** Fields to group by. Omitted or empty treats all rows as one group. */
|
|
5519
|
+
groupby?: string[];
|
|
5520
|
+
}
|
|
5401
5521
|
/**
|
|
5402
5522
|
* Aggregate transform: group rows and compute summary statistics (VL aligned).
|
|
5403
5523
|
* Produces one row per group with the groupby fields and computed aggregates.
|
|
@@ -5444,7 +5564,7 @@ interface WindowTransform {
|
|
|
5444
5564
|
groupby?: string[];
|
|
5445
5565
|
}
|
|
5446
5566
|
/** Discriminated union of all transform types. */
|
|
5447
|
-
type Transform = FilterTransform | BinTransform | CalculateTransform | TimeUnitTransform | AggregateTransform | FoldTransform | WindowTransform;
|
|
5567
|
+
type Transform = FilterTransform | BinTransform | CalculateTransform | TimeUnitTransform | AggregateTransform | JoinAggregateTransform | DensityTransform | FoldTransform | WindowTransform;
|
|
5448
5568
|
/**
|
|
5449
5569
|
* A single condition with a test predicate and resulting value/field.
|
|
5450
5570
|
* When the test passes for a datum, the condition's value/field is used.
|
|
@@ -6847,4 +6967,4 @@ declare const CSS_TOKEN_ROOT_SELECTORS: readonly string[];
|
|
|
6847
6967
|
declare const CSS_TOKENS: readonly CssTokenDef[];
|
|
6848
6968
|
declare function cssTokenDefault(name: string, mode: 'light' | 'dark'): string;
|
|
6849
6969
|
|
|
6850
|
-
export { type A11yConfig, type A11yMetadata, ACHROMATIC_RAMP, AXIS_TITLE_GAP, AXIS_TITLE_OFFSET_COMPACT, AXIS_TITLE_OFFSET_DEFAULT, AXIS_TITLE_TRAILING_PAD, type AggregateOp, type AggregateTransform, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationFootnote, type AnnotationOffset, type AnnotationPosition, type ArcEncoding, type ArcMark, type AreaEncoding, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, BREAKPOINT_COMPACT_MAX, BREAKPOINT_MEDIUM_MAX, type BarColumnConfig, type BarEncoding, type BarListEncoding, type BarListLayout, type BarListRowMark, type BarListSpec, type BarListSpecWithoutData, type BarTableCell, type BaseLegendLayout, type BeeswarmEncoding, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_EXTENDED_PALETTE, CATEGORICAL_FILL_PALETTE, CATEGORICAL_FILL_PALETTE_DARK, CATEGORICAL_PALETTE, CATEGORICAL_PALETTE_DARK, COMPACT_MAX_X_TICKS, COMPACT_WIDTH, CSS_TOKENS, CSS_TOKEN_ROOT_SELECTORS, type CalculateExpression, type CalculateTransform, type CalendarEncoding, type CategoricalLegendLayout, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type Chrome, type ChromeDefaults, type ChromeEconomy, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ChromeThemeOverride, type CircleEncoding, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type CompileWarning, type Condition, type ConditionalValueDef, type ConnectorConfig, type ConnectorType, type ContinuousLegendBin, type ContinuousLegendLayout, type ContinuousLegendTick, type CssTokenDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type DeltaColumnConfig, type DeltaTableCell, type Display, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type EndpointLabelContent, type EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, FOOTNOTE_LINE_HEIGHT, type FacetChannel, type FacetLayout, type FacetPanelLayout, type FieldFormatContext, type FieldPredicate, type FieldRef, type FieldType, type FillPatternType, type FilterPredicate, type FilterTransform, type FlagTableCell, type FoldTransform, GRAPH_ENCODING_RULES, type GeoMapBorders, type GeoMapEncoding, type GeoMapFeatureMark, type GeoMapFocus, type GeoMapFocusLayout, type GeoMapGeo, type GeoMapLayout, type GeoMapPointMark, type GeoMapPointsLayer, type GeoMapProjection, type GeoMapSpec, type GeoMapSpecWithoutData, type GradientColorStop, type GradientDef, type GradientLegendLayout, type GradientStop, type GraphAnimationConfig, type GraphAnimationSpec, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphInteractionConfig, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, HEIGHT_CRAMPED_MAX, HEIGHT_MINIMAL_MAX, HEIGHT_NO_GRID_MAX, HEIGHT_SHORT_MAX, HPAD_COMPACT_FRACTION, HPAD_COMPACT_MIN, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type ImageColumnConfig, type ImageTableCell, LABEL_GAP_COMPACT, LABEL_GAP_DEFAULT, LABEL_GAP_NARROW_MAX, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LabelSpec, type LayerSpec, type LayoutStrategy, type LegendChannel, type LegendConfig, type LegendEntry, type LegendEntryPosition, type LegendLayout, type LegendPosition, type LineEncoding, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, type LollipopEncoding, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, MAX_LEFT_LABEL_FRACTION_COMPACT, MAX_LEFT_LABEL_FRACTION_DEFAULT, MAX_LEFT_LABEL_FRACTION_MEDIUM, MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX, MAX_SR_TABLE_ROWS, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type Metric, NARROW_VIEWPORT_MAX, type NeutralRamp, type NodeOverride, type NumberFormatter, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type ParliamentEncoding, type Point, type PointEncoding, type PointMark, type RadialGradient, type RangeAnnotation, type RangeEncoding, type Rect, type RectEncoding, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnimationPhase, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedChromeRule, type ResolvedColumn, type ResolvedFillPattern, type ResolvedLabel, type ResolvedMetricBar, type ResolvedMetricCell, type ResolvedSeriesSearch, type ResolvedTheme, type ResolvedThemeColors, type ResolvedYouDrawIt, type ResponsiveConfig, type RuleMarkLayout, SEQUENTIAL_PALETTES, SUPPORTED_SCHEME_NAMES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleInvert, type ScaleType, type SequentialPalette, type SeriesSearchConfig, type SeriesStrategy, type SeriesStyle, type SizeLegendCircle, type SizeLegendLayout, type SortByField, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, TICK_LABEL_OFFSET, TICK_LINE_HEIGHT_FACTOR, TOP_PAD_EXTRA_NARROW, TOP_PAD_NARROW_MAX, type TableBuilderOptions, type TableCell, type TableCellBase, type TableDensity, type TableLayout, type TableRow, type TableSpec, type TableSpecWithoutData, type TableTotalRow, type TextAnnotation, type TextEncoding, type TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeRule, type ThemeSpacing, type TickEncoding, type TickMarkLayout, type TileMapBuilderOptions, type TileMapEncoding, type TileMapLayout, type TileMapPalette, type TileMapSpec, type TileMapSpecWithoutData, type TileMapTileMark, type TimeUnit, type TimeUnitTransform, type TokenValue, type TooltipContent, type TooltipField, type Transform, type UpdatePhaseConfig, type ValueDef, type VizSpec, type WaffleEncoding, type WindowFieldDef, type WindowOp, type WindowSortField, type WindowTransform, type XAxisExtentInput, X_AXIS_BAND_HEIGHT, X_AXIS_ROTATED_EXTENT_CAP, X_AXIS_TITLE_BAND, X_AXIS_TITLE_BAND_ROTATED, type YouDrawItConfig, type YouDrawItSample, type YouDrawItYInvert, abbreviateNumber, adaptColorForDarkMode, adaptForLightLineStroke, adaptTheme, areaChart, axisTitleOffset, barChart, broadsheet, buildCompactStepFormatter, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeFieldFormatContext, computeLabelBounds, computeXAxisExtentFromLabels, contrastRatio, cssTokenDefault, dataTable, deepMergeSpec, defaultNumberFormatter, deriveNeutralRamp, detectCollision, donutChart, dotChart, editorial, elementRef, essay, estimateTextWidth, findAccessibleColor, footnoteBandHeight, formatCurrency, formatDate, formatNumber, formatOrdinal, formatPercent, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, heuristicMeasure, inferFieldType, isAxislessMark, isBarListSpec, isChartSpec, isConditionalDef, isEncodingChannel, isGeoMapSpec, isGradientDef, isGraphSpec, isLayerSpec, isOpaqueColor, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, isValueDef, isYearContext, lineChart, maxRotatedLabelWidth, meetsAA, overlapArea, pickLabelColor, pieChart, resolveChromeEconomy, resolveCollisions, resolveMarkDef, resolveMarkType, resolveMeasurer, resolveNumberFormatter, resolveSchemeName, resolveTheme, scatterChart, simulateColorBlindness, terminal, textAscent, tileMap, truncateRotatedLabel, truncateToWidth, wire, wrapText };
|
|
6970
|
+
export { type A11yConfig, type A11yMetadata, ACHROMATIC_RAMP, AXIS_TITLE_GAP, AXIS_TITLE_OFFSET_COMPACT, AXIS_TITLE_OFFSET_DEFAULT, AXIS_TITLE_TRAILING_PAD, type AggregateOp, type AggregateTransform, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationFootnote, type AnnotationOffset, type AnnotationPosition, type ArcEncoding, type ArcMark, type AreaEncoding, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, BREAKPOINT_COMPACT_MAX, BREAKPOINT_MEDIUM_MAX, type BarColumnConfig, type BarEncoding, type BarListEncoding, type BarListLayout, type BarListRowMark, type BarListSpec, type BarListSpecWithoutData, type BarTableCell, type BaseLegendLayout, type BeeswarmEncoding, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_EXTENDED_PALETTE, CATEGORICAL_FILL_PALETTE, CATEGORICAL_FILL_PALETTE_DARK, CATEGORICAL_PALETTE, CATEGORICAL_PALETTE_DARK, COMPACT_MAX_X_TICKS, COMPACT_WIDTH, CSS_TOKENS, CSS_TOKEN_ROOT_SELECTORS, type CalculateExpression, type CalculateTransform, type CalendarEncoding, type CategoricalLegendLayout, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type Chrome, type ChromeDefaults, type ChromeEconomy, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ChromeThemeOverride, type CircleEncoding, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type CompileWarning, type Condition, type ConditionalValueDef, type ConnectorConfig, type ConnectorType, type ContinuousLegendBin, type ContinuousLegendLayout, type ContinuousLegendTick, type CssTokenDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type DeltaColumnConfig, type DeltaTableCell, type DensityEncoding, type DensityTransform, type Display, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type EndpointLabelContent, type EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, FOOTNOTE_LINE_HEIGHT, type FacetChannel, type FacetLayout, type FacetPanelLayout, type FieldFormatContext, type FieldPredicate, type FieldRef, type FieldType, type FillPatternType, type FilterPredicate, type FilterTransform, type FlagTableCell, type FoldTransform, GRAPH_ENCODING_RULES, type GeoMapBorders, type GeoMapEncoding, type GeoMapFeatureMark, type GeoMapFocus, type GeoMapFocusLayout, type GeoMapGeo, type GeoMapLayout, type GeoMapPointMark, type GeoMapPointsLayer, type GeoMapProjection, type GeoMapSpec, type GeoMapSpecWithoutData, type GradientColorStop, type GradientDef, type GradientLegendLayout, type GradientStop, type GraphAnimationConfig, type GraphAnimationSpec, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphInteractionConfig, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, HEIGHT_CRAMPED_MAX, HEIGHT_MINIMAL_MAX, HEIGHT_NO_GRID_MAX, HEIGHT_SHORT_MAX, HPAD_COMPACT_FRACTION, HPAD_COMPACT_MIN, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type HistogramEncoding, type ImageColumnConfig, type ImageTableCell, type JoinAggregateTransform, LABEL_GAP_COMPACT, LABEL_GAP_DEFAULT, LABEL_GAP_NARROW_MAX, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LabelSpec, type LayerSpec, type LayoutStrategy, type LegendChannel, type LegendConfig, type LegendEntry, type LegendEntryPosition, type LegendLayout, type LegendPosition, type LineEncoding, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, type LollipopEncoding, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, MAX_LEFT_LABEL_FRACTION_COMPACT, MAX_LEFT_LABEL_FRACTION_DEFAULT, MAX_LEFT_LABEL_FRACTION_MEDIUM, MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX, MAX_SR_TABLE_ROWS, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type Metric, NARROW_VIEWPORT_MAX, type NeutralRamp, type NodeOverride, type NumberFormatter, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type ParliamentEncoding, type Point, type PointEncoding, type PointMark, type RadialGradient, type RangeAnnotation, type RangeEncoding, type Rect, type RectEncoding, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnimationPhase, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedChromeRule, type ResolvedColumn, type ResolvedFillPattern, type ResolvedLabel, type ResolvedMetricBar, type ResolvedMetricCell, type ResolvedSeriesSearch, type ResolvedTheme, type ResolvedThemeColors, type ResolvedYouDrawIt, type ResponsiveConfig, type RuleMarkLayout, SEQUENTIAL_PALETTES, SUPPORTED_SCHEME_NAMES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleInvert, type ScaleType, type SequentialPalette, type SeriesSearchConfig, type SeriesStrategy, type SeriesStyle, type SizeLegendCircle, type SizeLegendLayout, type SortByField, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, TICK_LABEL_OFFSET, TICK_LINE_HEIGHT_FACTOR, TOP_PAD_EXTRA_NARROW, TOP_PAD_NARROW_MAX, type TableBuilderOptions, type TableCell, type TableCellBase, type TableDensity, type TableLayout, type TableRow, type TableSpec, type TableSpecWithoutData, type TableTotalRow, type TextAnnotation, type TextEncoding, type TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeRule, type ThemeSpacing, type TickEncoding, type TickMarkLayout, type TileMapBuilderOptions, type TileMapEncoding, type TileMapLayout, type TileMapPalette, type TileMapSpec, type TileMapSpecWithoutData, type TileMapTileMark, type TimeUnit, type TimeUnitTransform, type TokenValue, type TooltipContent, type TooltipField, type Transform, type UpdatePhaseConfig, type ValueDef, type VizSpec, type WaffleEncoding, type WindowFieldDef, type WindowOp, type WindowSortField, type WindowTransform, type XAxisExtentInput, X_AXIS_BAND_HEIGHT, X_AXIS_ROTATED_EXTENT_CAP, X_AXIS_TITLE_BAND, X_AXIS_TITLE_BAND_ROTATED, type YouDrawItConfig, type YouDrawItSample, type YouDrawItYInvert, abbreviateNumber, adaptColorForDarkMode, adaptForLightLineStroke, adaptTheme, areaChart, axisTitleOffset, barChart, broadsheet, buildCompactStepFormatter, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeFieldFormatContext, computeLabelBounds, computeXAxisExtentFromLabels, contrastRatio, cssTokenDefault, dataTable, deepMergeSpec, defaultNumberFormatter, deriveNeutralRamp, detectCollision, donutChart, dotChart, editorial, elementRef, essay, estimateTextWidth, findAccessibleColor, footnoteBandHeight, formatCurrency, formatDate, formatNumber, formatOrdinal, formatPercent, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, heuristicMeasure, inferFieldType, isAxislessMark, isBarListSpec, isChartSpec, isConditionalDef, isEncodingChannel, isGeoMapSpec, isGradientDef, isGraphSpec, isLayerSpec, isOpaqueColor, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, isValueDef, isYearContext, lineChart, maxRotatedLabelWidth, meetsAA, overlapArea, pickLabelColor, pieChart, resolveChromeEconomy, resolveCollisions, resolveMarkDef, resolveMarkType, resolveMeasurer, resolveNumberFormatter, resolveSchemeName, resolveTheme, scatterChart, simulateColorBlindness, terminal, textAscent, tileMap, truncateRotatedLabel, truncateToWidth, wire, wrapText };
|
package/dist/index.js
CHANGED
|
@@ -28,7 +28,9 @@ var MARK_ENCODING_RULES = {
|
|
|
28
28
|
detail: optional("nominal")
|
|
29
29
|
},
|
|
30
30
|
area: {
|
|
31
|
-
x:
|
|
31
|
+
// Quantitative x is what a density curve needs: the x values are computed
|
|
32
|
+
// evaluation points, not categories or dates.
|
|
33
|
+
x: required("temporal", "ordinal", "quantitative"),
|
|
32
34
|
y: required("quantitative"),
|
|
33
35
|
y2: optional("quantitative"),
|
|
34
36
|
color: optional("nominal", "ordinal", "quantitative"),
|
|
@@ -175,6 +177,31 @@ var MARK_ENCODING_RULES = {
|
|
|
175
177
|
opacity: optional("quantitative"),
|
|
176
178
|
tooltip: optional(),
|
|
177
179
|
detail: optional("nominal")
|
|
180
|
+
},
|
|
181
|
+
// histogram: x is the raw quantitative field to bin. y is optional because
|
|
182
|
+
// it defaults to the bin count; supply it only to plot something else per
|
|
183
|
+
// bin. A color field groups the distributions and they overlap rather than
|
|
184
|
+
// stack, which is the whole reason this mark exists.
|
|
185
|
+
histogram: {
|
|
186
|
+
x: required("quantitative"),
|
|
187
|
+
y: optional("quantitative"),
|
|
188
|
+
color: optional("nominal", "ordinal"),
|
|
189
|
+
size: optional(),
|
|
190
|
+
opacity: optional("quantitative"),
|
|
191
|
+
tooltip: optional(),
|
|
192
|
+
detail: optional("nominal")
|
|
193
|
+
},
|
|
194
|
+
// density: x is the raw quantitative field to estimate over. y is computed
|
|
195
|
+
// by the density transform, never authored, so it stays optional. A color
|
|
196
|
+
// field yields one translucent curve per group.
|
|
197
|
+
density: {
|
|
198
|
+
x: required("quantitative"),
|
|
199
|
+
y: optional("quantitative"),
|
|
200
|
+
color: optional("nominal", "ordinal"),
|
|
201
|
+
size: optional(),
|
|
202
|
+
opacity: optional("quantitative"),
|
|
203
|
+
tooltip: optional(),
|
|
204
|
+
detail: optional("nominal")
|
|
178
205
|
}
|
|
179
206
|
};
|
|
180
207
|
var GRAPH_ENCODING_RULES = {
|
|
@@ -252,7 +279,9 @@ var MARK_TYPES = /* @__PURE__ */ new Set([
|
|
|
252
279
|
"range",
|
|
253
280
|
"waffle",
|
|
254
281
|
"calendar",
|
|
255
|
-
"parliament"
|
|
282
|
+
"parliament",
|
|
283
|
+
"histogram",
|
|
284
|
+
"density"
|
|
256
285
|
]);
|
|
257
286
|
function isAxislessMark(markType) {
|
|
258
287
|
return markType === "arc" || markType === "waffle" || markType === "calendar" || markType === "parliament";
|
|
@@ -314,7 +343,9 @@ var MARK_DISPLAY_NAMES = {
|
|
|
314
343
|
range: "Range plot",
|
|
315
344
|
waffle: "Waffle chart",
|
|
316
345
|
calendar: "Calendar heatmap",
|
|
317
|
-
parliament: "Parliament chart"
|
|
346
|
+
parliament: "Parliament chart",
|
|
347
|
+
histogram: "Histogram",
|
|
348
|
+
density: "Density plot"
|
|
318
349
|
};
|
|
319
350
|
|
|
320
351
|
// src/colors/colorblind.ts
|
|
@@ -2747,6 +2778,10 @@ function generateAltText(spec, data) {
|
|
|
2747
2778
|
if (markType === "arc" && markDef.innerRadius && markDef.innerRadius > 0) {
|
|
2748
2779
|
chartName = "Donut chart";
|
|
2749
2780
|
}
|
|
2781
|
+
const isBinnedBar = markType === "bar" && !!spec.encoding.x2 && spec.encoding.x?.type === "quantitative" && spec.encoding.y?.type === "quantitative";
|
|
2782
|
+
if (isBinnedBar) {
|
|
2783
|
+
chartName = "Histogram";
|
|
2784
|
+
}
|
|
2750
2785
|
const parts = [chartName];
|
|
2751
2786
|
const title = spec.chrome?.title;
|
|
2752
2787
|
if (title) {
|
|
@@ -2780,6 +2815,12 @@ function generateAltText(spec, data) {
|
|
|
2780
2815
|
);
|
|
2781
2816
|
}
|
|
2782
2817
|
}
|
|
2818
|
+
if (isBinnedBar) {
|
|
2819
|
+
const sourceField = spec.encoding.x?.title ?? spec.encoding.x?.field;
|
|
2820
|
+
if (sourceField) {
|
|
2821
|
+
parts.push(`showing the distribution of ${sourceField}`);
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2783
2824
|
if (spec.encoding.x && markType !== "beeswarm" && data.length > 0) {
|
|
2784
2825
|
const field = spec.encoding.x.field;
|
|
2785
2826
|
const values = data.map((d) => d[field]).filter((v) => v != null);
|