svelteplot 0.5.1-pr-245.0 → 0.5.1-pr-246.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/core/Plot.svelte +2 -7
- package/dist/helpers/autoScales.js +10 -1
- package/dist/helpers/scales.d.ts +0 -1
- package/dist/helpers/scales.js +6 -9
- package/dist/marks/BarX.svelte +1 -1
- package/dist/marks/BarY.svelte +1 -1
- package/dist/marks/Dot.svelte +1 -6
- package/dist/types/plot.d.ts +0 -8
- package/package.json +1 -1
package/dist/core/Plot.svelte
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
margin: 'auto',
|
|
66
66
|
colorScheme: 'turbo',
|
|
67
67
|
unknown: '#cccccc99',
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
categoricalColorScheme: 'observable10',
|
|
70
70
|
pointScaleHeight: 18,
|
|
71
71
|
bandScaleHeight: 30,
|
|
@@ -365,12 +365,7 @@
|
|
|
365
365
|
initialOpts: Partial<PlotOptions>,
|
|
366
366
|
opts: PlotOptionsParameters
|
|
367
367
|
): PlotOptions {
|
|
368
|
-
return mergeDeep<PlotOptions>(
|
|
369
|
-
{},
|
|
370
|
-
{ sortOrdinalDomains: DEFAULTS.sortOrdinalDomains },
|
|
371
|
-
smartDefaultPlotOptions(opts),
|
|
372
|
-
initialOpts
|
|
373
|
-
);
|
|
368
|
+
return mergeDeep<PlotOptions>({}, smartDefaultPlotOptions(opts), initialOpts);
|
|
374
369
|
}
|
|
375
370
|
|
|
376
371
|
function maybeMargin(
|
|
@@ -79,7 +79,16 @@ export function autoScale({ name, type, domain, scaleOptions, plotOptions, plotW
|
|
|
79
79
|
...(type === 'band' || type === 'point'
|
|
80
80
|
? {
|
|
81
81
|
align: scaleOptions.align,
|
|
82
|
-
|
|
82
|
+
...(type === 'point'
|
|
83
|
+
? {
|
|
84
|
+
// point scales don't have paddingInner/Outer, only padding
|
|
85
|
+
padding: maybeNumber(coalesce(scaleOptions.padding, plotOptions.padding, 0.15))
|
|
86
|
+
}
|
|
87
|
+
: {
|
|
88
|
+
// padding: maybeNumber(coalesce(scaleOptions.padding, plotOptions.padding, 0.15)),
|
|
89
|
+
paddingInner: maybeNumber(coalesce(scaleOptions.paddingInner, scaleOptions.padding, plotOptions.padding, 0.15)),
|
|
90
|
+
paddingOuter: maybeNumber(coalesce(scaleOptions.paddingOuter, scaleOptions.padding, plotOptions.padding, 0.15))
|
|
91
|
+
})
|
|
83
92
|
}
|
|
84
93
|
: {})
|
|
85
94
|
};
|
package/dist/helpers/scales.d.ts
CHANGED
|
@@ -40,4 +40,3 @@ export declare function looksLikeANumber(input: string | number): boolean;
|
|
|
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 "point" | "ordinal" | "band" | "categorical" | "threshold";
|
package/dist/helpers/scales.js
CHANGED
|
@@ -48,7 +48,7 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
|
|
|
48
48
|
let manualActiveMarks = 0;
|
|
49
49
|
const propNames = new Set();
|
|
50
50
|
const uniqueScaleProps = new Set();
|
|
51
|
-
let sortOrdinalDomain =
|
|
51
|
+
let sortOrdinalDomain = true;
|
|
52
52
|
for (const mark of marks) {
|
|
53
53
|
// we only sort the scale domain alphabetically, if none of the
|
|
54
54
|
// marks that map to it are using the `sort` transform. Note that
|
|
@@ -152,7 +152,11 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
|
|
|
152
152
|
throw new Error(`Invalid scale type ${type} for scale
|
|
153
153
|
${name}. Valid types are ${[...VALID_SCALE_TYPES[name]].join(', ')}`);
|
|
154
154
|
}
|
|
155
|
-
const isOrdinal =
|
|
155
|
+
const isOrdinal = type === 'band' ||
|
|
156
|
+
type === 'point' ||
|
|
157
|
+
type === 'ordinal' ||
|
|
158
|
+
type === 'categorical' ||
|
|
159
|
+
type === 'threshold';
|
|
156
160
|
if (isOrdinal && sortOrdinalDomain) {
|
|
157
161
|
valueArr.sort(ascending);
|
|
158
162
|
}
|
|
@@ -347,10 +351,3 @@ export function projectY(channel, scales, value) {
|
|
|
347
351
|
? scales.y.fn.bandwidth()
|
|
348
352
|
: 0));
|
|
349
353
|
}
|
|
350
|
-
export function isOrdinalScale(scaleType) {
|
|
351
|
-
return (scaleType === 'band' ||
|
|
352
|
-
scaleType === 'point' ||
|
|
353
|
-
scaleType === 'ordinal' ||
|
|
354
|
-
scaleType === 'categorical' ||
|
|
355
|
-
scaleType === 'threshold');
|
|
356
|
-
}
|
package/dist/marks/BarX.svelte
CHANGED
package/dist/marks/BarY.svelte
CHANGED
package/dist/marks/Dot.svelte
CHANGED
|
@@ -32,7 +32,6 @@
|
|
|
32
32
|
import { addEventHandlers } from './helpers/events.js';
|
|
33
33
|
import Anchor from './helpers/Anchor.svelte';
|
|
34
34
|
import { getPlotDefaults } from '../hooks/plotDefaults.js';
|
|
35
|
-
import { isOrdinalScale } from '../helpers/scales.js';
|
|
36
35
|
|
|
37
36
|
const DEFAULTS = {
|
|
38
37
|
...getPlotDefaults().dot
|
|
@@ -61,11 +60,7 @@
|
|
|
61
60
|
recordizeXY({
|
|
62
61
|
data,
|
|
63
62
|
// sort by descending radius by default
|
|
64
|
-
...(options.r
|
|
65
|
-
!isOrdinalScale(plot.scales.x.type) &&
|
|
66
|
-
!isOrdinalScale(plot.scales.y.type)
|
|
67
|
-
? { sort: { channel: '-r' } }
|
|
68
|
-
: {}),
|
|
63
|
+
...(options.r ? { sort: { channel: '-r' } } : {}),
|
|
69
64
|
...options,
|
|
70
65
|
...(options.fill === true ? { fill: 'currentColor' } : {})
|
|
71
66
|
})
|
package/dist/types/plot.d.ts
CHANGED
|
@@ -112,10 +112,6 @@ export type PlotDefaults = {
|
|
|
112
112
|
* default dot radius for line markers, used in dot, circle, and circle-stroke markers
|
|
113
113
|
*/
|
|
114
114
|
markerDotRadius: number;
|
|
115
|
-
/**
|
|
116
|
-
* if set to true, ordinal domains will be sorted alphabetically
|
|
117
|
-
*/
|
|
118
|
-
sortOrdinalDomains: boolean;
|
|
119
115
|
/**
|
|
120
116
|
* default props for area marks, applied to area, areaX, and areaY marks
|
|
121
117
|
*/
|
|
@@ -471,9 +467,5 @@ export type PlotOptions = {
|
|
|
471
467
|
* pass a @emotion/css function to style plot using dynamic classes
|
|
472
468
|
*/
|
|
473
469
|
css: (d: string) => string | undefined;
|
|
474
|
-
/**
|
|
475
|
-
* if set to true, ordinal domains will be sorted alphabetically
|
|
476
|
-
*/
|
|
477
|
-
sortOrdinalDomains: boolean;
|
|
478
470
|
};
|
|
479
471
|
export {};
|