@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.
- package/dist/{chart-B-xXO_Qw.js → chart-BSbFRQju.js} +7 -8
- package/dist/components/chart/chart.js +1 -1
- package/dist/components/distribution/distribution.js +1 -1
- package/dist/components/legend/legend.d.ts +8 -1
- package/dist/components/legend/legend.js +4 -4
- package/dist/docs/custom-elements.json +3 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -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
|
|
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 (
|
|
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=${
|
|
221
|
+
y=${y(bucket.length)}
|
|
223
222
|
width=${Math.max(1, bucketWidth - 2)}
|
|
224
|
-
height=${innerHeight -
|
|
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-
|
|
1
|
+
import { t as SigveloChart } from "../../chart-BSbFRQju.js";
|
|
2
2
|
export { SigveloChart };
|
|
@@ -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
|
-
|
|
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.
|
|
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-
|
|
40
|
-
<strong part="
|
|
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, "
|
|
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": "
|
|
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-
|
|
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
|
+
"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.
|
|
30
|
+
"@mcp-b/wc-support": "0.3.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@custom-elements-manifest/analyzer": "^0.10.10",
|