@fusion.dev/helix-headless 0.181.2 → 0.182.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.
@@ -6947,7 +6947,7 @@
6947
6947
  "declarations": [
6948
6948
  {
6949
6949
  "kind": "class",
6950
- "description": "Every bar is measured from zero, and no property changes the baseline,\nbecause a bar's length is its value. To show the differences between values,\nuse a line chart.\n\nThe labels are HTML beside the drawing. An `<svg>` that fills its box scales\nthe text inside it: the same `font-size` renders at 10px in a narrow chart\nand 43px in a wide one, and SVG has no setting that keeps text at one size\nthe way `vector-effect` does for strokes.\n\nThe table is the accessible representation, and the drawing is hidden from\nscreen readers, so they get the numbers themselves. The `summary` part names\nthe chart, from `label` or the table's caption, and gives each series' highest\nreading.\n\n**The plot is read by key.** It takes focus, named by `label` or the caption.\nThe arrows along the categories move from one to the next, which is left and\nright for columns and up and down for `orientation=\"horizontal\"`. Home and\nEnd go to the first and the last, and the other pair of arrows moves among\nthe series of a category. The tooltip follows, the `live` part says the\nreading in words, and Escape puts the tooltip away.\n\nThe component writes the custom properties below with numbers it computes,\nand the stylesheet that draws the chart reads them. Do not set them yourself.\n\n**A tap shows the reading under it**, and keeps it until a tap lands\nelsewhere. `helix-reading-change` says each move of the reading, by pointer,\ntap or key, and `helix-reading-press` says a reading was clicked, tapped, or\npressed with Enter or Space, for a page that opens what a reading stands for.\n\n**`data` takes the readings as data** where the page has no table to point\n`for` at, in a table's shape: the column headings, then one row per reading\nwith its label first. A table is still the better source where the page can\nshow one, since it reads before any script runs.\n\n**A chart with nothing to draw says so.** A table with no readings shows\n`empty-text`, \"No readings\", in the plot, and `loading` shows `loading-text`\nthere until readings arrive. The `empty` and `loading` slots take markup in\ntheir place, such as a link to add the first reading.\n\n**Keyboard.** The plot is one tab stop.\n\n| Key | What it does |\n|---|---|\n| Tab | Moves focus to the plot and shows the first reading. |\n| Right, Left | Moves to the next or the previous reading. On a right-to-left page, Left moves to the next. |\n| Down, Up | Moves among the series of the reading. With one series, moves to the next or the previous reading. |\n| Down, Up under `orientation=\"horizontal\"` | Moves to the next or the previous reading, and Right and Left move among the series. |\n| Home, End | Moves to the first or the last reading. |\n| Page Down, Page Up | Moves a tenth of the readings on or back. |\n| Enter, Space | Presses the reading shown, which sends `helix-reading-press`. |\n| Escape | Puts the reading and its tooltip away. |",
6950
+ "description": "Every bar is measured from zero, and no property changes the baseline,\nbecause a bar's length is its value. To show the differences between values,\nuse a line chart.\n\nThe labels are HTML beside the drawing. An `<svg>` that fills its box scales\nthe text inside it: the same `font-size` renders at 10px in a narrow chart\nand 43px in a wide one, and SVG has no setting that keeps text at one size\nthe way `vector-effect` does for strokes.\n\nThe table is the accessible representation, and the drawing is hidden from\nscreen readers, so they get the numbers themselves. The `summary` part names\nthe chart, from `label` or the table's caption, and gives each series' highest\nreading.\n\n**The plot is read by key.** It takes focus, named by `label` or the caption.\nThe arrows along the categories move from one to the next, which is left and\nright for columns and up and down for `orientation=\"horizontal\"`. Home and\nEnd go to the first and the last, and the other pair of arrows moves among\nthe series of a category. The tooltip follows, the `live` part says the\nreading in words, and Escape puts the tooltip away.\n\nThe component writes the custom properties below with numbers it computes,\nand the stylesheet that draws the chart reads them. Do not set them yourself.\n\n**A tap shows the reading under it**, and keeps it until a tap lands\nelsewhere. `helix-reading-change` says each move of the reading, by pointer,\ntap or key, and `helix-reading-press` says a reading was clicked, tapped, or\npressed with Enter or Space, for a page that opens what a reading stands for.\n\n**A cell's `data-tone` colors its own bar**, such as `data-tone=\"primary\"`\non the one reading a chart is about, so one column of numbers can single\na bar out without a second column to color it. Without one, a bar takes\nits series' color.\n\n**`data` takes the readings as data** where the page has no table to point\n`for` at, in a table's shape: the column headings, then one row per reading\nwith its label first. A table is still the better source where the page can\nshow one, since it reads before any script runs.\n\n**A chart with nothing to draw says so.** A table with no readings shows\n`empty-text`, \"No readings\", in the plot, and `loading` shows `loading-text`\nthere until readings arrive. The `empty` and `loading` slots take markup in\ntheir place, such as a link to add the first reading.\n\n**Keyboard.** The plot is one tab stop.\n\n| Key | What it does |\n|---|---|\n| Tab | Moves focus to the plot and shows the first reading. |\n| Right, Left | Moves to the next or the previous reading. On a right-to-left page, Left moves to the next. |\n| Down, Up | Moves among the series of the reading. With one series, moves to the next or the previous reading. |\n| Down, Up under `orientation=\"horizontal\"` | Moves to the next or the previous reading, and Right and Left move among the series. |\n| Home, End | Moves to the first or the last reading. |\n| Page Down, Page Up | Moves a tenth of the readings on or back. |\n| Enter, Space | Presses the reading shown, which sends `helix-reading-press`. |\n| Escape | Puts the reading and its tooltip away. |",
6951
6951
  "name": "HelixHeadlessBarChart",
6952
6952
  "cssProperties": [
6953
6953
  {
@@ -6958,6 +6958,34 @@
6958
6958
  "description": "The color of the secondary axis, when one series is on it. The chart sets it from that series' `--chart-series-*` property, so the axis is drawn in whatever color that property resolves to.",
6959
6959
  "name": "--bar-chart-secondary"
6960
6960
  },
6961
+ {
6962
+ "description": "The color of a bar whose cell says `data-tone=\"accent\"`.",
6963
+ "name": "--bar-chart-tone-accent"
6964
+ },
6965
+ {
6966
+ "description": "The color of a bar whose cell says `data-tone=\"danger\"`.",
6967
+ "name": "--bar-chart-tone-danger"
6968
+ },
6969
+ {
6970
+ "description": "The color of a bar whose cell says `data-tone=\"info\"`.",
6971
+ "name": "--bar-chart-tone-info"
6972
+ },
6973
+ {
6974
+ "description": "The color of a bar whose cell says `data-tone=\"muted\"`.",
6975
+ "name": "--bar-chart-tone-muted"
6976
+ },
6977
+ {
6978
+ "description": "The color of a bar whose cell says `data-tone=\"primary\"`. A tone with no property of its own falls back to the bar's series color, and the same holds for a name you define.",
6979
+ "name": "--bar-chart-tone-primary"
6980
+ },
6981
+ {
6982
+ "description": "The color of a bar whose cell says `data-tone=\"success\"`.",
6983
+ "name": "--bar-chart-tone-success"
6984
+ },
6985
+ {
6986
+ "description": "The color of a bar whose cell says `data-tone=\"warning\"`.",
6987
+ "name": "--bar-chart-tone-warning"
6988
+ },
6961
6989
  {
6962
6990
  "description": "The gradient for a bar, named per bar so the styled tier can use it as the `fill`. It is always drawn, and used only when `wash=\"gradient\"` is set.",
6963
6991
  "name": "--chart-bar-wash"
@@ -6977,9 +7005,13 @@
6977
7005
  "name": "bar"
6978
7006
  },
6979
7007
  {
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`.",
7008
+ "description": "The bar at a column's far end, the end away from zero, which is the end to round. A column standing alone is its own far end. Under `stacked`, 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 is never the end. Set together with `bar`.",
6981
7009
  "name": "bar-end"
6982
7010
  },
7011
+ {
7012
+ "description": "A far end below zero, whose far end is its bottom, or its inline start when the bars run across. Set together with `bar-end`.",
7013
+ "name": "bar-end-negative"
7014
+ },
6983
7015
  {
6984
7016
  "description": "The far stop of a bar's gradient, where one is used.",
6985
7017
  "name": "bar-wash-end"
@@ -7368,7 +7400,7 @@
7368
7400
  {
7369
7401
  "name": "bar",
7370
7402
  "type": {
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"
7403
+ "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 named?: string,\n ) => TemplateResult"
7372
7404
  }
7373
7405
  }
7374
7406
  ],
@@ -200075,6 +200107,6 @@
200075
200107
  ],
200076
200108
  "helix": {
200077
200109
  "package": "@fusion.dev/helix-headless",
200078
- "version": "0.181.2"
200110
+ "version": "0.182.1"
200079
200111
  }
200080
200112
  }
@@ -35,6 +35,11 @@ declare const HelixHeadlessBarChart_base: typeof HelixElement & (new (...args: a
35
35
  * tap or key, and `helix-reading-press` says a reading was clicked, tapped, or
36
36
  * pressed with Enter or Space, for a page that opens what a reading stands for.
37
37
  *
38
+ * **A cell's `data-tone` colors its own bar**, such as `data-tone="primary"`
39
+ * on the one reading a chart is about, so one column of numbers can single
40
+ * a bar out without a second column to color it. Without one, a bar takes
41
+ * its series' color.
42
+ *
38
43
  * **`data` takes the readings as data** where the page has no table to point
39
44
  * `for` at, in a table's shape: the column headings, then one row per reading
40
45
  * with its label first. A table is still the better source where the page can
@@ -73,7 +78,8 @@ declare const HelixHeadlessBarChart_base: typeof HelixElement & (new (...args: a
73
78
  * @csspart axis - The numbers of one scale: the primary under `value-axis`, and both when `secondary` splits the chart into two scales.
74
79
  * @csspart band - The category band under the pointer.
75
80
  * @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`.
81
+ * @csspart bar-end - The bar at a column's far end, the end away from zero, which is the end to round. A column standing alone is its own far end. Under `stacked`, 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 is never the end. Set together with `bar`.
82
+ * @csspart bar-end-negative - A far end below zero, whose far end is its bottom, or its inline start when the bars run across. Set together with `bar-end`.
77
83
  * @csspart bar-wash-end - The far stop of a bar's gradient, where one is used.
78
84
  * @csspart bar-wash-start - The stop of a bar's gradient at its base.
79
85
  * @csspart baseline - The line the columns stand on.
@@ -111,6 +117,13 @@ declare const HelixHeadlessBarChart_base: typeof HelixElement & (new (...args: a
111
117
  *
112
118
  * @cssproperty --bar-chart-axis - The width of an axis, in `ch`, set from the widest number on it. The chart sets it on the axis itself, and only when the categories run along the bottom. In a horizontal chart the axis is a row, one line high.
113
119
  * @cssproperty --bar-chart-secondary - The color of the secondary axis, when one series is on it. The chart sets it from that series' `--chart-series-*` property, so the axis is drawn in whatever color that property resolves to.
120
+ * @cssproperty --bar-chart-tone-accent - The color of a bar whose cell says `data-tone="accent"`.
121
+ * @cssproperty --bar-chart-tone-danger - The color of a bar whose cell says `data-tone="danger"`.
122
+ * @cssproperty --bar-chart-tone-info - The color of a bar whose cell says `data-tone="info"`.
123
+ * @cssproperty --bar-chart-tone-muted - The color of a bar whose cell says `data-tone="muted"`.
124
+ * @cssproperty --bar-chart-tone-primary - The color of a bar whose cell says `data-tone="primary"`. A tone with no property of its own falls back to the bar's series color, and the same holds for a name you define.
125
+ * @cssproperty --bar-chart-tone-success - The color of a bar whose cell says `data-tone="success"`.
126
+ * @cssproperty --bar-chart-tone-warning - The color of a bar whose cell says `data-tone="warning"`.
114
127
  * @cssproperty --chart-bar-wash - The gradient for a bar, named per bar so the styled
115
128
  * tier can use it as the `fill`. It is always drawn, and used only when
116
129
  * `wash="gradient"` is set.
@@ -9,6 +9,7 @@ import { html, nothing, svg } from 'lit';
9
9
  import { property } from 'lit/decorators.js';
10
10
  import { stackEnds, stackedReadings, stackFarEnds, stackSpans } from '../stack.js';
11
11
  import '../../tooltip/index.js';
12
+ const toned = (tone) => tone && /^[a-z][a-z0-9-]*$/.test(tone) ? tone : undefined;
12
13
  let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus(MixinChartSource(HelixElement)) {
13
14
  constructor() {
14
15
  super(...arguments);
@@ -112,19 +113,25 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
112
113
  const stride = (slot * 0.72) / Math.max(abreast, 1);
113
114
  const gap = abreast > 1 ? stride * 0.08 : 0;
114
115
  const thickness = stride - gap;
115
- const bar = (value, index, depth, tone, scale, from, end) => {
116
+ const bar = (value, index, depth, tone, scale, from, end, named) => {
116
117
  const at = scale(value);
117
118
  const base = from === undefined ? floor : scale(from);
118
119
  const along = Math.min(base, at);
119
120
  const size = Math.abs(base - at);
120
121
  const across = index * slot + slot * 0.14 + depth * stride + gap / 2;
122
+ const ink = toned(named);
123
+ const paint = ink
124
+ ? `--chart-series: var(--bar-chart-tone-${ink}, var(--chart-series-${seriesIndex(tone)})); --chart-bar-wash: url(#helix-bar-wash-tone-${ink})`
125
+ : `--chart-series: var(--chart-series-${seriesIndex(tone)}); --chart-bar-wash: url(#helix-bar-wash-${seriesIndex(tone)})`;
126
+ const below = end === 'negative';
121
127
  return sideways
122
128
  ? svg `<rect
123
129
  data-end=${end ?? nothing}
124
130
  data-series=${seriesIndex(tone)}
131
+ data-tone=${ink ?? nothing}
125
132
  height=${thickness}
126
- style="--chart-series: var(--chart-series-${seriesIndex(tone)}); --chart-bar-wash: url(#helix-bar-wash-${seriesIndex(tone)})"
127
- part="bar${end ? ' bar-end' : ''}"
133
+ style=${paint}
134
+ part="bar${end ? ' bar-end' : ''}${below ? ' bar-end-negative' : ''}"
128
135
  width=${size}
129
136
  x=${along}
130
137
  y=${across}
@@ -132,9 +139,10 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
132
139
  : svg `<rect
133
140
  data-end=${end ?? nothing}
134
141
  data-series=${seriesIndex(tone)}
142
+ data-tone=${ink ?? nothing}
135
143
  height=${size}
136
- style="--chart-series: var(--chart-series-${seriesIndex(tone)}); --chart-bar-wash: url(#helix-bar-wash-${seriesIndex(tone)})"
137
- part="bar${end ? ' bar-end' : ''}"
144
+ style=${paint}
145
+ part="bar${end ? ' bar-end' : ''}${below ? ' bar-end-negative' : ''}"
138
146
  width=${thickness}
139
147
  x=${across}
140
148
  y=${along}
@@ -168,6 +176,19 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
168
176
  <stop offset="0" part="bar-wash-start" />
169
177
  <stop offset="1" part="bar-wash-end" />
170
178
  </linearGradient>`)}
179
+ ${[...new Set(series.flatMap((one) => one.points.map((point) => toned(point.tone))))]
180
+ .filter((ink) => ink !== undefined)
181
+ .map((ink) => svg `<linearGradient
182
+ id="helix-bar-wash-tone-${ink}"
183
+ style="--chart-series: var(--bar-chart-tone-${ink}, var(--chart-series-1))"
184
+ x1="0"
185
+ x2=${sideways ? '1' : '0'}
186
+ y1="0"
187
+ y2=${sideways ? '0' : '1'}
188
+ >
189
+ <stop offset="0" part="bar-wash-start" />
190
+ <stop offset="1" part="bar-wash-end" />
191
+ </linearGradient>`)}
171
192
  </defs>`}
172
193
  ${this.renderGridlines(y, domain, sideways, categories.length)}
173
194
  ${sideways
@@ -184,7 +205,7 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
184
205
  const point = slots[index];
185
206
  return point === undefined
186
207
  ? nothing
187
- : bar(point.value, index, depth, tone, against(one));
208
+ : bar(point.value, index, depth, tone, against(one), undefined, stackFarEnds([point.value])[0], point.tone);
188
209
  })}
189
210
  </g>`)}
190
211
  ${series.map((one) => lined.has(seriesKey(one.name)) && this.showsSeries(one.name)
@@ -201,9 +222,11 @@ let HelixHeadlessBarChart = class HelixHeadlessBarChart extends MixinChartStatus
201
222
  const values = mine.map(({ slots }) => slots[index]?.value);
202
223
  const spans = stackSpans(values);
203
224
  const ends = stackFarEnds(values);
204
- return mine.flatMap(({ tone }, place) => {
225
+ return mine.flatMap(({ slots, tone }, place) => {
205
226
  const span = spans[place];
206
- return span === undefined ? [] : [bar(span[1], index, 0, tone, scale, span[0], ends[place])];
227
+ return span === undefined
228
+ ? []
229
+ : [bar(span[1], index, 0, tone, scale, span[0], ends[place], slots[index]?.tone)];
207
230
  });
208
231
  });
209
232
  }