svelteplot 0.9.1 → 0.9.2-pr-336.1

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.
Files changed (88) hide show
  1. package/dist/Mark.svelte.d.ts +5 -4
  2. package/dist/constants.d.ts +1 -1
  3. package/dist/helpers/colors.d.ts +8 -11
  4. package/dist/helpers/curves.d.ts +2 -2
  5. package/dist/helpers/facets.d.ts +1 -1
  6. package/dist/helpers/getBaseStyles.d.ts +2 -4
  7. package/dist/helpers/index.d.ts +3 -3
  8. package/dist/helpers/reduce.d.ts +1 -1
  9. package/dist/helpers/scales.d.ts +7 -7
  10. package/dist/helpers/symbols.d.ts +1 -1
  11. package/dist/helpers/time.d.ts +3 -3
  12. package/dist/helpers/typeChecks.d.ts +8 -8
  13. package/dist/marks/Area.svelte.d.ts +5 -4
  14. package/dist/marks/AreaX.svelte.d.ts +6 -5
  15. package/dist/marks/Arrow.svelte.d.ts +5 -4
  16. package/dist/marks/AxisX.svelte +5 -2
  17. package/dist/marks/AxisX.svelte.d.ts +10 -6
  18. package/dist/marks/AxisY.svelte +1 -1
  19. package/dist/marks/AxisY.svelte.d.ts +6 -5
  20. package/dist/marks/BarX.svelte +53 -22
  21. package/dist/marks/BarX.svelte.d.ts +9 -4
  22. package/dist/marks/BarY.svelte +51 -21
  23. package/dist/marks/BarY.svelte.d.ts +9 -4
  24. package/dist/marks/BollingerX.svelte.d.ts +2 -77
  25. package/dist/marks/BollingerY.svelte.d.ts +2 -77
  26. package/dist/marks/BoxY.svelte.d.ts +1 -64
  27. package/dist/marks/Brush.svelte.d.ts +1 -64
  28. package/dist/marks/Cell.svelte +36 -13
  29. package/dist/marks/Cell.svelte.d.ts +9 -4
  30. package/dist/marks/CellX.svelte.d.ts +32 -30
  31. package/dist/marks/CellY.svelte.d.ts +32 -30
  32. package/dist/marks/CustomMark.svelte.d.ts +2 -85
  33. package/dist/marks/DifferenceY.svelte.d.ts +1 -64
  34. package/dist/marks/Dot.svelte.d.ts +5 -4
  35. package/dist/marks/DotX.svelte.d.ts +6 -5
  36. package/dist/marks/DotY.svelte.d.ts +6 -5
  37. package/dist/marks/Frame.svelte.d.ts +6 -5
  38. package/dist/marks/Geo.svelte.d.ts +5 -4
  39. package/dist/marks/GridX.svelte.d.ts +5 -4
  40. package/dist/marks/GridY.svelte.d.ts +5 -4
  41. package/dist/marks/Image.svelte.d.ts +2 -76
  42. package/dist/marks/Line.svelte.d.ts +5 -4
  43. package/dist/marks/LineX.svelte.d.ts +7 -6
  44. package/dist/marks/LineY.svelte.d.ts +7 -6
  45. package/dist/marks/Link.svelte.d.ts +5 -4
  46. package/dist/marks/Rect.svelte +54 -29
  47. package/dist/marks/Rect.svelte.d.ts +10 -5
  48. package/dist/marks/RectX.svelte +1 -1
  49. package/dist/marks/RectY.svelte +1 -1
  50. package/dist/marks/RuleX.svelte.d.ts +5 -4
  51. package/dist/marks/RuleY.svelte.d.ts +5 -4
  52. package/dist/marks/Spike.svelte.d.ts +6 -5
  53. package/dist/marks/Text.svelte.d.ts +5 -4
  54. package/dist/marks/TickX.svelte.d.ts +5 -4
  55. package/dist/marks/TickY.svelte.d.ts +5 -4
  56. package/dist/marks/Trail.svelte.d.ts +1 -64
  57. package/dist/marks/Vector.svelte.d.ts +5 -4
  58. package/dist/marks/WaffleX.svelte +1 -2
  59. package/dist/marks/WaffleX.svelte.d.ts +2 -86
  60. package/dist/marks/WaffleY.svelte +1 -2
  61. package/dist/marks/WaffleY.svelte.d.ts +2 -84
  62. package/dist/marks/helpers/BaseAxisX.svelte +1 -1
  63. package/dist/marks/helpers/BaseAxisX.svelte.d.ts +1 -1
  64. package/dist/marks/helpers/BaseAxisY.svelte +1 -1
  65. package/dist/marks/helpers/BaseAxisY.svelte.d.ts +1 -1
  66. package/dist/marks/helpers/Box.svelte.d.ts +1 -64
  67. package/dist/marks/helpers/MarkerPath.svelte.d.ts +2 -103
  68. package/dist/marks/helpers/RectCanvas.svelte +203 -0
  69. package/dist/marks/helpers/RectCanvas.svelte.d.ts +43 -0
  70. package/dist/transforms/centroid.d.ts +1 -4
  71. package/dist/transforms/filter.d.ts +3 -0
  72. package/dist/transforms/filter.js +3 -0
  73. package/dist/transforms/group.d.ts +4 -12
  74. package/dist/transforms/interval.d.ts +9 -135
  75. package/dist/transforms/interval.js +11 -5
  76. package/dist/transforms/map.d.ts +9 -0
  77. package/dist/transforms/map.js +9 -0
  78. package/dist/transforms/normalize.d.ts +33 -0
  79. package/dist/transforms/normalize.js +19 -5
  80. package/dist/transforms/recordize.d.ts +4 -7
  81. package/dist/transforms/rename.d.ts +1 -1
  82. package/dist/transforms/rename.js +1 -1
  83. package/dist/transforms/select.d.ts +7 -455
  84. package/dist/transforms/sort.d.ts +5 -257
  85. package/dist/transforms/stack.d.ts +3 -23
  86. package/dist/transforms/window.d.ts +2 -136
  87. package/dist/types/index.d.ts +6 -1
  88. package/package.json +152 -147
