svelteplot 0.4.3-pr-198.0 → 0.4.3-pr-199.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/Mark.svelte
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
import { getUsedScales, projectXY, projectX, projectY } from './helpers/scales.js';
|
|
41
41
|
import { testFilter, isValid } from './helpers/index.js';
|
|
42
42
|
import { resolveChannel, resolveProp } from './helpers/resolve.js';
|
|
43
|
+
import { RENAME } from './transforms/rename.js';
|
|
43
44
|
|
|
44
45
|
let {
|
|
45
46
|
data = [],
|
|
@@ -258,11 +259,13 @@
|
|
|
258
259
|
if (options?.[channel] != null && out[channel] === undefined) {
|
|
259
260
|
// resolve value
|
|
260
261
|
const value = row[channel];
|
|
262
|
+
// if this channel was renamed, use the original channel for scaling
|
|
263
|
+
const origChannel = options?.[RENAME]?.[channel] || channel;
|
|
261
264
|
const scaled = usedScales[channel]
|
|
262
265
|
? scale === 'x'
|
|
263
|
-
? projectX(
|
|
266
|
+
? projectX(origChannel as 'x' | 'x1' | 'x2', plot.scales, value)
|
|
264
267
|
: scale === 'y'
|
|
265
|
-
? projectY(
|
|
268
|
+
? projectY(origChannel as 'y' | 'y1' | 'y1', plot.scales, value)
|
|
266
269
|
: scale === 'color' && !isValid(value)
|
|
267
270
|
? plot.options.color.unknown
|
|
268
271
|
: plot.scales[scale].fn(value)
|
package/dist/helpers/scales.js
CHANGED
|
@@ -253,7 +253,7 @@ export function inferScaleType(name, dataValues, markTypes) {
|
|
|
253
253
|
if (dataValues.every(isDateOrNull))
|
|
254
254
|
return 'time';
|
|
255
255
|
if (dataValues.every(isStringOrNull))
|
|
256
|
-
return
|
|
256
|
+
return 'point';
|
|
257
257
|
return 'linear';
|
|
258
258
|
}
|
|
259
259
|
const scaledChannelNames = [
|
|
@@ -2,6 +2,7 @@ import type { DataRecord } from '../types/index.js';
|
|
|
2
2
|
import type { ScaledChannelName, TransformArg } from '../types/index.js';
|
|
3
3
|
type RenameChannelsOptions = Partial<Record<ScaledChannelName, ScaledChannelName>>;
|
|
4
4
|
type ReplaceChannelsOptions = Partial<Record<ScaledChannelName, ScaledChannelName[]>>;
|
|
5
|
+
export declare const RENAME = "__renamed__";
|
|
5
6
|
/**
|
|
6
7
|
* renames a channel without modifying the data
|
|
7
8
|
*/
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// using a symbol doesn't work because channels are spread into components
|
|
2
|
+
export const RENAME = '__renamed__';
|
|
1
3
|
/**
|
|
2
4
|
* renames a channel without modifying the data
|
|
3
5
|
*/
|
|
@@ -6,6 +8,9 @@ export function renameChannels({ data, ...channels }, options) {
|
|
|
6
8
|
for (const [from, to] of Object.entries(options)) {
|
|
7
9
|
if (newChannels[from] !== undefined) {
|
|
8
10
|
newChannels[to] = newChannels[from];
|
|
11
|
+
// keep track of the renaming
|
|
12
|
+
newChannels[RENAME] = newChannels[RENAME] || {};
|
|
13
|
+
newChannels[RENAME][to] = from;
|
|
9
14
|
delete newChannels[from];
|
|
10
15
|
}
|
|
11
16
|
}
|