@mcp-b/viz-components 0.2.22 → 0.3.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.
@@ -152,11 +152,13 @@ var SigveloChart = class extends SigveloElement {
152
152
  })).filter((entry) => entry.value !== void 0);
153
153
  if (numeric.length === 0) return nothing;
154
154
  const includeZero = this.type === "bar";
155
- const y = scaleLinear().domain(paddedExtent(numeric.map((entry) => entry.value), includeZero)).nice().range([innerHeight, 0]);
155
+ const values = numeric.map((entry) => entry.value);
156
+ const bins = this.type === "histogram" ? bin().thresholds(Math.min(12, Math.max(1, Math.ceil(Math.sqrt(values.length)))))(values) : void 0;
157
+ const y = scaleLinear().domain(bins ? [0, Math.max(1, ...bins.map((bucket) => bucket.length))] : paddedExtent(values, includeZero)).nice().range([innerHeight, 0]);
156
158
  const labels = numeric.map((entry) => labelAt(entry.row, this.xField, entry.index));
157
159
  const xBand = scaleBand().domain(numeric.map((_, index) => index)).range([0, innerWidth]).padding(.2);
158
160
  const baseline = includeZero ? y(0) : innerHeight;
159
- const yTicks = y.ticks(4);
161
+ const yTicks = y.ticks(4).filter((tick) => !bins || Number.isInteger(tick));
160
162
  const labelStride = Math.max(1, Math.ceil(labels.length / 8));
161
163
  const axes = svg`
162
164
  ${yTicks.map((tick) => {
@@ -210,18 +212,15 @@ var SigveloChart = class extends SigveloElement {
210
212
  >`)}
211
213
  </g>`;
212
214
  }
213
- if (this.type === "histogram") {
214
- const values = numeric.map((entry) => entry.value);
215
- const bins = bin().thresholds(Math.min(12, Math.max(1, Math.ceil(Math.sqrt(values.length)))))(values);
216
- const countScale = scaleLinear().domain([0, Math.max(1, ...bins.map((bucket) => bucket.length))]).range([innerHeight, 0]);
215
+ if (bins) {
217
216
  const bucketWidth = innerWidth / Math.max(1, bins.length);
218
217
  return svg`${axes}<g transform="translate(${PADDING.left}, ${PADDING.top})"
219
218
  >${bins.map((bucket, index) => svg`<rect
220
219
  class="mark"
221
220
  x=${index * bucketWidth + 1}
222
- y=${countScale(bucket.length)}
221
+ y=${y(bucket.length)}
223
222
  width=${Math.max(1, bucketWidth - 2)}
224
- height=${innerHeight - countScale(bucket.length)}
223
+ height=${innerHeight - y(bucket.length)}
225
224
  ><title>${bucket.x0 ?? 0}–${bucket.x1 ?? 0}: ${bucket.length}</title></rect
226
225
  >`)}</g
227
226
  >`;
@@ -1,2 +1,2 @@
1
- import { t as SigveloChart } from "../../chart-B-xXO_Qw.js";
1
+ import { t as SigveloChart } from "../../chart-BSbFRQju.js";
2
2
  export { SigveloChart };
@@ -1,4 +1,4 @@
1
- import "../../chart-B-xXO_Qw.js";
1
+ import "../../chart-BSbFRQju.js";
2
2
  import { t as __decorate } from "../../decorate-DcF3lt7P.js";
3
3
  import { html } from "lit";
4
4
  import { property } from "lit/decorators.js";
@@ -9,7 +9,14 @@ interface LegendItem {
9
9
  /** @tag sigvelo-viz-legend @summary Displays a compact color legend for charts and thematic maps. */
10
10
  declare class SigveloVizLegend extends SigveloElement {
11
11
  static styles: CSSResultGroup;
12
- title: string;
12
+ /**
13
+ * The visible text above the swatches, which also names the region.
14
+ *
15
+ * Not `title`: that is a global HTML attribute, so a Lit property of that name
16
+ * would make this heading and the browser's tooltip the same value, and each
17
+ * would overwrite the other.
18
+ */
19
+ heading: string;
13
20
  items: readonly LegendItem[];
14
21
  render(): import("lit-html").TemplateResult<1>;
15
22
  }
@@ -29,15 +29,15 @@ const styles = css`
29
29
  var SigveloVizLegend = class extends SigveloElement {
30
30
  constructor(..._args) {
31
31
  super(..._args);
32
- this.title = "Legend";
32
+ this.heading = "Legend";
33
33
  this.items = [];
34
34
  }
35
35
  static {
36
36
  this.styles = [hostStyles, styles];
37
37
  }
38
38
  render() {
39
- return html`<section aria-label=${this.title} part="legend">
40
- <strong part="title">${this.title}</strong>
39
+ return html`<section aria-labelledby="heading" part="legend">
40
+ <strong id="heading" part="heading">${this.heading}</strong>
41
41
  <div class="items">
42
42
  ${this.items.map((item) => html`<span class="item" part="item"
43
43
  ><span class="swatch" style=${`background:${item.color}`} part="swatch"></span
@@ -47,7 +47,7 @@ var SigveloVizLegend = class extends SigveloElement {
47
47
  </section>`;
48
48
  }
49
49
  };
50
- __decorate([property()], SigveloVizLegend.prototype, "title", void 0);
50
+ __decorate([property()], SigveloVizLegend.prototype, "heading", void 0);
51
51
  __decorate([property({ attribute: false })], SigveloVizLegend.prototype, "items", void 0);
52
52
  customElements.define("sigvelo-viz-legend", SigveloVizLegend);
53
53
  //#endregion
@@ -318,11 +318,12 @@
318
318
  },
319
319
  {
320
320
  "kind": "field",
321
- "name": "title",
321
+ "name": "heading",
322
322
  "type": {
323
323
  "text": "string"
324
324
  },
325
- "default": "\"Legend\""
325
+ "default": "\"Legend\"",
326
+ "description": "The visible text above the swatches, which also names the region.\n\nNot `title`: that is a global HTML attribute, so a Lit property of that name\nwould make this heading and the browser's tooltip the same value, and each\nwould overwrite the other."
326
327
  },
327
328
  {
328
329
  "kind": "field",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as SigveloChart } from "./chart-B-xXO_Qw.js";
1
+ import { t as SigveloChart } from "./chart-BSbFRQju.js";
2
2
  import { SigveloChartCard } from "./components/chart-card/chart-card.js";
3
3
  import { SigveloDistribution } from "./components/distribution/distribution.js";
4
4
  import { SigveloVizLegend } from "./components/legend/legend.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcp-b/viz-components",
3
- "version": "0.2.22",
3
+ "version": "0.3.1",
4
4
  "description": "D3-backed, framework-agnostic Sigvelo visualization web components.",
5
5
  "keywords": [
6
6
  "charts",
@@ -27,7 +27,7 @@
27
27
  "access": "public"
28
28
  },
29
29
  "dependencies": {
30
- "@mcp-b/wc-support": "0.2.19"
30
+ "@mcp-b/wc-support": "0.3.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@custom-elements-manifest/analyzer": "^0.10.10",