svelteplot 0.8.0 → 0.8.1-pr-283.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.
Files changed (80) hide show
  1. package/dist/Mark.svelte +1 -1
  2. package/dist/Mark.svelte.d.ts +6 -4
  3. package/dist/constants.d.ts +3 -1
  4. package/dist/constants.js +2 -0
  5. package/dist/helpers/colors.d.ts +9 -12
  6. package/dist/helpers/facets.d.ts +1 -1
  7. package/dist/helpers/getBaseStyles.d.ts +2 -4
  8. package/dist/helpers/index.d.ts +3 -3
  9. package/dist/helpers/projection.js +5 -2
  10. package/dist/helpers/reduce.d.ts +1 -1
  11. package/dist/helpers/scales.d.ts +7 -7
  12. package/dist/helpers/symbols.d.ts +2 -2
  13. package/dist/helpers/time.d.ts +3 -3
  14. package/dist/helpers/typeChecks.d.ts +8 -8
  15. package/dist/helpers/wordwrap.d.ts +6 -5
  16. package/dist/helpers/wordwrap.js +7 -6
  17. package/dist/index.d.ts +1 -0
  18. package/dist/index.js +1 -0
  19. package/dist/marks/Area.svelte.d.ts +6 -4
  20. package/dist/marks/AreaX.svelte.d.ts +7 -5
  21. package/dist/marks/Arrow.svelte.d.ts +6 -4
  22. package/dist/marks/AxisX.svelte.d.ts +7 -5
  23. package/dist/marks/AxisY.svelte +1 -1
  24. package/dist/marks/AxisY.svelte.d.ts +7 -5
  25. package/dist/marks/BarX.svelte.d.ts +6 -4
  26. package/dist/marks/BarY.svelte.d.ts +6 -4
  27. package/dist/marks/BollingerX.svelte.d.ts +2 -76
  28. package/dist/marks/BollingerY.svelte.d.ts +2 -76
  29. package/dist/marks/BoxY.svelte.d.ts +1 -63
  30. package/dist/marks/Brush.svelte.d.ts +1 -63
  31. package/dist/marks/Cell.svelte.d.ts +6 -4
  32. package/dist/marks/CustomMark.svelte.d.ts +2 -84
  33. package/dist/marks/DifferenceY.svelte.d.ts +1 -63
  34. package/dist/marks/Dot.svelte.d.ts +6 -4
  35. package/dist/marks/DotX.svelte.d.ts +7 -5
  36. package/dist/marks/DotY.svelte.d.ts +7 -5
  37. package/dist/marks/Frame.svelte.d.ts +7 -5
  38. package/dist/marks/Geo.svelte +2 -0
  39. package/dist/marks/Geo.svelte.d.ts +7 -4
  40. package/dist/marks/GridX.svelte.d.ts +6 -4
  41. package/dist/marks/GridY.svelte.d.ts +6 -4
  42. package/dist/marks/Image.svelte.d.ts +2 -75
  43. package/dist/marks/Line.svelte +5 -2
  44. package/dist/marks/Line.svelte.d.ts +6 -4
  45. package/dist/marks/LineX.svelte.d.ts +8 -6
  46. package/dist/marks/LineY.svelte.d.ts +8 -6
  47. package/dist/marks/Link.svelte.d.ts +6 -4
  48. package/dist/marks/Rect.svelte.d.ts +6 -4
  49. package/dist/marks/RuleX.svelte.d.ts +6 -4
  50. package/dist/marks/RuleY.svelte.d.ts +6 -4
  51. package/dist/marks/Spike.svelte.d.ts +7 -5
  52. package/dist/marks/Text.svelte.d.ts +6 -4
  53. package/dist/marks/TickX.svelte.d.ts +6 -4
  54. package/dist/marks/TickY.svelte.d.ts +6 -4
  55. package/dist/marks/Trail.svelte +157 -0
  56. package/dist/marks/Trail.svelte.d.ts +44 -0
  57. package/dist/marks/Vector.svelte.d.ts +6 -4
  58. package/dist/marks/WaffleX.svelte.d.ts +2 -85
  59. package/dist/marks/WaffleY.svelte.d.ts +2 -83
  60. package/dist/marks/helpers/BaseAxisX.svelte +6 -7
  61. package/dist/marks/helpers/MarkerPath.svelte.d.ts +2 -102
  62. package/dist/marks/helpers/TrailCanvas.svelte +0 -0
  63. package/dist/marks/helpers/TrailCanvas.svelte.d.ts +26 -0
  64. package/dist/marks/helpers/trail.d.ts +23 -0
  65. package/dist/marks/helpers/trail.js +372 -0
  66. package/dist/marks/index.d.ts +1 -0
  67. package/dist/marks/index.js +1 -0
  68. package/dist/transforms/bollinger.d.ts +1 -69
  69. package/dist/transforms/centroid.d.ts +1 -4
  70. package/dist/transforms/group.d.ts +4 -12
  71. package/dist/transforms/interval.d.ts +2 -128
  72. package/dist/transforms/normalize.d.ts +23 -0
  73. package/dist/transforms/recordize.d.ts +4 -7
  74. package/dist/transforms/select.d.ts +7 -448
  75. package/dist/transforms/sort.d.ts +5 -253
  76. package/dist/transforms/stack.d.ts +3 -23
  77. package/dist/transforms/window.d.ts +2 -134
  78. package/dist/types/mark.d.ts +2 -1
  79. package/dist/types/plot.d.ts +5 -1
  80. package/package.json +147 -145
