svelteplot 0.2.9-pr-104.0 → 0.2.9-pr-104.2
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/helpers/scales.js
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveProp, toChannelOption } from './resolve.js';
|
|
|
6
6
|
import isDataRecord from './isDataRecord.js';
|
|
7
7
|
import { createProjection } from './projection.js';
|
|
8
8
|
import { maybeInterval } from './autoTicks.js';
|
|
9
|
+
import { IS_SORTED } from '../transforms/sort.js';
|
|
9
10
|
/**
|
|
10
11
|
* compute the plot scales
|
|
11
12
|
*/
|
|
@@ -54,7 +55,9 @@ export function createScale(name, scaleOptions, marks, plotOptions, plotWidth, p
|
|
|
54
55
|
// we're deliberately checking for !== undefined and not for != null
|
|
55
56
|
// since the explicit sort transforms like shuffle will set the
|
|
56
57
|
// sort channel to null to we know that there's an explicit order
|
|
57
|
-
if (name === '
|
|
58
|
+
if (name === 'y')
|
|
59
|
+
console.log(mark.type, mark.options[IS_SORTED]);
|
|
60
|
+
if (mark.options[IS_SORTED] != null) {
|
|
58
61
|
sortOrdinalDomain = false;
|
|
59
62
|
}
|
|
60
63
|
for (const channel of mark.channels) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DataRecord, DataRow, TransformArg } from '../types.js';
|
|
2
2
|
export declare const SORT_KEY: unique symbol;
|
|
3
|
+
export declare const IS_SORTED: unique symbol;
|
|
3
4
|
export declare function sort({ data, ...channels }: TransformArg<DataRecord>, options?: {
|
|
4
5
|
reverse?: boolean;
|
|
5
6
|
}): any;
|
package/dist/transforms/sort.js
CHANGED
|
@@ -3,6 +3,7 @@ import { resolveChannel } from '../helpers/resolve.js';
|
|
|
3
3
|
import { shuffler } from 'd3-array';
|
|
4
4
|
import { randomLcg } from 'd3-random';
|
|
5
5
|
export const SORT_KEY = Symbol('sortKey');
|
|
6
|
+
export const IS_SORTED = Symbol('isSorted');
|
|
6
7
|
export function sort({ data, ...channels }, options = {}) {
|
|
7
8
|
if (!Array.isArray(data))
|
|
8
9
|
return { data, ...channels };
|
|
@@ -27,6 +28,7 @@ export function sort({ data, ...channels }, options = {}) {
|
|
|
27
28
|
: 1))
|
|
28
29
|
.map(({ [SORT_KEY]: a, ...rest }) => rest),
|
|
29
30
|
...channels,
|
|
31
|
+
[IS_SORTED]: sort,
|
|
30
32
|
// set the sort channel to null to disable the implicit alphabetical
|
|
31
33
|
// ordering of ordinal domains, and also to avoid double sorting in case
|
|
32
34
|
// this transform is used "outside" a mark
|
package/dist/types.d.ts
CHANGED
|
@@ -345,7 +345,7 @@ export type PlotDefaults = {
|
|
|
345
345
|
unknown: string;
|
|
346
346
|
css: (d: string) => string | undefined;
|
|
347
347
|
};
|
|
348
|
-
export type GenericMarkOptions = Record<string, any>;
|
|
348
|
+
export type GenericMarkOptions = Record<string | symbol, any>;
|
|
349
349
|
export type DataRecord = Record<string | symbol, RawValue> & {
|
|
350
350
|
___orig___?: RawValue | [RawValue, RawValue];
|
|
351
351
|
};
|
|
@@ -512,6 +512,12 @@ export type BaseMarkProps = Partial<{
|
|
|
512
512
|
dy: ConstantAccessor<number>;
|
|
513
513
|
fill: ConstantAccessor<string>;
|
|
514
514
|
fillOpacity: ConstantAccessor<number>;
|
|
515
|
+
sort: string | ConstantAccessor<RawValue> | {
|
|
516
|
+
/** sort data using an already defined channel */
|
|
517
|
+
channel: string;
|
|
518
|
+
/** sort order */
|
|
519
|
+
order?: 'ascending' | 'descending';
|
|
520
|
+
};
|
|
515
521
|
stroke: ConstantAccessor<string>;
|
|
516
522
|
strokeWidth: ConstantAccessor<number>;
|
|
517
523
|
strokeOpacity: ConstantAccessor<number>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelteplot",
|
|
3
|
-
"version": "0.2.9-pr-104.
|
|
3
|
+
"version": "0.2.9-pr-104.2",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Gregor Aisch",
|
|
@@ -72,13 +72,13 @@
|
|
|
72
72
|
"@types/d3-scale": "^4.0.9",
|
|
73
73
|
"@types/d3-scale-chromatic": "^3.1.0",
|
|
74
74
|
"@types/d3-shape": "^3.1.7",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
76
|
-
"@typescript-eslint/parser": "^8.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "^8.33.0",
|
|
76
|
+
"@typescript-eslint/parser": "^8.33.0",
|
|
77
77
|
"csstype": "^3.1.3",
|
|
78
78
|
"d3-dsv": "^3.0.1",
|
|
79
79
|
"d3-fetch": "^3.0.1",
|
|
80
80
|
"d3-force": "^3.0.0",
|
|
81
|
-
"eslint": "^9.
|
|
81
|
+
"eslint": "^9.28.0",
|
|
82
82
|
"eslint-config-prettier": "^10.1.5",
|
|
83
83
|
"eslint-plugin-svelte": "3.9.0",
|
|
84
84
|
"jsdom": "^26.1.0",
|
|
@@ -122,6 +122,6 @@
|
|
|
122
122
|
"es-toolkit": "^1.38.0",
|
|
123
123
|
"fast-equals": "^5.2.2",
|
|
124
124
|
"merge-deep": "^3.0.3",
|
|
125
|
-
"svelte": "5.33.
|
|
125
|
+
"svelte": "5.33.10"
|
|
126
126
|
}
|
|
127
127
|
}
|