@@ -1,4 +1,5 @@
1
1
  import { type Snippet } from 'svelte';
2
+ import { CHANNEL_SCALE } from './constants.js';
2
3
  import type { ScaledChannelName, MarkType, DataRecord, ChannelAccessor, ScaleName, RawValue, ScaledDataRecord, ScaleType } from './types/index.js';
3
4
  import { getUsedScales } from './helpers/scales.js';
4
5
  declare function $$render<Datum extends DataRecord>(): {
@@ -9,14 +10,14 @@ declare function $$render<Datum extends DataRecord>(): {
9
10
  fy: ChannelAccessor<Datum>;
10
11
  dx: import("./types/index.js").ConstantAccessor<number, Datum>;
11
12
  dy: import("./types/index.js").ConstantAccessor<number, Datum>;
12
- dodgeX: import("./transforms/dodge.js").DodgeXOptions;
13
- dodgeY: import("./transforms/dodge.js").DodgeYOptions;
13
+ dodgeX: CHANNEL_SCALE;
14
+ dodgeY: CHANNEL_SCALE;
14
15
  fill: ChannelAccessor<Datum>;
15
16
  fillOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
16
- sort: ((a: RawValue, b: RawValue) => number) | {
17
+ sort: {
17
18
  channel: string;
18
19
  order?: "ascending" | "descending";
19
- } | import("./types/index.js").ConstantAccessor<RawValue, Datum>;
20
+ } | ((a: RawValue, b: RawValue) => number) | import("./types/index.js").ConstantAccessor<RawValue, Datum>;
20
21
  stroke: ChannelAccessor<Datum>;
21
22
  strokeWidth: import("./types/index.js").ConstantAccessor<number, Datum>;
22
23
  strokeOpacity: import("./types/index.js").ConstantAccessor<number, Datum>;
@@ -13,6 +13,6 @@ export declare const CSS_COLOR_MIX: RegExp;
13
13
  export declare const CSS_COLOR_CONTRAST: RegExp;
14
14
  export declare const CSS_RGBA: RegExp;
15
15
  export declare const CSS_URL: RegExp;
16
- export declare const INDEX: unique symbol;
16
+ export declare const INDEX: any;
17
17
  export declare const PI: number;
18
18
  export declare const TAU: number;
@@ -1,13 +1,10 @@
1
- import { interpolateBrBG } from 'd3-scale-chromatic';
2
1
  import type { ColorScheme } from '../types/index.js';
3
- export declare const categoricalSchemes: Map<string, readonly string[]>;
4
- export declare function isCategoricalScheme(scheme: string): boolean;
5
- type SchemeGetter = (n: number) => readonly string[];
2
+ export declare const categoricalSchemes: any;
3
+ export declare function isCategoricalScheme(scheme: string): any;
6
4
  export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
7
- export declare function ordinalScheme(scheme: ColorScheme | string): SchemeGetter;
8
- export declare function ordinalRange(scheme: ColorScheme | string, length: number): readonly string[];
9
- export declare function maybeBooleanRange(domain: boolean[], scheme?: ColorScheme | string): unknown[] | undefined;
10
- export declare function isQuantitativeScheme(scheme: string): boolean;
11
- export declare function quantitativeScheme(scheme: ColorScheme | string): typeof interpolateBrBG | undefined;
12
- export declare function isDivergingScheme(scheme: string): boolean;
13
- export {};
5
+ export declare function ordinalScheme(scheme: ColorScheme | string): any;
6
+ export declare function ordinalRange(scheme: ColorScheme | string, length: number): any;
7
+ export declare function maybeBooleanRange(domain: boolean[], scheme?: ColorScheme | string): any[] | undefined;
8
+ export declare function isQuantitativeScheme(scheme: string): any;
9
+ export declare function quantitativeScheme(scheme: ColorScheme | string): any;
10
+ export declare function isDivergingScheme(scheme: string): any;
@@ -1,3 +1,3 @@
1
1
  import type { CurveName } from '../types/index.js';
2
- import { type CurveFactory, type CurveBundleFactory } from 'd3-shape';
3
- export declare function maybeCurve(curve: (CurveName | CurveFactory) | undefined, tension: number): CurveFactory | CurveBundleFactory;
2
+ import { type CurveFactory } from 'd3-shape';
3
+ export declare function maybeCurve(curve: (CurveName | CurveFactory) | undefined, tension: number): any;
@@ -9,4 +9,4 @@ import type { GenericMarkOptions, Mark, RawValue } from '../types/index.js';
9
9
  * @param fyValues y facet domain
10
10
  * @returns
11
11
  */
12
- export declare function getEmptyFacets(marks: Mark<GenericMarkOptions>[], fxValues: RawValue[], fyValues: RawValue[]): Map<RawValue, Map<RawValue, boolean>>;
12
+ export declare function getEmptyFacets(marks: Mark<GenericMarkOptions>[], fxValues: RawValue[], fyValues: RawValue[]): any;
@@ -1,8 +1,6 @@
1
1
  import type { Channels } from '../types/index.js';
2
- export declare function getBaseStylesObject<T>(datum: T, props: Partial<Channels<T>>): {
3
- [k: string]: string | number;
4
- };
5
- export default function <T>(datum: T, props: Partial<Channels<T>>): string;
2
+ export declare function getBaseStylesObject<T>(datum: T, props: Partial<Channels<T>>): any;
3
+ export default function <T>(datum: T, props: Partial<Channels<T>>): any;
6
4
  export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
7
5
  export declare function maybeFromPixel(value: string | number): string | number;
8
6
  export declare function maybeFromRem(value: string | number, rootFontSize?: number): string | number;
@@ -3,8 +3,8 @@ import type { Snippet } from 'svelte';
3
3
  /**
4
4
  * Returns first argument that is not null or undefined
5
5
  */
6
- export declare function coalesce(...args: (RawValue | undefined | null)[]): string | number | boolean | symbol | object | null;
7
- export declare function testFilter<T>(datum: T, options: Channels<T>): true | T | null;
6
+ export declare function coalesce(...args: (RawValue | undefined | null)[]): any;
7
+ export declare function testFilter<T>(datum: T, options: Channels<T>): any;
8
8
  export declare function randomId(): string;
9
9
  export declare function isSnippet(value: unknown): value is Snippet;
10
10
  export declare function isValid(value: RawValue | undefined): value is number | Date | string;
@@ -15,4 +15,4 @@ export declare const POSITION_CHANNELS: Set<ChannelName>;
15
15
  export declare function parseInset(inset: number | string, width: number): number;
16
16
  export declare function omit<T extends {}, K extends keyof T>(obj: T, ...keys: K[]): Omit<T, K>;
17
17
  export declare function identity<T>(x: T): T;
18
- export declare const GEOJSON_PREFER_STROKE: Set<string>;
18
+ export declare const GEOJSON_PREFER_STROKE: any;
@@ -4,7 +4,7 @@ type ReducerOption = ReducerName | ReducerFunc;
4
4
  type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
5
5
  export type ReducerPercentile = (`p${Digit}${Digit}` & Record<never, never>) | 'p25' | 'p50' | 'p75';
6
6
  export type ReducerName = 'count' | 'deviation' | 'difference' | 'first' | 'last' | 'max' | 'mean' | 'median' | 'min' | 'mode' | 'ratio' | 'sum' | 'variance' | ReducerPercentile;
7
- export declare const Reducer: Record<ReducerName, ReducerFunc>;
7
+ export declare const Reducer: any;
8
8
  export declare function mayberReducer(r: ReducerOption): ReducerFunc;
9
9
  export declare function reduceOutputs(newDatum: DataRecord, data: DataRecord[], options: Record<ChannelName, ReducerOption>, outputs: Iterable<ChannelName>, channels: Channels, newChannels: Channels): void;
10
10
  export {};
@@ -1,4 +1,4 @@
1
- import type { ChannelAccessor, GenericMarkOptions, Mark, MarkType, PlotDefaults, PlotOptions, PlotScales, PlotState, RawValue, ScaleName, ScaleOptions, ScaleType, ScaledChannelName, UsedScales } from '../types/index.js';
1
+ import type { GenericMarkOptions, Mark, MarkType, PlotDefaults, PlotOptions, PlotScales, PlotState, RawValue, ScaleName, ScaleOptions, ScaleType, UsedScales } from '../types/index.js';
2
2
  /**
3
3
  * compute the plot scales
4
4
  */
@@ -8,19 +8,19 @@ export declare function createScale<T extends ScaleOptions>(name: ScaleName, sca
8
8
  domain: number[];
9
9
  range: number[];
10
10
  fn: (() => string) | (() => number);
11
- skip: Map<any, any>;
11
+ skip: any;
12
12
  isDummy: boolean;
13
13
  manualActiveMarks?: undefined;
14
14
  uniqueScaleProps?: undefined;
15
15
  autoTitle?: undefined;
16
16
  } | {
17
17
  type: ScaleType;
18
- domain: RawValue[] | [undefined, undefined];
18
+ domain: any;
19
19
  range: any;
20
20
  fn: any;
21
- skip: Map<ScaledChannelName, Set<symbol>>;
21
+ skip: any;
22
22
  manualActiveMarks: number;
23
- uniqueScaleProps: Set<ChannelAccessor>;
23
+ uniqueScaleProps: any;
24
24
  autoTitle: string | null;
25
25
  isDummy?: undefined;
26
26
  };
@@ -36,8 +36,8 @@ export declare function inferScaleType(name: ScaleName, dataValues: RawValue[],
36
36
  * not. That's what this function is used for.
37
37
  */
38
38
  export declare function getUsedScales(plot: PlotState, options: GenericMarkOptions, mark: Mark<GenericMarkOptions>): UsedScales;
39
- export declare function looksLikeANumber(input: string | number): boolean;
39
+ export declare function looksLikeANumber(input: string | number): any;
40
40
  export declare function projectXY(scales: PlotScales, x: RawValue, y: RawValue, useXScale?: boolean, useYScale?: boolean): [number, number];
41
41
  export declare function projectX(channel: 'x' | 'x1' | 'x2', scales: PlotScales, value: RawValue): number;
42
42
  export declare function projectY(channel: 'y' | 'y1' | 'y2', scales: PlotScales, value: RawValue): number;
43
- export declare function isOrdinalScale(scaleType: ScaleType): scaleType is "ordinal" | "point" | "band" | "categorical" | "threshold";
43
+ export declare function isOrdinalScale(scaleType: ScaleType): scaleType is "point" | "ordinal" | "band" | "categorical" | "threshold";
@@ -3,5 +3,5 @@ export declare const sqrt3: number;
3
3
  export declare const sqrt4_3: number;
4
4
  type BuiltinSymbol = 'asterisk' | 'circle' | 'cross' | 'diamond' | 'diamond2' | 'hexagon' | 'plus' | 'square' | 'square2' | 'star' | 'times' | 'triangle' | 'triangle2' | 'wye';
5
5
  export declare function isSymbol(value: any): value is SymbolType | BuiltinSymbol;
6
- export declare function maybeSymbol(symbol: SymbolType | string): SymbolType;
6
+ export declare function maybeSymbol(symbol: SymbolType | string): any;
7
7
  export {};
@@ -1,6 +1,6 @@
1
- export declare const durations: Map<string, number>;
2
- export declare const intervalDuration: unique symbol;
3
- export declare const intervalType: unique symbol;
1
+ export declare const durations: any;
2
+ export declare const intervalDuration: any;
3
+ export declare const intervalType: any;
4
4
  export declare function parseTimeInterval(input: string): [string, number];
5
5
  export declare function maybeTimeInterval(input: string): any;
6
6
  export declare function maybeUtcInterval(input: string): any;
@@ -1,10 +1,10 @@
1
1
  import type { RawValue } from '../types/index.js';
2
- export declare function isBooleanOrNull(v: RawValue): v is boolean | null;
2
+ export declare function isBooleanOrNull(v: RawValue): boolean;
3
3
  export declare function isDate(v: RawValue): v is Date;
4
- export declare function isDateOrNull(v: RawValue | null | undefined): v is Date | null | undefined;
5
- export declare function isNumberOrNull(v: RawValue | null | undefined): boolean;
6
- export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): boolean;
7
- export declare function isStringOrNull(v: RawValue | null | undefined): v is string | null | undefined;
8
- export declare function isSymbolOrNull(v: RawValue | null | undefined): v is ("square" | "circle" | "asterisk" | "cross" | "diamond" | "diamond2" | "hexagon" | "plus" | "square2" | "star" | "times" | "triangle" | "triangle2" | "wye") | import("d3-shape").SymbolType | null | undefined;
9
- export declare function isColorOrNull(v: RawValue | null | undefined): boolean;
10
- export declare function isOpacityOrNull(v: RawValue): boolean;
4
+ export declare function isDateOrNull(v: RawValue | null | undefined): boolean;
5
+ export declare function isNumberOrNull(v: RawValue | null | undefined): any;
6
+ export declare function isNumberOrNullOrNaN(v: RawValue | null | undefined): any;
7
+ export declare function isStringOrNull(v: RawValue | null | undefined): boolean;
8
+ export declare function isSymbolOrNull(v: RawValue | null | undefined): boolean;
9
+ export declare function isColorOrNull(v: RawValue | null | undefined): any;
10
+ export declare function isOpacityOrNull(v: RawValue): any;
@@ -1,4 +1,5 @@
1
1
  import { type CurveFactory } from 'd3-shape';
2
+ import callWithProps from '../helpers/callWithProps.js';
2
3
  import type { CurveName, DataRecord, ConstantAccessor, ChannelAccessor, LinkableMarkProps, RawValue } from '../types/index.js';
3
4
  import type { StackOptions } from '../transforms/stack.js';
4
5
  declare function $$render<Datum extends DataRecord>(): {
@@ -9,14 +10,14 @@ declare function $$render<Datum extends DataRecord>(): {
9
10
  fy: ChannelAccessor<Datum>;
10
11
  dx: ConstantAccessor<number, Datum>;
11
12
  dy: ConstantAccessor<number, Datum>;
12
- dodgeX: import("../transforms/dodge").DodgeXOptions;
13
- dodgeY: import("../transforms/dodge").DodgeYOptions;
13
+ dodgeX: callWithProps;
14
+ dodgeY: callWithProps;
14
15
  fill: ChannelAccessor<Datum>;
15
16
  fillOpacity: ConstantAccessor<number, Datum>;
16
- sort: ((a: RawValue, b: RawValue) => number) | {
17
+ sort: {
17
18
  channel: string;
18
19
  order?: "ascending" | "descending";
19
- } | ConstantAccessor<RawValue, Datum>;
20
+ } | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
20
21
  stroke: ChannelAccessor<Datum>;
21
22
  strokeWidth: ConstantAccessor<number, Datum>;
22
23
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -1,3 +1,4 @@
1
+ import { renameChannels } from '../transforms/rename.js';
1
2
  import type { ChannelAccessor, DataRow } from '../types/index.js';
2
3
  declare function $$render<Datum extends DataRow>(): {
3
4
  props: Omit<Partial<{
@@ -7,14 +8,14 @@ declare function $$render<Datum extends DataRow>(): {
7
8
  fy: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
8
9
  dx: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
9
10
  dy: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
10
- dodgeX: import("../transforms/dodge").DodgeXOptions;
11
- dodgeY: import("../transforms/dodge").DodgeYOptions;
11
+ dodgeX: renameChannels;
12
+ dodgeY: renameChannels;
12
13
  fill: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
13
14
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
14
- sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
15
+ sort: {
15
16
  channel: string;
16
17
  order?: "ascending" | "descending";
17
- } | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
18
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Record<string | symbol, import("../types/data").RawValue>>;
18
19
  stroke: ChannelAccessor<Record<string | symbol, import("../types/data").RawValue>>;
19
20
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
20
21
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
@@ -75,7 +76,7 @@ declare function $$render<Datum extends DataRow>(): {
75
76
  sort?: import("../types/index.js").ConstantAccessor<import("../types/data").RawValue> | {
76
77
  channel: "stroke" | "fill";
77
78
  };
78
- stack?: Partial<import("../transforms/stack.js").StackOptions>;
79
+ stack?: Partial<renameChannels>;
79
80
  canvas?: boolean;
80
81
  areaClass?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
81
82
  }, "y1" | "y2"> & {
@@ -1,5 +1,6 @@
1
1
  import type { DataRecord, ConstantAccessor, ChannelAccessor, RawValue } from '../types/index.js';
2
2
  import { type SweepOption } from '../helpers/arrowPath.js';
3
+ import { replaceChannels } from '../transforms/rename.js';
3
4
  declare function $$render<Datum extends DataRecord>(): {
4
5
  props: Omit<Partial<{
5
6
  filter: ConstantAccessor<boolean, Datum>;
@@ -8,14 +9,14 @@ declare function $$render<Datum extends DataRecord>(): {
8
9
  fy: ChannelAccessor<Datum>;
9
10
  dx: ConstantAccessor<number, Datum>;
10
11
  dy: ConstantAccessor<number, Datum>;
11
- dodgeX: import("../transforms/dodge.js").DodgeXOptions;
12
- dodgeY: import("../transforms/dodge.js").DodgeYOptions;
12
+ dodgeX: replaceChannels;
13
+ dodgeY: replaceChannels;
13
14
  fill: ChannelAccessor<Datum>;
14
15
  fillOpacity: ConstantAccessor<number, Datum>;
15
- sort: ((a: RawValue, b: RawValue) => number) | {
16
+ sort: {
16
17
  channel: string;
17
18
  order?: "ascending" | "descending";
18
- } | ConstantAccessor<RawValue, Datum>;
19
+ } | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
19
20
  stroke: ChannelAccessor<Datum>;
20
21
  strokeWidth: ConstantAccessor<number, Datum>;
21
22
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -51,7 +51,10 @@
51
51
  tickSpacing?: number;
52
52
  /** text anchor for axis labels */
53
53
  textAnchor?: ConstantAccessor<CSS.Property.TextAnchor | 'auto', Datum>;
54
- removeDuplicateTicks: boolean;
54
+ /**
55
+ * you can set this to true to remove duplicate tick labels
56
+ */
57
+ removeDuplicateTicks?: boolean;
55
58
  }
56
59
 
57
60
  let markProps: AxisXMarkProps = $props();
@@ -241,7 +244,7 @@
241
244
  {#if showAxis}
242
245
  <BaseAxisX
243
246
  {anchor}
244
- {className}
247
+ class={className}
245
248
  {labelAnchor}
246
249
  options={{ ...options, ...plot.options.x }}
247
250
  {plot}
@@ -1,5 +1,6 @@
1
1
  import type { RawValue, ConstantAccessor } from '../types/index.js';
2
2
  import type * as CSS from 'csstype';
3
+ import autoTimeFormat from '../helpers/autoTimeFormat.js';
3
4
  declare function $$render<Datum extends RawValue>(): {
4
5
  props: Omit<Partial<{
5
6
  filter: ConstantAccessor<boolean, Datum>;
@@ -8,14 +9,14 @@ declare function $$render<Datum extends RawValue>(): {
8
9
  fy: import("../types/channel").ChannelAccessor<Datum>;
9
10
  dx: ConstantAccessor<number, Datum>;
10
11
  dy: ConstantAccessor<number, Datum>;
11
- dodgeX: import("../transforms/dodge").DodgeXOptions;
12
- dodgeY: import("../transforms/dodge").DodgeYOptions;
12
+ dodgeX: autoTimeFormat;
13
+ dodgeY: autoTimeFormat;
13
14
  fill: import("../types/channel").ChannelAccessor<Datum>;
14
15
  fillOpacity: ConstantAccessor<number, Datum>;
15
- sort: ((a: RawValue, b: RawValue) => number) | {
16
+ sort: {
16
17
  channel: string;
17
18
  order?: "ascending" | "descending";
18
- } | ConstantAccessor<RawValue, Datum>;
19
+ } | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
19
20
  stroke: import("../types/channel").ChannelAccessor<Datum>;
20
21
  strokeWidth: ConstantAccessor<number, Datum>;
21
22
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -64,7 +65,7 @@ declare function $$render<Datum extends RawValue>(): {
64
65
  class: string;
65
66
  style: string;
66
67
  cursor: ConstantAccessor<CSS.Property.Cursor, Datum>;
67
- }>, "fillOpacity" | "paintOrder" | "href" | "target" | "title"> & {
68
+ }>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
68
69
  data?: Datum[];
69
70
  automatic?: boolean;
70
71
  title?: string | false | null;
@@ -88,7 +89,10 @@ declare function $$render<Datum extends RawValue>(): {
88
89
  tickSpacing?: number;
89
90
  /** text anchor for axis labels */
90
91
  textAnchor?: ConstantAccessor<CSS.Property.TextAnchor | "auto", Datum>;
91
- removeDuplicateTicks: boolean;
92
+ /**
93
+ * you can set this to true to remove duplicate tick labels
94
+ */
95
+ removeDuplicateTicks?: boolean;
92
96
  };
93
97
  exports: {};
94
98
  bindings: "";
@@ -221,7 +221,7 @@
221
221
  {#if showAxis}
222
222
  <BaseAxisY
223
223
  {anchor}
224
- {className}
224
+ class={className}
225
225
  {lineAnchor}
226
226
  options={{
227
227
  ...options,
@@ -1,4 +1,5 @@
1
1
  import type { RawValue, ConstantAccessor } from '../types/index.js';
2
+ import autoTimeFormat from '../helpers/autoTimeFormat.js';
2
3
  declare function $$render<Datum extends RawValue>(): {
3
4
  props: Omit<Partial<{
4
5
  filter: ConstantAccessor<boolean, Datum>;
@@ -7,14 +8,14 @@ declare function $$render<Datum extends RawValue>(): {
7
8
  fy: import("../types/channel").ChannelAccessor<Datum>;
8
9
  dx: ConstantAccessor<number, Datum>;
9
10
  dy: ConstantAccessor<number, Datum>;
10
- dodgeX: import("../transforms/dodge").DodgeXOptions;
11
- dodgeY: import("../transforms/dodge").DodgeYOptions;
11
+ dodgeX: autoTimeFormat;
12
+ dodgeY: autoTimeFormat;
12
13
  fill: import("../types/channel").ChannelAccessor<Datum>;
13
14
  fillOpacity: ConstantAccessor<number, Datum>;
14
- sort: ((a: RawValue, b: RawValue) => number) | {
15
+ sort: {
15
16
  channel: string;
16
17
  order?: "ascending" | "descending";
17
- } | ConstantAccessor<RawValue, Datum>;
18
+ } | ((a: RawValue, b: RawValue) => number) | ConstantAccessor<RawValue, Datum>;
18
19
  stroke: import("../types/channel").ChannelAccessor<Datum>;
19
20
  strokeWidth: ConstantAccessor<number, Datum>;
20
21
  strokeOpacity: ConstantAccessor<number, Datum>;
@@ -63,7 +64,7 @@ declare function $$render<Datum extends RawValue>(): {
63
64
  class: string;
64
65
  style: string;
65
66
  cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
66
- }>, "fillOpacity" | "paintOrder" | "href" | "target" | "title"> & {
67
+ }>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
67
68
  data?: Datum[];
68
69
  automatic?: boolean;
69
70
  title?: string | false | null;
@@ -11,6 +11,11 @@
11
11
  x2?: ChannelAccessor<Datum>;
12
12
  y?: ChannelAccessor<Datum>;
13
13
  stack?: StackOptions;
14
+ /**
15
+ * Renders using Canvas instead of SVG.
16
+ */
17
+
18
+ canvas?: boolean;
14
19
  /**
15
20
  * Converts x into x1/x2 ranges based on the provided interval. Disables the
16
21
  * implicit stacking
@@ -25,6 +30,7 @@
25
30
  import type { DataRow } from '../types/index.js';
26
31
  import GroupMultiple from './helpers/GroupMultiple.svelte';
27
32
  import RectPath from './helpers/RectPath.svelte';
33
+ import RectCanvas from './helpers/RectCanvas.svelte';
28
34
  import type {
29
35
  BaseMarkProps,
30
36
  BaseRectMarkProps,
@@ -46,6 +52,7 @@
46
52
  data = [{} as Datum],
47
53
  class: className = null,
48
54
  stack,
55
+ canvas = false,
49
56
  ...options
50
57
  }: BarXMarkProps = $derived({ ...DEFAULTS, ...markProps });
51
58
 
@@ -55,8 +62,7 @@
55
62
  stackX(
56
63
  intervalX(
57
64
  // by default, sort by y channel (the ordinal labels)
58
- sort(recordizeX({ data, ...options })),
59
- { plot }
65
+ sort(recordizeX({ data, ...options }))
60
66
  ),
61
67
  stack
62
68
  )
@@ -68,25 +74,50 @@
68
74
  requiredScales={{ y: ['band'] }}
69
75
  channels={['x1', 'x2', 'y', 'fill', 'stroke', 'opacity', 'fillOpacity', 'strokeOpacity']}
70
76
  {...args}>
71
- {#snippet children({ mark, usedScales, scaledData })}
72
- <GroupMultiple class="bar-x" length={scaledData.length}>
73
- {#each scaledData as d, i (i)}
74
- {@const bw = plot.scales.y.fn.bandwidth()}
75
- {@const minx = Math.min(d.x1, d.x2)}
76
- {@const maxx = Math.max(d.x1, d.x2)}
77
- {#if d.valid}
78
- <RectPath
79
- {usedScales}
80
- class={className}
81
- {options}
82
- datum={d}
83
- x={minx}
84
- useInsetAsFallbackHorizontally={false}
85
- y={d.y - bw * 0.5}
86
- width={maxx - minx}
87
- height={bw} />
88
- {/if}
89
- {/each}
90
- </GroupMultiple>
77
+ {#snippet children({ usedScales, scaledData })}
78
+ {@const bw = plot.scales.y.fn.bandwidth()}
79
+ {@const barGroupClass = className ? `bar-x ${className}` : 'bar-x'}
80
+ {#if canvas}
81
+ {@const rectCanvasData = scaledData
82
+ .filter((d) => d.valid)
83
+ .map((d) => {
84
+ const minx = Math.min(d.x1, d.x2);
85
+ const maxx = Math.max(d.x1, d.x2);
86
+
87
+ return {
88
+ ...d,
89
+ x1: minx,
90
+ x2: maxx,
91
+ y1: d.y - bw * 0.5,
92
+ y2: d.y + bw * 0.5
93
+ };
94
+ })}
95
+ <GroupMultiple class={barGroupClass} length={scaledData.length}>
96
+ <RectCanvas
97
+ {options}
98
+ data={rectCanvasData}
99
+ {usedScales}
100
+ useInsetAsFallbackHorizontally={false} />
101
+ </GroupMultiple>
102
+ {:else}
103
+ <GroupMultiple class="bar-x" length={scaledData.length}>
104
+ {#each scaledData as d, i (i)}
105
+ {@const minx = Math.min(d.x1, d.x2)}
106
+ {@const maxx = Math.max(d.x1, d.x2)}
107
+ {#if d.valid}
108
+ <RectPath
109
+ {usedScales}
110
+ class={className}
111
+ {options}
112
+ datum={d}
113
+ x={minx}
114
+ useInsetAsFallbackHorizontally={false}
115
+ y={d.y - bw * 0.5}
116
+ width={maxx - minx}
117
+ height={bw} />
118
+ {/if}
119
+ {/each}
120
+ </GroupMultiple>
121
+ {/if}
91
122
  {/snippet}
92
123
  </Mark>
@@ -1,3 +1,4 @@
1
+ import { stackX } from '../index.js';
1
2
  import type { StackOptions } from '../transforms/stack.js';
2
3
  import type { DataRow } from '../types/index.js';
3
4
  import type { BaseRectMarkProps, ChannelAccessor, LinkableMarkProps } from '../types/index.js';
@@ -9,14 +10,14 @@ declare function $$render<Datum extends DataRow>(): {
9
10
  fy: ChannelAccessor<Datum>;
10
11
  dx: import("../types/index.js").ConstantAccessor<number, Datum>;
11
12
  dy: import("../types/index.js").ConstantAccessor<number, Datum>;
12
- dodgeX: import("../transforms/dodge").DodgeXOptions;
13
- dodgeY: import("../transforms/dodge").DodgeYOptions;
13
+ dodgeX: stackX;
14
+ dodgeY: stackX;
14
15
  fill: ChannelAccessor<Datum>;
15
16
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
16
- sort: ((a: import("../types/index.js").RawValue, b: import("../types/index.js").RawValue) => number) | {
17
+ sort: {
17
18
  channel: string;
18
19
  order?: "ascending" | "descending";
19
- } | import("../types/index.js").ConstantAccessor<import("../types/index.js").RawValue, Datum>;
20
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Datum>;
20
21
  stroke: ChannelAccessor<Datum>;
21
22
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
22
23
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
@@ -72,6 +73,10 @@ declare function $$render<Datum extends DataRow>(): {
72
73
  x2?: ChannelAccessor<Datum>;
73
74
  y?: ChannelAccessor<Datum>;
74
75
  stack?: StackOptions;
76
+ /**
77
+ * Renders using Canvas instead of SVG.
78
+ */
79
+ canvas?: boolean;
75
80
  /**
76
81
  * Converts x into x1/x2 ranges based on the provided interval. Disables the
77
82
  * implicit stacking