package/dist/Mark.svelte CHANGED
@@ -151,7 +151,7 @@
151
151
  // check if the mark has defined an accessor for this channel
152
152
  if (options?.[channel] !== undefined && out[channel] === undefined) {
153
153
  // resolve value
154
- out[channel] = resolveChannel(channel, row, options);
154
+ out[channel] = resolveChannel(channel, row, options, index);
155
155
  if (options[channel] === INDEX) {
156
156
  const scale = plot.scales[CHANNEL_SCALE[channel]];
157
157
  if (scale.type === 'band' || scale.type === 'point') {
@@ -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>;
@@ -28,6 +29,7 @@ declare function $$render<Datum extends DataRecord>(): {
28
29
  strokeDashoffset: import("./types/index.js").ConstantAccessor<number, Datum>;
29
30
  mixBlendMode: import("./types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
30
31
  clipPath: string;
32
+ mask: string;
31
33
  imageFilter: import("./types/index.js").ConstantAccessor<string, Datum>;
32
34
  shapeRendering: import("./types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
33
35
  paintOrder: import("./types/index.js").ConstantAccessor<string, Datum>;
@@ -13,4 +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
+ export declare const PI: number;
18
+ export declare const TAU: number;
package/dist/constants.js CHANGED
@@ -117,6 +117,8 @@ export const CSS_COLOR_CONTRAST = /^color-contrast\(/; // just check for prefix
117
117
  export const CSS_RGBA = /^rgba\(/; // just check for prefix
118
118
  export const CSS_URL = /^url\(#/; // just check for prefix
119
119
  export const INDEX = Symbol('index');
120
+ export const PI = Math.PI;
121
+ export const TAU = PI * 2;
120
122
  // export const CHANNEL_MAP: Record<ScaleName, ValueOf<typeof SCALE_TYPES>> = {
121
123
  // x: SCALE_TYPES.x,
122
124
  // y: SCALE_TYPES.y,
@@ -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[];
6
- export declare function isOrdinalScheme(scheme: ColorScheme): boolean;
7
- export declare function ordinalScheme(scheme: string): SchemeGetter | undefined;
8
- export declare function ordinalRange(scheme: string, length: number): readonly string[] | undefined;
9
- export declare function maybeBooleanRange(domain: boolean[], scheme?: string): unknown[] | undefined;
10
- export declare function isQuantitativeScheme(scheme: string): boolean;
11
- export declare function quantitativeScheme(scheme: string): typeof interpolateBrBG | undefined;
12
- export declare function isDivergingScheme(scheme: string): boolean;
13
- export {};
2
+ export declare const categoricalSchemes: any;
3
+ export declare function isCategoricalScheme(scheme: string): any;
4
+ export declare function isOrdinalScheme(scheme: ColorScheme): any;
5
+ export declare function ordinalScheme(scheme: string): any;
6
+ export declare function ordinalRange(scheme: string, length: number): any;
7
+ export declare function maybeBooleanRange(domain: boolean[], scheme?: string): any[] | undefined;
8
+ export declare function isQuantitativeScheme(scheme: string): any;
9
+ export declare function quantitativeScheme(scheme: string): any;
10
+ export declare function isDivergingScheme(scheme: string): 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,9 +1,7 @@
1
1
  import type { Channels } from '../types/index.js';
2
2
  import type { DataRow } from '../types/index.js';
3
- export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>): {
4
- [k: string]: string | number;
5
- };
6
- export default function (datum: DataRow, props: Partial<Channels>): string;
3
+ export declare function getBaseStylesObject(datum: DataRow, props: Partial<Channels>): any;
4
+ export default function (datum: DataRow, props: Partial<Channels>): any;
7
5
  export declare function maybeToPixel(cssKey: string, value: string | number): string | number;
8
6
  export declare function maybeFromPixel(value: string | number): string | number;
9
7
  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;
@@ -50,7 +50,7 @@ export function createProjection({ projOptions, inset: globalInset = 2, insetTop
50
50
  let transform;
51
51
  let invertTransform = (d) => d;
52
52
  // If a domain is specified, fit the projection to the frame.
53
- if (domain != null) {
53
+ if (domain != null && dx > 0 && dy > 0) {
54
54
  const [[x0, y0], [x1, y1]] = geoPath(projInstance).bounds(domain);
55
55
  const k = Math.min(dx / (x1 - x0), dy / (y1 - y0));
56
56
  aspectRatio = (y1 - y0) / (x1 - x0);
@@ -66,9 +66,12 @@ export function createProjection({ projOptions, inset: globalInset = 2, insetTop
66
66
  invertTransform = ([x, y]) => [(x - tx) / k, (y - ty) / k];
67
67
  }
68
68
  else {
69
- throw new Error(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
69
+ console.warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
70
70
  }
71
71
  }
72
+ else if (domain != null) {
73
+ console.warn(`Warning: the projection could not be fit to the specified domain; using the default scale.`);
74
+ }
72
75
  transform ??=
73
76
  tx === 0 && ty === 0
74
77
  ? identity()
@@ -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";
@@ -1,5 +1,5 @@
1
1
  import { type SymbolType } from 'd3-shape';
2
2
  export declare const sqrt3: number;
3
3
  export declare const sqrt4_3: number;
4
- export declare function isSymbol(value: string | SymbolType): boolean;
5
- export declare function maybeSymbol(symbol: SymbolType | string): SymbolType;
4
+ export declare function isSymbol(value: string | SymbolType): any;
5
+ export declare function maybeSymbol(symbol: SymbolType | string): any;
@@ -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;
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): boolean;
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): any;
9
+ export declare function isColorOrNull(v: RawValue | null | undefined): any;
10
+ export declare function isOpacityOrNull(v: RawValue): any;
@@ -5,10 +5,11 @@
5
5
  * - Uses a rough character width table to approximate line widths.
6
6
  * - Wraps once the maximum visual width is exceeded, but only after a minimum.
7
7
  */
8
- export default function wordwrap(line: string, { maxCharactersPerLine, maxLineWidth }: {
9
- maxCharactersPerLine?: number;
10
- maxLineWidth?: number;
11
- }, { minCharactersPerLine, minLineWidth }: {
8
+ export default function wordwrap(line: string, options?: {
12
9
  minCharactersPerLine?: number;
13
10
  minLineWidth?: number;
14
- }, fontSize?: number, monospace?: boolean): string[];
11
+ maxCharactersPerLine?: number;
12
+ maxLineWidth?: number;
13
+ fontSize?: number;
14
+ monospace?: boolean;
15
+ }): string[];
@@ -67,7 +67,8 @@ const CHAR_W = {
67
67
  * - Uses a rough character width table to approximate line widths.
68
68
  * - Wraps once the maximum visual width is exceeded, but only after a minimum.
69
69
  */
70
- export default function wordwrap(line, { maxCharactersPerLine, maxLineWidth }, { minCharactersPerLine, minLineWidth }, fontSize = 12, monospace = false) {
70
+ export default function wordwrap(line, options = {}) {
71
+ let { minCharactersPerLine, minLineWidth, maxCharactersPerLine, maxLineWidth, fontSize, monospace } = { fontSize: 12, maxCharactersPerLine: 10, ...options };
71
72
  // Tokenized words (with hyphen-splitting applied) including trailing spaces/hyphens.
72
73
  const tokens = [];
73
74
  // First split by spaces, then further split by hyphens so we can
@@ -86,20 +87,20 @@ export default function wordwrap(line, { maxCharactersPerLine, maxLineWidth }, {
86
87
  tokens.push(word + trailingWhitespace);
87
88
  }
88
89
  });
89
- const maxChars = maxCharactersPerLine || 40;
90
90
  if (!maxLineWidth) {
91
91
  // Fallback for max characters per line if not provided / falsy.
92
92
  // Convert character counts into approximate visual widths.
93
- maxLineWidth = maxChars * CHAR_W.a;
93
+ maxLineWidth = maxCharactersPerLine * CHAR_W.a;
94
94
  }
95
95
  if (!minLineWidth) {
96
96
  // Estimate a good minimum line length:
97
97
  // - start from either a provided value or
98
- // - clamp a scaled median word length between 3 and half of maxChars.
98
+ // - clamp a scaled median word length between 3 and half of maxCharactersPerLine.
99
99
  const sortedWordLengths = tokens.map((t) => t.length).sort((a, b) => a - b);
100
100
  const medianIndex = Math.round(tokens.length / 2);
101
- const medianWordLength = sortedWordLengths[medianIndex] ?? maxChars;
102
- const minChars = minCharactersPerLine || Math.max(3, Math.min(maxChars * 0.5, 0.75 * medianWordLength));
101
+ const medianWordLength = sortedWordLengths[medianIndex] ?? maxCharactersPerLine;
102
+ const minChars = minCharactersPerLine ||
103
+ Math.max(3, Math.min(maxCharactersPerLine * 0.5, 0.75 * medianWordLength));
103
104
  minLineWidth = minChars * CHAR_W.a;
104
105
  }
105
106
  const lines = [];
package/dist/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export { default as PlotCore } from './core/Plot.svelte';
3
3
  export * from './marks/index.js';
4
4
  export * from './transforms/index.js';
5
5
  export { formatMonth } from './helpers/formats.js';
6
+ export { default as wordwrap } from './helpers/wordwrap.js';
6
7
  export * from './hooks/plotDefaults.js';
package/dist/index.js CHANGED
@@ -4,5 +4,6 @@ export * from './marks/index.js';
4
4
  export * from './transforms/index.js';
5
5
  // helpers
6
6
  export { formatMonth } from './helpers/formats.js';
7
+ export { default as wordwrap } from './helpers/wordwrap.js';
7
8
  // hooks
8
9
  export * from './hooks/plotDefaults.js';
@@ -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>;
@@ -28,6 +29,7 @@ declare function $$render<Datum extends DataRecord>(): {
28
29
  strokeDashoffset: ConstantAccessor<number, Datum>;
29
30
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
30
31
  clipPath: string;
32
+ mask: string;
31
33
  imageFilter: ConstantAccessor<string, Datum>;
32
34
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
33
35
  paintOrder: ConstantAccessor<string, 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>>;
@@ -26,6 +27,7 @@ declare function $$render<Datum extends DataRow>(): {
26
27
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Record<string | symbol, import("../types/data").RawValue>>;
27
28
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Record<string | symbol, import("../types/data").RawValue>>;
28
29
  clipPath: string;
30
+ mask: string;
29
31
  imageFilter: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
30
32
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Record<string | symbol, import("../types/data").RawValue>>;
31
33
  paintOrder: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
@@ -74,7 +76,7 @@ declare function $$render<Datum extends DataRow>(): {
74
76
  sort?: import("../types/index.js").ConstantAccessor<import("../types/data").RawValue> | {
75
77
  channel: "stroke" | "fill";
76
78
  };
77
- stack?: Partial<import("../transforms/stack.js").StackOptions>;
79
+ stack?: Partial<renameChannels>;
78
80
  canvas?: boolean;
79
81
  areaClass?: import("../types/index.js").ConstantAccessor<string, Record<string | symbol, import("../types/data").RawValue>>;
80
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>;
@@ -27,6 +28,7 @@ declare function $$render<Datum extends DataRecord>(): {
27
28
  strokeDashoffset: ConstantAccessor<number, Datum>;
28
29
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
29
30
  clipPath: string;
31
+ mask: string;
30
32
  imageFilter: ConstantAccessor<string, Datum>;
31
33
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
32
34
  paintOrder: ConstantAccessor<string, Datum>;
@@ -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>;
@@ -27,6 +28,7 @@ declare function $$render<Datum extends RawValue>(): {
27
28
  strokeDashoffset: ConstantAccessor<number, Datum>;
28
29
  mixBlendMode: ConstantAccessor<CSS.Property.MixBlendMode, Datum>;
29
30
  clipPath: string;
31
+ mask: string;
30
32
  imageFilter: ConstantAccessor<string, Datum>;
31
33
  shapeRendering: ConstantAccessor<CSS.Property.ShapeRendering, Datum>;
32
34
  paintOrder: ConstantAccessor<string, Datum>;
@@ -63,7 +65,7 @@ declare function $$render<Datum extends RawValue>(): {
63
65
  class: string;
64
66
  style: string;
65
67
  cursor: ConstantAccessor<CSS.Property.Cursor, Datum>;
66
- }>, "fillOpacity" | "paintOrder" | "href" | "target" | "title"> & {
68
+ }>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
67
69
  data?: Datum[];
68
70
  automatic?: boolean;
69
71
  title?: string | false | null;
@@ -170,7 +170,7 @@
170
170
  : optionsLabel !== undefined
171
171
  ? optionsLabel
172
172
  : plot.scales.y.autoTitle
173
- ? `↑ ${plot.scales.y.autoTitle}${plot.options.y.percent ? ' (%)' : ''}`
173
+ ? `${!plot.options.y.reverse ? '↑' : '↓'} ${plot.scales.y.autoTitle}${plot.options.y.percent ? ' (%)' : ''}`
174
174
  : ''
175
175
  );
176
176
 
@@ -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>;
@@ -26,6 +27,7 @@ declare function $$render<Datum extends RawValue>(): {
26
27
  strokeDashoffset: ConstantAccessor<number, Datum>;
27
28
  mixBlendMode: ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
28
29
  clipPath: string;
30
+ mask: string;
29
31
  imageFilter: ConstantAccessor<string, Datum>;
30
32
  shapeRendering: ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
31
33
  paintOrder: ConstantAccessor<string, Datum>;
@@ -62,7 +64,7 @@ declare function $$render<Datum extends RawValue>(): {
62
64
  class: string;
63
65
  style: string;
64
66
  cursor: ConstantAccessor<import("csstype").Property.Cursor, Datum>;
65
- }>, "fillOpacity" | "paintOrder" | "href" | "target" | "title"> & {
67
+ }>, "fillOpacity" | "href" | "target" | "title" | "paintOrder"> & {
66
68
  data?: Datum[];
67
69
  automatic?: boolean;
68
70
  title?: string | false | null;
@@ -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>;
@@ -28,6 +29,7 @@ declare function $$render<Datum extends DataRow>(): {
28
29
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
29
30
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
30
31
  clipPath: string;
32
+ mask: string;
31
33
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
32
34
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
33
35
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;
@@ -1,3 +1,4 @@
1
+ import { intervalY } from '../index.js';
1
2
  import type { StackOptions } from '../transforms/stack.js';
2
3
  import type { BaseRectMarkProps, ChannelAccessor, DataRow, LinkableMarkProps } from '../types/index.js';
3
4
  declare function $$render<Datum extends DataRow>(): {
@@ -8,14 +9,14 @@ declare function $$render<Datum extends DataRow>(): {
8
9
  fy: ChannelAccessor<Datum>;
9
10
  dx: import("../types/index.js").ConstantAccessor<number, Datum>;
10
11
  dy: import("../types/index.js").ConstantAccessor<number, Datum>;
11
- dodgeX: import("../transforms/dodge").DodgeXOptions;
12
- dodgeY: import("../transforms/dodge").DodgeYOptions;
12
+ dodgeX: intervalY;
13
+ dodgeY: intervalY;
13
14
  fill: ChannelAccessor<Datum>;
14
15
  fillOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
15
- sort: ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | {
16
+ sort: {
16
17
  channel: string;
17
18
  order?: "ascending" | "descending";
18
- } | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Datum>;
19
+ } | ((a: import("../types/data").RawValue, b: import("../types/data").RawValue) => number) | import("../types/index.js").ConstantAccessor<import("../types/data").RawValue, Datum>;
19
20
  stroke: ChannelAccessor<Datum>;
20
21
  strokeWidth: import("../types/index.js").ConstantAccessor<number, Datum>;
21
22
  strokeOpacity: import("../types/index.js").ConstantAccessor<number, Datum>;
@@ -27,6 +28,7 @@ declare function $$render<Datum extends DataRow>(): {
27
28
  strokeDashoffset: import("../types/index.js").ConstantAccessor<number, Datum>;
28
29
  mixBlendMode: import("../types/index.js").ConstantAccessor<import("csstype").Property.MixBlendMode, Datum>;
29
30
  clipPath: string;
31
+ mask: string;
30
32
  imageFilter: import("../types/index.js").ConstantAccessor<string, Datum>;
31
33
  shapeRendering: import("../types/index.js").ConstantAccessor<import("csstype").Property.ShapeRendering, Datum>;
32
34
  paintOrder: import("../types/index.js").ConstantAccessor<string, Datum>;