@mcp-b/viz-components 0.3.0 → 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";
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.3.0",
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.3.0"
30
+ "@mcp-b/wc-support": "0.3.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@custom-elements-manifest/analyzer": "^0.10.10",