@humanforest/charts 0.3.5 → 0.3.6
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/package.json +2 -2
- package/src/forestTooltip.ts +1 -1
- package/src/fromCategories.ts +2 -2
- package/src/resolveVar.ts +1 -1
- package/src/useCellScale.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@humanforest/charts",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"src"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"vue": "^3.5.22"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@humanforest/tokens": "^0.3.
|
|
27
|
+
"@humanforest/tokens": "^0.3.6"
|
|
28
28
|
},
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
package/src/forestTooltip.ts
CHANGED
|
@@ -97,7 +97,7 @@ export function forestTooltip<Datum extends Record<string, unknown>>(
|
|
|
97
97
|
const present = keys.filter((k) => k in d);
|
|
98
98
|
const title = opts.titleFormatter ? opts.titleFormatter(d) : Object.values(d)[0];
|
|
99
99
|
const rows: ForestTipRow[] = present.map((k, i) => {
|
|
100
|
-
const item = categories[k]
|
|
100
|
+
const item = categories[k]!;
|
|
101
101
|
const raw = d[k];
|
|
102
102
|
return {
|
|
103
103
|
swatch: typeof item.color === 'string' ? item.color : `var(--vis-color${i})`,
|
package/src/fromCategories.ts
CHANGED
|
@@ -35,8 +35,8 @@ export function fromCategories<Datum extends Record<string, unknown>>(
|
|
|
35
35
|
: Array.isArray(item.color) && typeof item.color[0] === 'string' ? item.color[0]
|
|
36
36
|
: `var(--vis-color${i})`;
|
|
37
37
|
return {
|
|
38
|
-
colors: keys.map((k, i) => colorOf(categories[k]
|
|
39
|
-
legendItems: keys.map((k, i) => ({ ...categories[k]
|
|
38
|
+
colors: keys.map((k, i) => colorOf(categories[k]!, i)),
|
|
39
|
+
legendItems: keys.map((k, i) => ({ ...categories[k]!, color: colorOf(categories[k]!, i) })),
|
|
40
40
|
yAccessors: keys.map((k) => (d: Datum) => d[k] as number | null | undefined),
|
|
41
41
|
xAccessor: xKey ? (d) => d[xKey] as number : (_d, i) => i,
|
|
42
42
|
};
|
package/src/resolveVar.ts
CHANGED
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
/** The computed value of a `var(--x)` string. Non-var strings pass through untouched. */
|
|
17
17
|
export function resolveVar(value: string, context: Element = document.documentElement): string {
|
|
18
18
|
if (typeof window === 'undefined' || !value.startsWith('var(--')) return value;
|
|
19
|
-
const name = value.slice(4, -1).split(',')[0]
|
|
19
|
+
const name = value.slice(4, -1).split(',')[0]!.trim();
|
|
20
20
|
return getComputedStyle(context).getPropertyValue(name).trim() || value;
|
|
21
21
|
}
|
package/src/useCellScale.ts
CHANGED
|
@@ -118,9 +118,9 @@ export function useCellScale<D>(options: CellScaleOptions<D>) {
|
|
|
118
118
|
const stops = swatches.value;
|
|
119
119
|
// A flat domain has no gradient to express — everything sits at the top stop rather than
|
|
120
120
|
// dividing by zero.
|
|
121
|
-
if (hi <= lo) return stops[stops.length - 1]
|
|
121
|
+
if (hi <= lo) return stops[stops.length - 1]!;
|
|
122
122
|
const t = Math.min(1, Math.max(0, (v - lo) / (hi - lo)));
|
|
123
|
-
return stops[Math.min(stops.length - 1, Math.floor(t * stops.length))]
|
|
123
|
+
return stops[Math.min(stops.length - 1, Math.floor(t * stops.length))]!;
|
|
124
124
|
}
|
|
125
125
|
const states = unref(options.states) ?? {};
|
|
126
126
|
const key = options.state!(d as D) as string;
|