@fusion.dev/helix-headless 0.181.0 → 0.181.1
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/custom-elements.json +33 -3
- package/dist/bar-chart/root/bar-chart-root.d.ts +2 -1
- package/dist/bar-chart/root/bar-chart-root.js +10 -6
- package/dist/bar-chart/stack.d.ts +9 -0
- package/dist/bar-chart/stack.js +5 -0
- package/lint.json +1 -1
- package/package.json +5 -5
- package/types/jsx.d.ts +4 -2
package/custom-elements.json
CHANGED
|
@@ -6973,9 +6973,13 @@
|
|
|
6973
6973
|
"name": "band"
|
|
6974
6974
|
},
|
|
6975
6975
|
{
|
|
6976
|
-
"description": "One column.",
|
|
6976
|
+
"description": "One column. Under `stacked`, one segment of a category's column.",
|
|
6977
6977
|
"name": "bar"
|
|
6978
6978
|
},
|
|
6979
|
+
{
|
|
6980
|
+
"description": "Under `stacked`, the segment at a column's far end: the last positive segment above zero and the last negative one below it. Its `data-end` is `positive` or `negative`. A blank or a zero segment is never the end. Set together with `bar`.",
|
|
6981
|
+
"name": "bar-end"
|
|
6982
|
+
},
|
|
6979
6983
|
{
|
|
6980
6984
|
"description": "The far stop of a bar's gradient, where one is used.",
|
|
6981
6985
|
"name": "bar-wash-end"
|
|
@@ -7364,7 +7368,7 @@
|
|
|
7364
7368
|
{
|
|
7365
7369
|
"name": "bar",
|
|
7366
7370
|
"type": {
|
|
7367
|
-
"text": "(\n value: number,\n index: number,\n depth: number,\n tone: number,\n scale: (value: number) => number,\n from?: number,\n ) => TemplateResult"
|
|
7371
|
+
"text": "(\n value: number,\n index: number,\n depth: number,\n tone: number,\n scale: (value: number) => number,\n from?: number,\n end?: StackEnd,\n ) => TemplateResult"
|
|
7368
7372
|
}
|
|
7369
7373
|
}
|
|
7370
7374
|
],
|
|
@@ -8510,6 +8514,24 @@
|
|
|
8510
8514
|
],
|
|
8511
8515
|
"description": "Each column's span in one category, in the order given: a positive reading\nstacks up from zero on the positives before it, and a negative one down\nfrom zero on the negatives before it, so neither hides the other. A blank\nhas no span."
|
|
8512
8516
|
},
|
|
8517
|
+
{
|
|
8518
|
+
"kind": "function",
|
|
8519
|
+
"name": "stackFarEnds",
|
|
8520
|
+
"return": {
|
|
8521
|
+
"type": {
|
|
8522
|
+
"text": "(StackEnd | undefined)[]"
|
|
8523
|
+
}
|
|
8524
|
+
},
|
|
8525
|
+
"parameters": [
|
|
8526
|
+
{
|
|
8527
|
+
"name": "values",
|
|
8528
|
+
"type": {
|
|
8529
|
+
"text": "readonly (number | undefined)[]"
|
|
8530
|
+
}
|
|
8531
|
+
}
|
|
8532
|
+
],
|
|
8533
|
+
"description": "The segments at a stack's two far ends, in the order given: the last\npositive reading is the end of the stack above zero, and the last negative\nreading is the end of the stack below it. A blank or a zero has no length,\nso it is never an end. Every other segment is `undefined`."
|
|
8534
|
+
},
|
|
8513
8535
|
{
|
|
8514
8536
|
"kind": "function",
|
|
8515
8537
|
"name": "stackEnds",
|
|
@@ -8568,6 +8590,14 @@
|
|
|
8568
8590
|
"module": "src/bar-chart/stack.ts"
|
|
8569
8591
|
}
|
|
8570
8592
|
},
|
|
8593
|
+
{
|
|
8594
|
+
"kind": "js",
|
|
8595
|
+
"name": "stackFarEnds",
|
|
8596
|
+
"declaration": {
|
|
8597
|
+
"name": "stackFarEnds",
|
|
8598
|
+
"module": "src/bar-chart/stack.ts"
|
|
8599
|
+
}
|
|
8600
|
+
},
|
|
8571
8601
|
{
|
|
8572
8602
|
"kind": "js",
|
|
8573
8603
|
"name": "stackEnds",
|
|
@@ -200045,6 +200075,6 @@
|
|
|
200045
200075
|
],
|
|
200046
200076
|
"helix": {
|
|
200047
200077
|
"package": "@fusion.dev/helix-headless",
|
|
200048
|
-
"version": "0.181.
|
|
200078
|
+
"version": "0.181.1"
|
|
200049
200079
|
}
|
|
200050
200080
|
}
|
|
@@ -72,7 +72,8 @@ declare const HelixHeadlessBarChart_base: typeof HelixElement & (new (...args: a
|
|
|
72
72
|
*
|
|
73
73
|
* @csspart axis - The numbers of one scale: the primary under `value-axis`, and both when `secondary` splits the chart into two scales.
|
|
74
74
|
* @csspart band - The category band under the pointer.
|
|
75
|
-
* @csspart bar - One column.
|
|
75
|
+
* @csspart bar - One column. Under `stacked`, one segment of a category's column.
|
|
76
|
+
* @csspart bar-end - Under `stacked`, the segment at a column's far end: the last positive segment above zero and the last negative one below it. Its `data-end` is `positive` or `negative`. A blank or a zero segment is never the end. Set together with `bar`.
|
|
76
77
|
* @csspart bar-wash-end - The far stop of a bar's gradient, where one is used.
|
|
77
78
|
* @csspart bar-wash-start - The stop of a bar's gradient at its base.
|
|
78
79
|
* @csspart baseline - The line the columns stand on.
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { byRow, CHART_PLOT, customElement, drawTooltip, extent, formatNumbers, formatWords, HelixElement, HelixReadingChangeEvent, HelixReadingPressEvent, linear, linePath, MixinChartSource, MixinChartStatus, PLOT_HEIGHT, PLOT_WIDTH, seriesIndex, seriesKey, seriesNames, ticks, unbroken, words, wordsLocale, } from '@fusion.dev/helix-core';
|
|
8
8
|
import { html, nothing, svg } from 'lit';
|
|
9
9
|
import { property } from 'lit/decorators.js';
|
|
10
|
-
import { stackEnds, stackedReadings, stackSpans } from '../stack.js';
|
|
10
|
+
import { stackEnds, stackedReadings, stackFarEnds, stackSpans } from '../stack.js';
|
|
11
11
|
import '../../tooltip/index.js';
|
|
12
12
|
let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus(MixinChartSource(HelixElement)) {
|
|
13
13
|
constructor() {
|
|
@@ -112,7 +112,7 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
|
|
|
112
112
|
const stride = (slot * 0.72) / Math.max(abreast, 1);
|
|
113
113
|
const gap = abreast > 1 ? stride * 0.08 : 0;
|
|
114
114
|
const thickness = stride - gap;
|
|
115
|
-
const bar = (value, index, depth, tone, scale, from) => {
|
|
115
|
+
const bar = (value, index, depth, tone, scale, from, end) => {
|
|
116
116
|
const at = scale(value);
|
|
117
117
|
const base = from === undefined ? floor : scale(from);
|
|
118
118
|
const along = Math.min(base, at);
|
|
@@ -120,19 +120,21 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
|
|
|
120
120
|
const across = index * slot + slot * 0.14 + depth * stride + gap / 2;
|
|
121
121
|
return sideways
|
|
122
122
|
? svg `<rect
|
|
123
|
+
data-end=${end ?? nothing}
|
|
123
124
|
data-series=${seriesIndex(tone)}
|
|
124
125
|
height=${thickness}
|
|
125
126
|
style="--chart-series: var(--chart-series-${seriesIndex(tone)}); --chart-bar-wash: url(#helix-bar-wash-${seriesIndex(tone)})"
|
|
126
|
-
part="bar"
|
|
127
|
+
part="bar${end ? ' bar-end' : ''}"
|
|
127
128
|
width=${size}
|
|
128
129
|
x=${along}
|
|
129
130
|
y=${across}
|
|
130
131
|
/>`
|
|
131
132
|
: svg `<rect
|
|
133
|
+
data-end=${end ?? nothing}
|
|
132
134
|
data-series=${seriesIndex(tone)}
|
|
133
135
|
height=${size}
|
|
134
136
|
style="--chart-series: var(--chart-series-${seriesIndex(tone)}); --chart-bar-wash: url(#helix-bar-wash-${seriesIndex(tone)})"
|
|
135
|
-
part="bar"
|
|
137
|
+
part="bar${end ? ' bar-end' : ''}"
|
|
136
138
|
width=${thickness}
|
|
137
139
|
x=${across}
|
|
138
140
|
y=${along}
|
|
@@ -196,10 +198,12 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
|
|
|
196
198
|
const scales = [...new Set(columns.map(({ one }) => against(one)))];
|
|
197
199
|
return scales.flatMap((scale) => {
|
|
198
200
|
const mine = columns.filter(({ one }) => against(one) === scale);
|
|
199
|
-
const
|
|
201
|
+
const values = mine.map(({ slots }) => slots[index]?.value);
|
|
202
|
+
const spans = stackSpans(values);
|
|
203
|
+
const ends = stackFarEnds(values);
|
|
200
204
|
return mine.flatMap(({ tone }, place) => {
|
|
201
205
|
const span = spans[place];
|
|
202
|
-
return span === undefined ? [] : [bar(span[1], index, 0, tone, scale, span[0])];
|
|
206
|
+
return span === undefined ? [] : [bar(span[1], index, 0, tone, scale, span[0], ends[place])];
|
|
203
207
|
});
|
|
204
208
|
});
|
|
205
209
|
}
|
|
@@ -8,6 +8,15 @@ export type Span = readonly [from: number, to: number];
|
|
|
8
8
|
* has no span.
|
|
9
9
|
*/
|
|
10
10
|
export declare const stackSpans: (values: readonly (number | undefined)[]) => (Span | undefined)[];
|
|
11
|
+
/** Which way a stack's end segment grows from zero. */
|
|
12
|
+
export type StackEnd = 'positive' | 'negative';
|
|
13
|
+
/**
|
|
14
|
+
* The segments at a stack's two far ends, in the order given: the last
|
|
15
|
+
* positive reading is the end of the stack above zero, and the last negative
|
|
16
|
+
* reading is the end of the stack below it. A blank or a zero has no length,
|
|
17
|
+
* so it is never an end. Every other segment is `undefined`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const stackFarEnds: (values: readonly (number | undefined)[]) => (StackEnd | undefined)[];
|
|
11
20
|
/**
|
|
12
21
|
* Every end a stack reaches across the categories, which is what its scale
|
|
13
22
|
* has to hold: the top of each stack of positives and the foot of each stack
|
package/dist/bar-chart/stack.js
CHANGED
|
@@ -17,6 +17,11 @@ export const stackSpans = (values) => {
|
|
|
17
17
|
return [from, to];
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
+
export const stackFarEnds = (values) => {
|
|
21
|
+
const up = values.findLastIndex((value) => value !== undefined && value > 0);
|
|
22
|
+
const down = values.findLastIndex((value) => value !== undefined && value < 0);
|
|
23
|
+
return values.map((_, at) => (at === up ? 'positive' : at === down ? 'negative' : undefined));
|
|
24
|
+
};
|
|
20
25
|
export const stackEnds = (categories) => categories.flatMap((values) => stackSpans(values).flatMap((span) => (span === undefined ? [] : [span[1]])));
|
|
21
26
|
export const stackedReadings = (group, count, lined) => {
|
|
22
27
|
const slots = group.filter((one) => !lined(one)).map((one) => byRow(one, count));
|