svelteplot 0.7.0-pr-277.3 → 0.7.1-pr-278.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.
@@ -19,11 +19,10 @@
19
19
  import { resolveScaledStyles } from '../helpers/resolve.js';
20
20
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
21
21
 
22
- interface AxisXMarkProps
23
- extends Omit<
24
- BaseMarkProps<Datum>,
25
- 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'
26
- > {
22
+ interface AxisXMarkProps extends Omit<
23
+ BaseMarkProps<Datum>,
24
+ 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'
25
+ > {
27
26
  data?: Datum[];
28
27
  automatic?: boolean;
29
28
  title?: string | false | null;
@@ -115,6 +114,17 @@
115
114
  )
116
115
  );
117
116
 
117
+ const useCompactNotation = $derived(
118
+ new Set(
119
+ ticks
120
+ .filter(
121
+ (tick): tick is number =>
122
+ typeof tick === 'number' && Number.isFinite(tick)
123
+ )
124
+ .map((tick) => (tick === 0 ? -Infinity : Math.floor(Math.log10(Math.abs(tick)))))
125
+ ).size > 1
126
+ );
127
+
118
128
  const tickFmt = $derived(tickFormat || plot.options.x.tickFormat);
119
129
 
120
130
  const useTickFormat = $derived(
@@ -133,10 +143,8 @@
133
143
  : // auto
134
144
  (d: RawValue) =>
135
145
  Intl.NumberFormat(plot.options.locale, {
136
- // use compact notation if range covers multipe magnitudes
137
- ...(new Set(ticks.map(Math.log10).map(Math.round)).size > 1
138
- ? { notation: 'compact' }
139
- : {}),
146
+ // use compact notation if range covers multiple magnitudes
147
+ ...(useCompactNotation ? { notation: 'compact' } : {}),
140
148
  ...DEFAULTS.numberFormat,
141
149
  style: plot.options.x.percent ? 'percent' : 'decimal'
142
150
  }).format(d)
@@ -18,11 +18,10 @@
18
18
  import { resolveScaledStyles } from '../helpers/resolve.js';
19
19
  import { getPlotDefaults } from '../hooks/plotDefaults.js';
20
20
 
21
- interface AxisYMarkProps
22
- extends Omit<
23
- BaseMarkProps<Datum>,
24
- 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'
25
- > {
21
+ interface AxisYMarkProps extends Omit<
22
+ BaseMarkProps<Datum>,
23
+ 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target'
24
+ > {
26
25
  data?: Datum[];
27
26
  automatic?: boolean;
28
27
  title?: string | false | null;
@@ -113,6 +112,14 @@
113
112
  )
114
113
  );
115
114
 
115
+ const useCompactNotation = $derived(
116
+ new Set(
117
+ ticks
118
+ .filter((tick): tick is number => typeof tick === 'number' && Number.isFinite(tick))
119
+ .map((tick) => (tick === 0 ? -Infinity : Math.floor(Math.log10(Math.abs(tick)))))
120
+ ).size > 1
121
+ );
122
+
116
123
  const tickFmt = $derived(tickFormat || plot.options.y.tickFormat);
117
124
 
118
125
  const useTickFormat = $derived(
@@ -131,10 +138,8 @@
131
138
  : // auto
132
139
  (d: RawValue) =>
133
140
  Intl.NumberFormat(plot.options.locale, {
134
- // use compact notation if range covers multipe magnitudes
135
- ...(new Set(ticks.map(Math.log10).map(Math.round)).size > 1
136
- ? { notation: 'compact' }
137
- : {}),
141
+ // use compact notation if range covers multiple magnitudes
142
+ ...(useCompactNotation ? { notation: 'compact' } : {}),
138
143
  ...DEFAULTS.numberFormat,
139
144
  style: plot.options.y.percent ? 'percent' : 'decimal'
140
145
  }).format(d)
@@ -4,9 +4,7 @@
4
4
  -->
5
5
  <script lang="ts" generics="Datum extends DataRow">
6
6
  interface BarXMarkProps
7
- extends BaseMarkProps<Datum>,
8
- LinkableMarkProps<Datum>,
9
- BaseRectMarkProps<Datum> {
7
+ extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, BaseRectMarkProps<Datum> {
10
8
  data: Datum[];
11
9
  x?: ChannelAccessor<Datum>;
12
10
  x1?: ChannelAccessor<Datum>;
@@ -5,9 +5,7 @@
5
5
 
6
6
  <script lang="ts" generics="Datum extends DataRow">
7
7
  interface BarYMarkProps
8
- extends BaseMarkProps<Datum>,
9
- LinkableMarkProps<Datum>,
10
- BaseRectMarkProps<Datum> {
8
+ extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, BaseRectMarkProps<Datum> {
11
9
  data: Datum[];
12
10
  x?: ChannelAccessor<Datum>;
13
11
  y?: ChannelAccessor<Datum>;
@@ -2,8 +2,10 @@
2
2
  Creates a vertical box plot for visualizing data distribution with quartiles and outliers
3
3
  -->
4
4
  <script lang="ts" generics="Datum extends DataRecord">
5
- interface BoxYMarkProps
6
- extends Pick<BaseMarkProps<Datum>, 'class' | 'fill' | 'stroke' | 'fx' | 'fy'> {
5
+ interface BoxYMarkProps extends Pick<
6
+ BaseMarkProps<Datum>,
7
+ 'class' | 'fill' | 'stroke' | 'fx' | 'fy'
8
+ > {
7
9
  data: Datum[];
8
10
  x: ChannelAccessor;
9
11
  y: ChannelAccessor;
@@ -3,19 +3,18 @@
3
3
  For creating a two-dimensional brush selection
4
4
  -->
5
5
  <script lang="ts" generics="Datum extends DataRecord">
6
- interface BrushMarkProps
7
- extends Pick<
8
- BaseMarkProps<Datum>,
9
- | 'cursor'
10
- | 'stroke'
11
- | 'strokeDasharray'
12
- | 'strokeOpacity'
13
- | 'strokeWidth'
14
- | 'strokeLinecap'
15
- | 'strokeDashoffset'
16
- | 'strokeLinejoin'
17
- | 'strokeMiterlimit'
18
- > {
6
+ interface BrushMarkProps extends Pick<
7
+ BaseMarkProps<Datum>,
8
+ | 'cursor'
9
+ | 'stroke'
10
+ | 'strokeDasharray'
11
+ | 'strokeOpacity'
12
+ | 'strokeWidth'
13
+ | 'strokeLinecap'
14
+ | 'strokeDashoffset'
15
+ | 'strokeLinejoin'
16
+ | 'strokeMiterlimit'
17
+ > {
19
18
  brush: Brush;
20
19
  /**
21
20
  * limit brushing to x or y dimension
@@ -4,9 +4,7 @@
4
4
  -->
5
5
  <script lang="ts" generics="Datum extends DataRecord">
6
6
  interface CellMarkProps
7
- extends BaseMarkProps<Datum>,
8
- LinkableMarkProps<Datum>,
9
- BaseRectMarkProps<Datum> {
7
+ extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, BaseRectMarkProps<Datum> {
10
8
  data: Datum[];
11
9
  x?: ChannelAccessor<Datum>;
12
10
  y?: ChannelAccessor<Datum>;
@@ -4,7 +4,8 @@
4
4
  -->
5
5
  <script lang="ts" generics="Datum extends DataRecord">
6
6
  interface FrameMarkProps
7
- extends Omit<BaseMarkProps<Datum>, 'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity'>,
7
+ extends
8
+ Omit<BaseMarkProps<Datum>, 'fill' | 'stroke' | 'fillOpacity' | 'strokeOpacity'>,
8
9
  BaseRectMarkProps<Datum>,
9
10
  LinkableMarkProps<Datum> {
10
11
  fill?: string;
@@ -3,11 +3,10 @@
3
3
  -->
4
4
 
5
5
  <script lang="ts">
6
- interface GraticuleMarkProps
7
- extends Omit<
8
- BaseMarkProps<GeoJSON.GeoJsonObject>,
9
- 'fill' | 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target' | 'cursor'
10
- > {
6
+ interface GraticuleMarkProps extends Omit<
7
+ BaseMarkProps<GeoJSON.GeoJsonObject>,
8
+ 'fill' | 'fillOpacity' | 'paintOrder' | 'title' | 'href' | 'target' | 'cursor'
9
+ > {
11
10
  step?: number;
12
11
  stepX?: number;
13
12
  stepY?: number;
@@ -4,9 +4,7 @@
4
4
  -->
5
5
  <script lang="ts" generics="Datum extends DataRecord">
6
6
  interface RectMarkProps
7
- extends BaseMarkProps<Datum>,
8
- LinkableMarkProps<Datum>,
9
- BaseRectMarkProps<Datum> {
7
+ extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, BaseRectMarkProps<Datum> {
10
8
  data: Datum[];
11
9
  x?: ChannelAccessor<Datum>;
12
10
  x1?: ChannelAccessor<Datum>;
@@ -3,8 +3,7 @@
3
3
 
4
4
  <script lang="ts">
5
5
  interface SphereMarkProps
6
- extends BaseMarkProps<GeoJSON.GeoJsonObject>,
7
- LinkableMarkProps<GeoJSON.GeoJsonObject> {}
6
+ extends BaseMarkProps<GeoJSON.GeoJsonObject>, LinkableMarkProps<GeoJSON.GeoJsonObject> {}
8
7
 
9
8
  import Geo from './Geo.svelte';
10
9
  import type { BaseMarkProps, LinkableMarkProps, PlotDefaults } from '../types/index.js';
@@ -3,11 +3,10 @@
3
3
  Wrapper around the vector mark with presets suitable for spike maps
4
4
  -->
5
5
  <script lang="ts" generics="Datum extends DataRecord">
6
- interface SpikeMarkProps
7
- extends Omit<
8
- ComponentProps<typeof Vector>,
9
- 'data' | 'x' | 'y' | 'r' | 'length' | 'rotate'
10
- > {
6
+ interface SpikeMarkProps extends Omit<
7
+ ComponentProps<typeof Vector>,
8
+ 'data' | 'x' | 'y' | 'r' | 'length' | 'rotate'
9
+ > {
11
10
  data: Datum[];
12
11
  x: ChannelAccessor<Datum>;
13
12
  y: ChannelAccessor<Datum>;
@@ -20,9 +20,7 @@
20
20
  import { roundedRect } from '../helpers/roundedRect';
21
21
 
22
22
  interface WaffleXMarkProps
23
- extends BaseMarkProps<Datum>,
24
- LinkableMarkProps<Datum>,
25
- WaffleOptions<Datum> {
23
+ extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, WaffleOptions<Datum> {
26
24
  data?: Datum[];
27
25
  /**
28
26
  * bound to a quantitative scale
@@ -21,9 +21,7 @@
21
21
  import GroupMultiple from './helpers/GroupMultiple.svelte';
22
22
 
23
23
  interface WaffleYMarkProps
24
- extends BaseMarkProps<Datum>,
25
- LinkableMarkProps<Datum>,
26
- WaffleOptions<Datum> {
24
+ extends BaseMarkProps<Datum>, LinkableMarkProps<Datum>, WaffleOptions<Datum> {
27
25
  data?: Datum[];
28
26
  /**
29
27
  * bound to a babd scale
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelteplot",
3
- "version": "0.7.0-pr-277.3",
3
+ "version": "0.7.1-pr-278.0",
4
4
  "license": "ISC",
5
5
  "author": {
6
6
  "name": "Gregor Aisch",
@@ -54,13 +54,13 @@
54
54
  "devDependencies": {
55
55
  "@aitodotai/json-stringify-pretty-compact": "^1.3.0",
56
56
  "@emotion/css": "^11.13.5",
57
- "@shikijs/twoslash": "^3.15.0",
57
+ "@shikijs/twoslash": "^3.17.0",
58
58
  "@sveltejs/adapter-auto": "^7.0.0",
59
59
  "@sveltejs/adapter-static": "^3.0.10",
60
- "@sveltejs/enhanced-img": "^0.9.0",
60
+ "@sveltejs/enhanced-img": "^0.9.2",
61
61
  "@sveltejs/eslint-config": "^8.3.4",
62
62
  "@sveltejs/kit": "^2.49.0",
63
- "@sveltejs/package": "^2.5.6",
63
+ "@sveltejs/package": "^2.5.7",
64
64
  "@sveltejs/vite-plugin-svelte": "6.2.1",
65
65
  "@sveltepress/twoslash": "^1.3.1",
66
66
  "@sveltepress/vite": "^1.3.1",
@@ -80,8 +80,8 @@
80
80
  "@types/geojson": "^7946.0.16",
81
81
  "@types/topojson": "^3.2.6",
82
82
  "@types/topojson-client": "^3.1.5",
83
- "@typescript-eslint/eslint-plugin": "^8.47.0",
84
- "@typescript-eslint/parser": "^8.47.0",
83
+ "@typescript-eslint/eslint-plugin": "^8.48.0",
84
+ "@typescript-eslint/parser": "^8.48.0",
85
85
  "@unocss/extractor-svelte": "^66.5.9",
86
86
  "@vite-pwa/sveltekit": "^1.0.1",
87
87
  "csstype": "^3.2.3",
@@ -96,14 +96,14 @@
96
96
  "lru-cache": "^11.2.2",
97
97
  "mdast-util-from-markdown": "^2.0.2",
98
98
  "mdast-util-gfm": "^3.1.0",
99
- "prettier": "^3.6.2",
99
+ "prettier": "^3.7.1",
100
100
  "prettier-plugin-svelte": "^3.4.0",
101
101
  "puppeteer": "^24.31.0",
102
102
  "remark-code-extra": "^1.0.1",
103
103
  "remark-code-frontmatter": "^1.0.0",
104
104
  "resize-observer-polyfill": "^1.5.1",
105
105
  "sass": "^1.94.2",
106
- "shiki": "^3.15.0",
106
+ "shiki": "^3.17.0",
107
107
  "svelte-check": "^4.3.4",
108
108
  "svelte-eslint-parser": "1.4.0",
109
109
  "svelte-highlight": "^7.9.0",
@@ -118,7 +118,7 @@
118
118
  "unist-util-visit": "^5.0.0",
119
119
  "unocss": "^66.5.9",
120
120
  "vite": "^7.2.4",
121
- "vitest": "^4.0.13",
121
+ "vitest": "^4.0.14",
122
122
  "vitest-matchmedia-mock": "^2.0.3",
123
123
  "yoctocolors": "^2.1.2"
124
124
  },