@opendata-ai/openchart-core 6.12.0 → 6.13.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 CHANGED
@@ -287,7 +287,7 @@ interface MarkDef {
287
287
  /** Data field type, following Vega-Lite conventions. */
288
288
  type FieldType = 'quantitative' | 'temporal' | 'nominal' | 'ordinal';
289
289
  /** Aggregate function applied to a field before encoding. */
290
- type AggregateOp = 'count' | 'sum' | 'mean' | 'median' | 'min' | 'max';
290
+ type AggregateOp = 'count' | 'sum' | 'mean' | 'median' | 'min' | 'max' | 'variance' | 'stdev' | 'distinct' | 'q1' | 'q3';
291
291
  /** Axis configuration for an encoding channel. */
292
292
  interface AxisConfig {
293
293
  /** Axis title text. If omitted, the field name is used. */
@@ -318,10 +318,6 @@ interface AxisConfig {
318
318
  titlePadding?: number;
319
319
  /** Padding between tick labels and axis. */
320
320
  labelPadding?: number;
321
- /** @deprecated Use `title` instead. */
322
- label?: string;
323
- /** @deprecated Use `labelAngle` instead. */
324
- tickAngle?: number;
325
321
  }
326
322
  /** Scale configuration for an encoding channel. */
327
323
  interface ScaleConfig {
@@ -382,10 +378,47 @@ interface EncodingChannel {
382
378
  scale?: ScaleConfig;
383
379
  /**
384
380
  * Stacking behavior for quantitative channels (Vega-Lite aligned).
385
- * - undefined | true | 'zero': stack (default, cumulative segments)
381
+ * - undefined | true | 'zero': stack from zero baseline (default)
382
+ * - 'normalize': stack and normalize to fraction of total (0-1 per category)
383
+ * - 'center': center stacks around zero (streamgraph style)
386
384
  * - null | false: no stacking (grouped/dodged side-by-side)
387
385
  */
388
- stack?: boolean | 'zero' | null;
386
+ stack?: boolean | 'zero' | 'normalize' | 'center' | null;
387
+ /**
388
+ * Encoding-level bin shorthand (Vega-Lite aligned).
389
+ * When set, auto-generates a BinTransform during normalization and updates
390
+ * the field reference to the binned output (convention: `bin_<fieldName>`).
391
+ * - true: bin with default params
392
+ * - BinParams: bin with custom params (maxbins, step, etc.)
393
+ */
394
+ bin?: boolean | BinParams;
395
+ /**
396
+ * Encoding-level timeUnit shorthand (Vega-Lite aligned).
397
+ * When set, auto-generates a TimeUnitTransform during normalization and
398
+ * updates the field reference to the output (convention: `<timeUnit>_<fieldName>`).
399
+ */
400
+ timeUnit?: TimeUnit;
401
+ /**
402
+ * Sort order for categorical (nominal/ordinal) scale domains (Vega-Lite aligned).
403
+ * - 'ascending': sort domain values ascending (default VL behavior)
404
+ * - 'descending': sort domain values descending
405
+ * - null: use data order (no sorting)
406
+ * - undefined: ascending (VL default)
407
+ */
408
+ sort?: 'ascending' | 'descending' | null;
409
+ /**
410
+ * Display title override (Vega-Lite aligned).
411
+ * Used as the label in tooltips instead of the raw field name.
412
+ * Also usable for axis titles, but `axis.title` takes precedence there.
413
+ */
414
+ title?: string;
415
+ /**
416
+ * Format string for values (Vega-Lite aligned).
417
+ * For quantitative fields: d3-format string (e.g. ",.0f", "$,.2f").
418
+ * For temporal fields: d3-time-format string (e.g. "%Y", "%b %d").
419
+ * Used in tooltips; `axis.format` takes precedence for axis tick labels.
420
+ */
421
+ format?: string;
389
422
  }
390
423
  /**
391
424
  * Encoding object mapping visual channels to data fields.
@@ -1149,8 +1182,30 @@ interface TimeUnitTransform {
1149
1182
  field: string;
1150
1183
  as: string;
1151
1184
  }
1185
+ /**
1186
+ * Aggregate transform: group rows and compute summary statistics (VL aligned).
1187
+ * Produces one row per group with the groupby fields and computed aggregates.
1188
+ */
1189
+ interface AggregateTransform {
1190
+ aggregate: Array<{
1191
+ op: AggregateOp;
1192
+ field: string;
1193
+ as: string;
1194
+ }>;
1195
+ groupby: string[];
1196
+ }
1197
+ /**
1198
+ * Fold transform: unpivot wide-format columns into key/value rows (VL aligned).
1199
+ * For each input row, produces N output rows (one per fold field) with all
1200
+ * non-fold fields copied plus a key column (field name) and value column (field value).
1201
+ */
1202
+ interface FoldTransform {
1203
+ fold: string[];
1204
+ /** Output field names for [key, value]. Defaults to ['key', 'value']. */
1205
+ as?: [string, string];
1206
+ }
1152
1207
  /** Discriminated union of all transform types. */
1153
- type Transform = FilterTransform | BinTransform | CalculateTransform | TimeUnitTransform;
1208
+ type Transform = FilterTransform | BinTransform | CalculateTransform | TimeUnitTransform | AggregateTransform | FoldTransform;
1154
1209
  /**
1155
1210
  * A single condition with a test predicate and resulting value/field.
1156
1211
  * When the test passes for a datum, the condition's value/field is used.
@@ -3040,4 +3095,4 @@ declare function scatterChart(data: DataRow[], x: FieldRef, y: FieldRef, options
3040
3095
  */
3041
3096
  declare function dataTable(data: DataRow[], options?: TableBuilderOptions): TableSpec;
3042
3097
 
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 };
3098
+ export { type A11yMetadata, type AggregateOp, type AggregateTransform, 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, type FoldTransform, 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 };