blockcharts 0.0.1 → 0.0.3

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.
Files changed (87) hide show
  1. package/README.md +274 -171
  2. package/package.json +43 -6
  3. package/release/bc.d.ts +35 -2
  4. package/release/blocks/guide.axis.js +2 -2
  5. package/release/blocks/guide.grid.js +2 -2
  6. package/release/blocks/guide.kpi.js +2 -2
  7. package/release/blocks/guide.legend.js +2 -2
  8. package/release/blocks/interaction.animate.js +2 -2
  9. package/release/blocks/interaction.brush.js +2 -2
  10. package/release/blocks/interaction.click.js +3 -0
  11. package/release/blocks/interaction.crosshair.js +2 -2
  12. package/release/blocks/interaction.legend-filter.js +2 -2
  13. package/release/blocks/interaction.tooltip.js +2 -2
  14. package/release/blocks/interaction.zoom-controls.js +2 -2
  15. package/release/blocks/interaction.zoom.js +2 -2
  16. package/release/blocks/lib.columns.js +2 -2
  17. package/release/blocks/lib.curve.js +2 -2
  18. package/release/blocks/lib.pointer.js +2 -2
  19. package/release/blocks/lib.stats.js +2 -2
  20. package/release/blocks/lib.ticks.js +2 -2
  21. package/release/blocks/lib.view.js +2 -2
  22. package/release/blocks/mark.arc.js +2 -2
  23. package/release/blocks/mark.area.js +2 -2
  24. package/release/blocks/mark.boxplot.js +2 -2
  25. package/release/blocks/mark.candlestick.js +2 -2
  26. package/release/blocks/mark.line.js +2 -2
  27. package/release/blocks/mark.point.js +2 -2
  28. package/release/blocks/mark.polygon.js +2 -2
  29. package/release/blocks/mark.rect.js +2 -2
  30. package/release/blocks/mark.rule.js +2 -2
  31. package/release/blocks/mark.sankey.js +2 -2
  32. package/release/blocks/mark.text.js +2 -2
  33. package/release/blocks/mark.violin.js +2 -2
  34. package/release/blocks/renderer.canvas.js +2 -2
  35. package/release/blocks/renderer.svg.js +2 -2
  36. package/release/blocks/scale.band.js +2 -2
  37. package/release/blocks/scale.color.js +2 -2
  38. package/release/blocks/scale.linear.js +2 -2
  39. package/release/blocks/scale.log.js +2 -2
  40. package/release/blocks/scale.sequential.js +2 -2
  41. package/release/blocks/scale.size.js +2 -2
  42. package/release/blocks/scale.time.js +2 -2
  43. package/release/blocks/transform.aggregate.js +2 -2
  44. package/release/blocks/transform.bin.js +2 -2
  45. package/release/blocks/transform.calculate.js +2 -2
  46. package/release/blocks/transform.calendar.js +2 -2
  47. package/release/blocks/transform.contour.js +2 -2
  48. package/release/blocks/transform.decimate.js +2 -2
  49. package/release/blocks/transform.density.js +2 -2
  50. package/release/blocks/transform.filter.js +2 -2
  51. package/release/blocks/transform.fold.js +2 -2
  52. package/release/blocks/transform.funnel.js +2 -2
  53. package/release/blocks/transform.hexbin.js +2 -2
  54. package/release/blocks/transform.highlight.js +2 -2
  55. package/release/blocks/transform.marimekko.js +2 -2
  56. package/release/blocks/transform.quartiles.js +2 -2
  57. package/release/blocks/transform.sankey.js +2 -2
  58. package/release/blocks/transform.sort.js +2 -2
  59. package/release/blocks/transform.stack.js +2 -2
  60. package/release/blocks/transform.treemap.js +2 -2
  61. package/release/blocks/transform.waterfall.js +2 -2
  62. package/release/blocks/transform.window.js +2 -2
  63. package/release/core.js +3 -3
  64. package/release/frameworks/controller.d.mts +51 -0
  65. package/release/frameworks/controller.mjs +181 -0
  66. package/release/frameworks/element.d.mts +32 -0
  67. package/release/frameworks/element.mjs +95 -0
  68. package/release/frameworks/react.d.mts +10 -0
  69. package/release/frameworks/react.mjs +30 -0
  70. package/release/frameworks/svelte.d.mts +9 -0
  71. package/release/frameworks/svelte.mjs +17 -0
  72. package/release/frameworks/vue.d.mts +40 -0
  73. package/release/frameworks/vue.mjs +44 -0
  74. package/release/kits/basic.js +25 -22
  75. package/release/kits/basic.mjs +25 -22
  76. package/release/kits/composition.js +39 -36
  77. package/release/kits/composition.mjs +39 -36
  78. package/release/kits/dashboard.js +37 -34
  79. package/release/kits/dashboard.mjs +37 -34
  80. package/release/kits/full.js +64 -61
  81. package/release/kits/full.mjs +64 -61
  82. package/release/kits/timeseries.js +35 -32
  83. package/release/kits/timeseries.mjs +35 -32
  84. package/release/loader.js +2 -2
  85. package/release/manifest.json +326 -221
  86. package/release/schema/chart.schema.json +4155 -0
  87. package/release/schema/page.schema.json +4547 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blockcharts",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Interactive SVG and canvas charts described as JSON, assembled from independent blocks. For standalone HTML reports and for pages of your own.",
5
5
  "keywords": [
6
6
  "charts",
@@ -47,6 +47,23 @@
47
47
  "./loader.js": "./release/loader.js",
48
48
  "./manifest.json": "./release/manifest.json",
49
49
  "./bc.d.ts": "./release/bc.d.ts",
50
+ "./schema/*": "./release/schema/*",
51
+ "./react": {
52
+ "types": "./release/frameworks/react.d.mts",
53
+ "default": "./release/frameworks/react.mjs"
54
+ },
55
+ "./vue": {
56
+ "types": "./release/frameworks/vue.d.mts",
57
+ "default": "./release/frameworks/vue.mjs"
58
+ },
59
+ "./svelte": {
60
+ "types": "./release/frameworks/svelte.d.mts",
61
+ "default": "./release/frameworks/svelte.mjs"
62
+ },
63
+ "./element": {
64
+ "types": "./release/frameworks/element.d.mts",
65
+ "default": "./release/frameworks/element.mjs"
66
+ },
50
67
  "./package.json": "./package.json"
51
68
  },
52
69
  "files": [
@@ -58,29 +75,49 @@
58
75
  "engines": {
59
76
  "node": ">=22"
60
77
  },
78
+ "peerDependencies": {
79
+ "react": ">=18",
80
+ "vue": ">=3.3"
81
+ },
82
+ "peerDependenciesMeta": {
83
+ "react": {
84
+ "optional": true
85
+ },
86
+ "vue": {
87
+ "optional": true
88
+ }
89
+ },
61
90
  "workspaces": [
62
91
  "site"
63
92
  ],
64
93
  "scripts": {
65
- "build": "tsc",
94
+ "build": "tsc && tsc -p tsconfig.frameworks.json",
66
95
  "manifest": "node scripts/build-manifest.js && node scripts/minify.js",
67
- "test": "npm run build && npm run manifest && node scripts/test.js && node scripts/test-canvas.js && node scripts/test-compose.js && node scripts/test-csv.js && node scripts/test-skill.js && node scripts/test-dist.js",
96
+ "test": "npm run build && npm run manifest && node scripts/test.js && node scripts/test-canvas.js && node scripts/test-compose.js && node scripts/test-csv.js && node scripts/test-skill.js && node scripts/test-dist.js && node scripts/test-schema.js",
68
97
  "test:chrome": "npm run build && npm run manifest && node scripts/test-chrome.js",
98
+ "test:frameworks": "npm run build && npm run manifest && node scripts/test-frameworks.js",
69
99
  "skill": "npm run build && npm run manifest && node scripts/build-skill.js && node scripts/build-docs.js",
70
100
  "release": "npm run build && npm run manifest && node scripts/build-dist.js",
71
101
  "og": "node scripts/og-image.js",
72
102
  "test:site": "node scripts/check-site-phone.js",
73
103
  "site": "npm run build && npm run manifest && npm run build -w site && node scripts/check-site.js",
74
104
  "prepack": "npm run release",
75
- "format": "prettier --write \"src/**/*.ts\" \"scripts/**/*.js\" \"site/src/**/*.{mjs,css}\" site/astro.config.mjs",
76
- "format:check": "prettier --check \"src/**/*.ts\" \"scripts/**/*.js\" \"site/src/**/*.{mjs,css}\" site/astro.config.mjs"
105
+ "format": "prettier --write \"src/**/*.{ts,mts}\" \"scripts/**/*.js\" \"site/src/**/*.{mjs,css}\" site/astro.config.mjs",
106
+ "format:check": "prettier --check \"src/**/*.{ts,mts}\" \"scripts/**/*.js\" \"site/src/**/*.{mjs,css}\" site/astro.config.mjs"
77
107
  },
78
108
  "devDependencies": {
109
+ "@types/react": "^19.3.1",
110
+ "@types/react-dom": "^19.3.0",
111
+ "ajv": "^8.20.0",
79
112
  "esbuild": "^0.28.2",
80
113
  "fflate": "^0.8.3",
81
114
  "playwright-core": "^1.64.1",
82
115
  "prettier": "^3.9.10",
83
- "typescript": "^7.0.2"
116
+ "react": "^19.3.1",
117
+ "react-dom": "^19.3.1",
118
+ "svelte": "^5.59.1",
119
+ "typescript": "^7.0.2",
120
+ "vue": "^3.5.46"
84
121
  },
85
122
  "allowScripts": {
86
123
  "esbuild": true,
package/release/bc.d.ts CHANGED
@@ -61,6 +61,8 @@ declare namespace BC {
61
61
  }
62
62
 
63
63
  interface ChartSpec {
64
+ /** The JSON Schema the spec follows (release/schema/chart.schema.json), for an editor; the chart ignores it. */
65
+ $schema?: string;
64
66
  id?: string;
65
67
  /** Key in the data lake. */
66
68
  data: string;
@@ -141,6 +143,25 @@ declare namespace BC {
141
143
  table: Table;
142
144
  }
143
145
 
146
+ /** What interaction.click sends with its `bc-click` event (`event.detail`), from the chart's element, for a click or a tap
147
+ * on the data: the datum the tooltip shows there. */
148
+ interface ClickDetail {
149
+ /** Row of the table (after the transforms) that was clicked. */
150
+ row: number;
151
+ /** Every row the shape stands for (see Pick.rows); just `row` for most shapes. */
152
+ rows: number[];
153
+ /** Every column of that row, not only the ones the mark reads. */
154
+ values: Record<string, unknown>;
155
+ mark: MarkSpec;
156
+ markIndex: number;
157
+ /** Anchor of the datum, in display-list px. */
158
+ x: number;
159
+ y: number;
160
+ table: Table;
161
+ /** The browser's click: modifier keys, the button, where on the page. */
162
+ event: MouseEvent;
163
+ }
164
+
144
165
  /** What a tooltip `content` function may return. A string is inserted as text. `{ html }` is inserted as markup
145
166
  * (the caller is responsible for escaping data in it). A Node is inserted as is. An array inserts each item.
146
167
  * null / false hides the tooltip; undefined keeps the default content. */
@@ -613,6 +634,9 @@ declare namespace BC {
613
634
 
614
635
  interface InteractionDef extends BlockBase {
615
636
  role: 'interaction';
637
+ /** DOM events it sends from the chart's element (`host`, they bubble) for a script of the page: "bc-click". Listed in the
638
+ * manifest; a page the composer makes from JSON alone has no script to listen, and gets a warning. */
639
+ events?: readonly string[];
616
640
  /** For an overlay that sits in a corner of the chart: which one, and how far along its edge from the end of the chart.
617
641
  * Read at layout, so what is drawn along that edge can keep clear of it. */
618
642
  corner?(spec: InteractionSpec, ctx: ChartCtx): { edge: 'top' | 'bottom'; side: 'left' | 'right'; width: number } | null;
@@ -706,8 +730,9 @@ declare namespace BC {
706
730
 
707
731
  /** Add/replace a dataset in the data lake (the page's #bc-data is loaded on mount). Rows and columns are
708
732
  * available at once; an EncodedDataset is decoded in the background (a failure is reported by the charts
709
- * that use it, and by console.error). A malformed plain dataset throws. */
710
- data(name: string, input: DatasetInput): void;
733
+ * that use it, and by console.error). A malformed plain dataset throws. `null` removes the dataset (a decode still
734
+ * running for it is dropped); a chart already drawn from it keeps its drawing until it is built again. */
735
+ data(name: string, input: DatasetInput | null): void;
711
736
  /** Resolves when every dataset that was being decoded has settled. Never rejects. */
712
737
  ready(): Promise<void>;
713
738
  /** Register a function that specs can refer to by name (e.g. tooltip `content: "myTip"`), because JSON
@@ -752,6 +777,8 @@ declare namespace BC {
752
777
  closure: BlockName[];
753
778
  params?: Record<string, ParamDef>;
754
779
  channels?: Record<string, ChannelDef>;
780
+ /** InteractionDef.events */
781
+ events?: string[];
755
782
  doc?: string;
756
783
  }
757
784
 
@@ -762,3 +789,9 @@ declare namespace BC {
762
789
  }
763
790
 
764
791
  declare const BC: BC.Runtime;
792
+
793
+ /** The events a chart sends from its element, typed for addEventListener. */
794
+ interface HTMLElementEventMap {
795
+ /** interaction.click: a click on the data of a chart. It bubbles, so one listener on the page hears every chart. */
796
+ 'bc-click': CustomEvent<BC.ClickDetail>;
797
+ }
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const nt="var(--bc-axis, #888)",$="var(--bc-text, #444)",S="var(--bc-label, var(--bc-text, #444))",A=t=>t.ticks===!0?9:8,j=(t,e)=>t.line==="on"?!0:t.line==="off"?!1:e==="top"||e==="bottom";function I(t,e){return t.position?t.position:t.scale&&e.orientation(t.scale)==="vertical"?"left":"bottom"}const F=new WeakMap,E=.71,ot=14,W=19,K=20,L=6,st=.85,it=/^\s*-?\d[\d.,:\/-]*(T[\d:.]+Z?)?\s*$/;function z(t,e){let i=0,o=0;for(const n of e.spec.guides||[])if(n!==t)if(n.type==="axis"){const s=n.scale?I(n,e):"top",a=(s==="left"||s==="right")&&et.measure(n,e)[s]||0;s==="left"?i+=a:s==="right"&&(o+=a)}else{const s=BC.get(`guide.${n.type}`),a=s&&s.measure?s.measure(n,e):{};i+=a.left||0,o+=a.right||0}return{x:e.plot.x+i,w:e.plot.w-i-o}}function lt(t,e,i){const o=t.scale?e.scales[t.scale]:void 0;if(!o||o.input!=="category"||i==="left"||i==="right"||e.orientation(t.scale)!=="horizontal")return 0;const n=o.domain(),s=z(t,e).w;return n.length<2||s/n.length<ot||n.every(a=>typeof a=="number"||a instanceof Date||it.test(String(a)))||q(t,e,s)>=n.length?0:s/n.length<W?90:45}const rt=/[、。,.・:;?!)」』】〕》〉ーゝゞ々ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ]/,at=/[(「『【〔《〈]/,V=/\d/;function G(t,e){const i=[];for(let o=1;o<t.length;o++){const n=t[o-1],s=t[o];!e.wide(n)||rt.test(s)||at.test(n)||V.test(s)&&!(o>=2&&V.test(t[o-2]))||i.push(o)}return i}function H(t,e,i){const o=Array.from(t),n=(r,u)=>i.measure(o.slice(r,u).join(""),11).w;let s=-1,a=1/0;for(const r of G(o,i)){const u=n(0,r);if(u>e)break;const m=Math.max(u,n(r,o.length));m<a&&(a=m,s=r)}if(s<0){const r=G(o,i);if(!r.length)return[t];s=r[0]}return[o.slice(0,s).join(""),o.slice(s).join("")]}function q(t,e,i){const o=t.scale,n=e.orientation(o)==="horizontal";let s=0;for(const a of e.scales[o].domain()){const r=String(a);if(!n){s=Math.max(s,e.measure(r,11).h);continue}const u=e.measure(r,11).w,m=r.split(/\s+/).filter(Boolean),l=m.length===1&&e.wide(r)?Math.max(...H(r,1/0,e).map(f=>e.measure(f,11).w)):m.reduce((f,h)=>Math.max(f,e.measure(h,11).w),0);s=Math.max(s,Math.min(u,Math.max(l,u/2)))}return Math.floor(i/(n?s*.9+4:s+3))}const C=t=>t.length>K?t.slice(0,K-1)+"\u2026":t;function P(t,e){return ft(ct(t,e),t,e)}function ft(t,e,i){if(i.scales[e.scale].input==="category"||i.orientation(e.scale)!=="horizontal")return t;const o=X(e),n=t.filter((u,m)=>m===0||u.label!==t[m-1].label);if(n.length<2)return n;let s=1/0;for(let u=1;u<n.length;u++)s=Math.min(s,Math.abs(n[u].pos-n[u-1].pos));const a=n.reduce((u,m)=>Math.max(u,i.measure(m.label,11).w),0),r=s>0?Math.ceil((a+L)/s):1;return r>1?n.filter((u,m)=>o(m,n.length,r)):n}const X=t=>(e,i,o)=>(t.anchor==="end"?i-1-e:e)%o===0;function ut(t,e){if(t.format===void 0||e.orientation(t.scale)!=="horizontal")return 0;const i=BC.formatter(t.format),o=e.scales[t.scale].domain(),n=o.reduce((s,a)=>Math.max(s,e.measure(i(a),11).w),0);return Math.min(o.length,Math.floor(e.plot.w/(n+L)))}function ht(t,e){const i=t.scale,o=e.scales[i],n=typeof t.count=="number"&&t.count>=1?Math.round(t.count):void 0;if(o.input!=="category")return n===void 0?e.ticks(i):e.ticks(i,n);const s=Math.max(e.ticks(i).length,ut(t,e)),a=n===void 0?s:Math.min(n,s);if(t.anchor!=="end")return e.ticks(i,a);const r=e.ticks(i,o.domain().length),u=Math.max(1,Math.ceil(r.length/Math.max(1,a))),m=X(t);return r.filter((l,f)=>m(f,r.length,u))}function ct(t,e){const i=e.scales[t.scale],o=F.has(t)?e.ticks(t.scale,i.domain().length):ht(t,e);if(t.format===void 0||i.output!=="position")return o;const{input:n}=i,s=BC.formatter(t.format,n==="date"?"date":n==="category"?void 0:"number");return o.map(a=>({value:a.value,pos:a.pos,label:s(a.value)}))}const Q=(t,e)=>F.has(t)?P(t,e).map(i=>({...i,label:C(i.label)})):P(t,e),_=t=>typeof t.title=="string"?t.title:"",N=11*1.25,mt=.3;function U(t,e,i){if(i.measure(t,11).w<=e)return t;const o=Array.from(t);let n=0,s=o.length;for(;n<s;){const a=n+s+1>>1;i.measure(o.slice(0,a).join("")+"\u2026",11).w<=e?n=a:s=a-1}return o.slice(0,n).join("").trimEnd()+"\u2026"}function dt(t,e,i){const o=t.split(/\s+/).filter(Boolean);if(o.length<2){if(!i.wide(t))return null;const a=Array.from(t);let r=0;for(;r<a.length-1&&i.measure(a.slice(0,r+1).join(""),11).w<=e;)r++;return r?[a.slice(0,r).join(""),a.slice(r).join("")]:null}if(i.measure(o[0],11).w>e)return null;let n=o[0],s=1;for(;s<o.length-1&&i.measure(n+" "+o[s],11).w<=e;)n+=" "+o[s++];return[n,o.slice(s).join(" ")]}function gt(t,e){const i=e.scales[t.scale],o=i.input==="category"?i.domain().length:0,n=Math.max(44,e.size.w*mt),s=o>0&&e.plot.h/o>=2*N+2;return a=>{if(e.measure(a,11).w<=n)return[a];const r=s?dt(a,n,e):null;return r?[r[0],U(r[1],n,e)]:[U(a,n,e)]}}function D(t,e,i){if(t.scale&&(i==="left"||i==="right"))return gt(t,e);const o=t.scale?e.scales[t.scale]:void 0,n=o&&o.input==="category"?o.domain().length:0;if(!n)return a=>[a];const s=e.plot.w/n-6;return a=>Z(a,s,e)}function Z(t,e,i){if(i.measure(t,11).w<=e)return[t];const o=t.split(/\s+/).filter(Boolean);if(o.length<2)return i.wide(t)?H(t,e,i):[t];let n=o[0],s=1;for(;s<o.length-1&&i.measure(n+" "+o[s],11).w<=e;)n+=" "+o[s++];return[n,o.slice(s).join(" ")]}const J=new WeakMap;function B(t,e){const{text:i,from:o,to:n}=t;if(i===void 0&&o===void 0&&n===void 0)return null;if(typeof i!="string"||typeof o!="string"||typeof n!="string")throw new Error('an axis that names spans needs all three of "text", "from" and "to"');const s=I(t,e);if(s==="left"||s==="right")throw new Error('"text", "from" and "to" name spans along a horizontal axis (top or bottom)');return{text:i,from:o,to:n}}function wt(t,e,i){const o=B(t,e),n=e.table.columns,s=n[o.text],a=n[o.from],r=n[o.to],u=e.scales[t.scale];if(!s||!a||!r||!u)return[];const m=t.format!==void 0?BC.formatter(t.format):null,l=e.plot,f=g=>i.x+(g-l.x)*i.w/l.w,h=[],c=new Set;for(let g=0;g<e.table.length;g++){const T=s[g];if(T==null||T==="")continue;const O=m?m(T):String(T),d=u(a[g]),b=u(r[g]);if(!O||typeof d!="number"||typeof b!="number"||!isFinite(d)||!isFinite(b))continue;const k=(d+b)/2;if(k<l.x-.5||k>l.x+l.w+.5)continue;const y=`${d},${b}|${O}`;if(c.has(y))continue;c.add(y);const p=f(Math.min(d,b)),w=f(Math.max(d,b));h.push({label:O,lo:p,hi:w,mid:(p+w)/2})}return h.sort((g,T)=>g.mid-T.mid)}function Tt(t,e,i,o){const n=t.map(l=>{const f=Z(l.label,l.hi-l.lo-L,e),h=f.reduce((g,T)=>Math.max(g,e.textWidth(T,11)),0),c=f.reduce((g,T)=>Math.max(g,e.measure(T,11).w),h);return{...l,lines:f,w:h,room:c,x:l.mid}}),s=n.length;if(!s)return{named:n,ok:!0};const a=[0];for(let l=1;l<s;l++)a.push(a[l-1]+(n[l-1].w+n[l].w)/2+L);const r=[];for(let l=0;l<s;l++){let f={first:l,last:l,sum:n[l].mid-a[l]};for(;r.length;){const h=r[r.length-1];if(h.sum/(h.last-h.first+1)<f.sum/(f.last-f.first+1))break;r.pop(),f={first:h.first,last:f.last,sum:h.sum+f.sum}}r.push(f)}for(const l of r)for(let f=l.first;f<=l.last;f++)n[f].x=l.sum/(l.last-l.first+1)+a[f];const u=l=>a[l]-a[l-1];n[s-1].x=Math.min(n[s-1].x,o-n[s-1].room/2);for(let l=s-2;l>=0;l--)n[l].x=Math.min(n[l].x,n[l+1].x-u(l+1));n[0].x=Math.max(n[0].x,i+n[0].room/2);for(let l=1;l<s;l++)n[l].x=Math.max(n[l].x,n[l-1].x+u(l));const m=n[s-1].x+n[s-1].room/2<=o+.5&&n.every(l=>Math.abs(l.x-l.mid)<=l.w/2);return{named:n,ok:m}}const bt=2;function Y(t,e,i){const o=i?z(t,e):{x:e.plot.x,w:e.plot.w},n=wt(t,e,o).filter(r=>r.hi-r.lo>=bt),s=i?void 0:J.get(t),a=[];for(const r of n){const u=a[a.length-1];if(u&&r.mid-u.mid<W){r.hi-r.lo>u.hi-u.lo&&(a[a.length-1]=r);continue}a.push(r)}if(!s){const r=m=>Tt(m,e,0,e.size.w);let u=r(n);if(!u.ok){const m=n.map((c,g)=>g).sort((c,g)=>n[c].hi-n[c].lo-(n[g].hi-n[g].lo)),l=c=>{const g=new Set(m.slice(0,c));return n.filter((T,O)=>!g.has(O))};let f=1,h=n.length;for(;f<h;){const c=f+h>>1;r(l(c)).ok?h=c:f=c+1}u=r(l(f))}if(s===0||u.named.length>=a.length)return{angle:0,named:u.named}}return{angle:45,named:a.map(r=>({...r,label:C(r.label),lines:[C(r.label)],w:0,room:0,x:r.mid}))}}function tt(t,e,i,o,n){const s=o===90?0:E,a=o===90?1:E;let r=0,u=0,m=0;for(const f of n){const h=e.textWidth(f.label,11),c=(h+11)*s;r=Math.max(r,h*a),i==="bottom"?u=Math.max(u,e.plot.x-(f.pos-c)):m=Math.max(m,f.pos+c-(e.plot.x+e.plot.w))}const l={overhang:{top:0,right:m,bottom:0,left:u}};return l[i]=A(t)+r+11*E+4+(_(t)?20.4:0),l}const et={role:"guide",type:"axis",version:20,params:{scale:{kind:"scale",required:!0},position:{kind:"enum",values:["top","right","bottom","left"]},title:{kind:"string"},format:{kind:"format"},line:{kind:"enum",values:["auto","on","off"],default:"auto"},ticks:{kind:"boolean",default:!1},count:{kind:"number"},anchor:{kind:"enum",values:["start","end"],default:"start"},text:{kind:"field"},from:{kind:"field"},to:{kind:"field"}},fits:q,measure(t,e){if(!t.scale)return{};const i=I(t,e),o=i==="left"||i==="right";if(B(t,e)){const{angle:l,named:f}=Y(t,e,!0);if(J.set(t,l),l)return tt(t,e,i,l,f.map(d=>({pos:d.x,label:d.label})));const h=z(t,e);let c=0,g=0,T=0;for(const d of f)c=Math.max(c,d.lines.length>1?d.lines.length*N:e.measure(d.label,11).h),g=Math.max(g,h.x-(d.x-d.room/2)),T=Math.max(T,d.x+d.room/2-(h.x+h.w));const O={overhang:{top:0,right:T,bottom:0,left:g}};return O[i]=A(t)+c+4+(_(t)?20.4:0),O}const n=lt(t,e,i);if(n?F.set(t,n):F.delete(t),n)return tt(t,e,i,n,Q(t,e));let s=0;const a={top:0,right:0,bottom:0,left:0},r=e.plot,u=D(t,e,i);for(const l of P(t,e)){const f=u(l.label),h=f.reduce((c,g)=>{const T=e.measure(g,11);return{w:Math.max(c.w,T.w),h:c.h}},{w:0,h:f.length>1?f.length*N:e.measure(l.label,11).h});if(s=Math.max(s,o?h.w:h.h),o){const c=l.pos-(f.length-1)/2*N;a.top=Math.max(a.top,r.y-(l.pos-h.h/2),r.y-(c-st*11)),a.bottom=Math.max(a.bottom,l.pos+h.h/2-(r.y+r.h))}else a.left=Math.max(a.left,r.x-(l.pos-h.w/2)),a.right=Math.max(a.right,l.pos+h.w/2-(r.x+r.w))}const m={overhang:a};return m[i]=A(t)+s+4+(_(t)?20.4:0),m},render(t,e,i){if(!t.scale)return{};const o=I(t,e),{x:n,y:s,w:a,h:r}=e.plot,u=B(t,e),m=u?[]:Q(t,e),l=[],f=_(t);let h,c=0;const g=A(t),T=t.ticks===!0;if(o==="left"||o==="right"){const d=o==="left"?-1:1,b=o==="left"?n-i.left:n+a+i.right;h=j(t,o)?`M${b} ${s}V${s+r}`:"";const k=D(t,e,o);for(const w of m){T&&(h+=`M${b} ${w.pos}H${b+d*5}`);const M=k(w.label),x=M.length===1&&M[0]===w.label?void 0:w.label;M.forEach((v,R)=>{c=Math.max(c,e.measure(v,11).w),l.push({type:"text",x:b+d*g,y:w.pos+(R-(M.length-1)/2)*N,text:v,size:11,anchor:d<0?"end":"start",baseline:"middle",style:{fill:S},cls:"bc-axis-label",title:x})})}const y=b+d*(g+c+4+20.4/2);if(!!f&&Array.from(f).every(w=>e.wide(w))&&f.length*12*1.1<=r){const w=Array.from(f);w.forEach((M,x)=>{l.push({type:"text",x:y,y:s+r/2+(x-(w.length-1)/2)*12*1.1,text:M,size:12,weight:600,anchor:"middle",baseline:"middle",style:{fill:$},cls:"bc-axis-title"})})}else f&&l.push({type:"text",x:y,y:s+r/2,text:f,size:12,weight:600,anchor:"middle",baseline:"middle",rotate:d<0?-90:90,style:{fill:$},cls:"bc-axis-title"})}else{const d=o==="top"?-1:1,b=o==="top"?s-i.top:s+r+i.bottom;h=j(t,o)?`M${n} ${b}H${n+a}`:"";const k=(p,w,M)=>{c=Math.max(c,e.textWidth(w,11)*(M===90?1:E)+11*E),l.push({type:"text",x:p,y:b+d*g,text:w,size:11,anchor:d<0?"start":"end",baseline:"middle",rotate:-M,style:{fill:S},cls:"bc-axis-label"})},y=(p,w,M)=>{c=Math.max(c,M.length>1?M.length*N:e.measure(w,11).h),(d<0?M.slice().reverse():M).forEach((v,R)=>{l.push({type:"text",x:p,y:b+d*(g+R*N),text:v,size:11,anchor:"middle",baseline:d<0?"auto":"hanging",style:{fill:S},cls:"bc-axis-label"})})};if(u){const{angle:p,named:w}=Y(t,e,!1);for(const M of w)T&&(h+=`M${M.mid} ${b}V${b+d*5}`),p?k(M.mid,M.label,p):y(M.x,M.label,M.lines)}else{const p=D(t,e,o);for(const w of m)T&&(h+=`M${w.pos} ${b}V${b+d*5}`),F.has(t)?k(w.pos,w.label,F.get(t)):y(w.pos,w.label,p(w.label))}if(f){const p=b+d*(g+c+4+2);l.push({type:"text",x:n+a/2,y:p,text:f,size:12,weight:600,anchor:"middle",baseline:d<0?"auto":"hanging",style:{fill:$},cls:"bc-axis-title"})}}return{axes:[...h?[{type:"path",d:h,cls:"bc-axis",style:{fill:"none",stroke:nt,strokeWidth:1}}]:[],...l]}}};BC.define(et)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(E){const ot="var(--bc-axis, #888)",S="var(--bc-text, #444)",z="var(--bc-label, var(--bc-text, #444))",I=t=>t.ticks===!0?9:8,K=(t,e)=>t.line==="on"?!0:t.line==="off"?!1:e==="top"||e==="bottom";function L(t,e){return t.position?t.position:t.scale&&e.orientation(t.scale)==="vertical"?"left":"bottom"}const F=new WeakMap,A=.71,st=14,V=19,G=20,_=6,it=.85,lt=/^\s*-?\d[\d.,:\/-]*(T[\d:.]+Z?)?\s*$/;function P(t,e){let i=0,o=0;for(const n of e.spec.guides||[])if(n!==t)if(n.type==="axis"){const s=n.scale?L(n,e):"top",a=(s==="left"||s==="right")&&nt.measure(n,e)[s]||0;s==="left"?i+=a:s==="right"&&(o+=a)}else{const s=E.get(`guide.${n.type}`),a=s&&s.measure?s.measure(n,e):{};i+=a.left||0,o+=a.right||0}return{x:e.plot.x+i,w:e.plot.w-i-o}}function rt(t,e,i){const o=t.scale?e.scales[t.scale]:void 0;if(!o||o.input!=="category"||i==="left"||i==="right"||e.orientation(t.scale)!=="horizontal")return 0;const n=o.domain(),s=P(t,e).w;return n.length<2||s/n.length<st||n.every(a=>typeof a=="number"||a instanceof Date||lt.test(String(a)))||X(t,e,s)>=n.length?0:s/n.length<V?90:45}const at=/[、。,.・:;?!)」』】〕》〉ーゝゞ々ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ]/,ft=/[(「『【〔《〈]/,H=/\d/;function q(t,e){const i=[];for(let o=1;o<t.length;o++){const n=t[o-1],s=t[o];!e.wide(n)||at.test(s)||ft.test(n)||H.test(s)&&!(o>=2&&H.test(t[o-2]))||i.push(o)}return i}function B(t,e,i){const o=Array.from(t),n=(r,u)=>i.measure(o.slice(r,u).join(""),11).w;let s=-1,a=1/0;for(const r of q(o,i)){const u=n(0,r);if(u>e)break;const m=Math.max(u,n(r,o.length));m<a&&(a=m,s=r)}if(s<0){const r=q(o,i);if(!r.length)return[t];s=r[0]}return[o.slice(0,s).join(""),o.slice(s).join("")]}function X(t,e,i){const o=t.scale,n=e.orientation(o)==="horizontal";let s=0;for(const a of e.scales[o].domain()){const r=String(a);if(!n){s=Math.max(s,e.measure(r,11).h);continue}const u=e.measure(r,11).w,m=r.split(/\s+/).filter(Boolean),l=m.length===1&&e.wide(r)?Math.max(...B(r,1/0,e).map(f=>e.measure(f,11).w)):m.reduce((f,h)=>Math.max(f,e.measure(h,11).w),0);s=Math.max(s,Math.min(u,Math.max(l,u/2)))}return Math.floor(i/(n?s*.9+4:s+3))}const D=t=>t.length>G?t.slice(0,G-1)+"\u2026":t;function R(t,e){return ut(mt(t,e),t,e)}function ut(t,e,i){if(i.scales[e.scale].input==="category"||i.orientation(e.scale)!=="horizontal")return t;const o=Q(e),n=t.filter((u,m)=>m===0||u.label!==t[m-1].label);if(n.length<2)return n;let s=1/0;for(let u=1;u<n.length;u++)s=Math.min(s,Math.abs(n[u].pos-n[u-1].pos));const a=n.reduce((u,m)=>Math.max(u,i.measure(m.label,11).w),0),r=s>0?Math.ceil((a+_)/s):1;return r>1?n.filter((u,m)=>o(m,n.length,r)):n}const Q=t=>(e,i,o)=>(t.anchor==="end"?i-1-e:e)%o===0;function ht(t,e){if(t.format===void 0||e.orientation(t.scale)!=="horizontal")return 0;const i=E.formatter(t.format),o=e.scales[t.scale].domain(),n=o.reduce((s,a)=>Math.max(s,e.measure(i(a),11).w),0);return Math.min(o.length,Math.floor(e.plot.w/(n+_)))}function ct(t,e){const i=t.scale,o=e.scales[i],n=typeof t.count=="number"&&t.count>=1?Math.round(t.count):void 0;if(o.input!=="category")return n===void 0?e.ticks(i):e.ticks(i,n);const s=Math.max(e.ticks(i).length,ht(t,e)),a=n===void 0?s:Math.min(n,s);if(t.anchor!=="end")return e.ticks(i,a);const r=e.ticks(i,o.domain().length),u=Math.max(1,Math.ceil(r.length/Math.max(1,a))),m=Q(t);return r.filter((l,f)=>m(f,r.length,u))}function mt(t,e){const i=e.scales[t.scale],o=F.has(t)?e.ticks(t.scale,i.domain().length):ct(t,e);if(t.format===void 0||i.output!=="position")return o;const{input:n}=i,s=E.formatter(t.format,n==="date"?"date":n==="category"?void 0:"number");return o.map(a=>({value:a.value,pos:a.pos,label:s(a.value)}))}const U=(t,e)=>F.has(t)?R(t,e).map(i=>({...i,label:D(i.label)})):R(t,e),x=t=>typeof t.title=="string"?t.title:"",N=11*1.25,dt=.3;function Z(t,e,i){if(i.measure(t,11).w<=e)return t;const o=Array.from(t);let n=0,s=o.length;for(;n<s;){const a=n+s+1>>1;i.measure(o.slice(0,a).join("")+"\u2026",11).w<=e?n=a:s=a-1}return o.slice(0,n).join("").trimEnd()+"\u2026"}function gt(t,e,i){const o=t.split(/\s+/).filter(Boolean);if(o.length<2){if(!i.wide(t))return null;const a=Array.from(t);let r=0;for(;r<a.length-1&&i.measure(a.slice(0,r+1).join(""),11).w<=e;)r++;return r?[a.slice(0,r).join(""),a.slice(r).join("")]:null}if(i.measure(o[0],11).w>e)return null;let n=o[0],s=1;for(;s<o.length-1&&i.measure(n+" "+o[s],11).w<=e;)n+=" "+o[s++];return[n,o.slice(s).join(" ")]}function wt(t,e){const i=e.scales[t.scale],o=i.input==="category"?i.domain().length:0,n=Math.max(44,e.size.w*dt),s=o>0&&e.plot.h/o>=2*N+2;return a=>{if(e.measure(a,11).w<=n)return[a];const r=s?gt(a,n,e):null;return r?[r[0],Z(r[1],n,e)]:[Z(a,n,e)]}}function j(t,e,i){if(t.scale&&(i==="left"||i==="right"))return wt(t,e);const o=t.scale?e.scales[t.scale]:void 0,n=o&&o.input==="category"?o.domain().length:0;if(!n)return a=>[a];const s=e.plot.w/n-6;return a=>J(a,s,e)}function J(t,e,i){if(i.measure(t,11).w<=e)return[t];const o=t.split(/\s+/).filter(Boolean);if(o.length<2)return i.wide(t)?B(t,e,i):[t];let n=o[0],s=1;for(;s<o.length-1&&i.measure(n+" "+o[s],11).w<=e;)n+=" "+o[s++];return[n,o.slice(s).join(" ")]}const Y=new WeakMap;function W(t,e){const{text:i,from:o,to:n}=t;if(i===void 0&&o===void 0&&n===void 0)return null;if(typeof i!="string"||typeof o!="string"||typeof n!="string")throw new Error('an axis that names spans needs all three of "text", "from" and "to"');const s=L(t,e);if(s==="left"||s==="right")throw new Error('"text", "from" and "to" name spans along a horizontal axis (top or bottom)');return{text:i,from:o,to:n}}function Tt(t,e,i){const o=W(t,e),n=e.table.columns,s=n[o.text],a=n[o.from],r=n[o.to],u=e.scales[t.scale];if(!s||!a||!r||!u)return[];const m=t.format!==void 0?E.formatter(t.format):null,l=e.plot,f=g=>i.x+(g-l.x)*i.w/l.w,h=[],c=new Set;for(let g=0;g<e.table.length;g++){const T=s[g];if(T==null||T==="")continue;const O=m?m(T):String(T),d=u(a[g]),b=u(r[g]);if(!O||typeof d!="number"||typeof b!="number"||!isFinite(d)||!isFinite(b))continue;const k=(d+b)/2;if(k<l.x-.5||k>l.x+l.w+.5)continue;const y=`${d},${b}|${O}`;if(c.has(y))continue;c.add(y);const p=f(Math.min(d,b)),w=f(Math.max(d,b));h.push({label:O,lo:p,hi:w,mid:(p+w)/2})}return h.sort((g,T)=>g.mid-T.mid)}function bt(t,e,i,o){const n=t.map(l=>{const f=J(l.label,l.hi-l.lo-_,e),h=f.reduce((g,T)=>Math.max(g,e.textWidth(T,11)),0),c=f.reduce((g,T)=>Math.max(g,e.measure(T,11).w),h);return{...l,lines:f,w:h,room:c,x:l.mid}}),s=n.length;if(!s)return{named:n,ok:!0};const a=[0];for(let l=1;l<s;l++)a.push(a[l-1]+(n[l-1].w+n[l].w)/2+_);const r=[];for(let l=0;l<s;l++){let f={first:l,last:l,sum:n[l].mid-a[l]};for(;r.length;){const h=r[r.length-1];if(h.sum/(h.last-h.first+1)<f.sum/(f.last-f.first+1))break;r.pop(),f={first:h.first,last:f.last,sum:h.sum+f.sum}}r.push(f)}for(const l of r)for(let f=l.first;f<=l.last;f++)n[f].x=l.sum/(l.last-l.first+1)+a[f];const u=l=>a[l]-a[l-1];n[s-1].x=Math.min(n[s-1].x,o-n[s-1].room/2);for(let l=s-2;l>=0;l--)n[l].x=Math.min(n[l].x,n[l+1].x-u(l+1));n[0].x=Math.max(n[0].x,i+n[0].room/2);for(let l=1;l<s;l++)n[l].x=Math.max(n[l].x,n[l-1].x+u(l));const m=n[s-1].x+n[s-1].room/2<=o+.5&&n.every(l=>Math.abs(l.x-l.mid)<=l.w/2);return{named:n,ok:m}}const Mt=2;function tt(t,e,i){const o=i?P(t,e):{x:e.plot.x,w:e.plot.w},n=Tt(t,e,o).filter(r=>r.hi-r.lo>=Mt),s=i?void 0:Y.get(t),a=[];for(const r of n){const u=a[a.length-1];if(u&&r.mid-u.mid<V){r.hi-r.lo>u.hi-u.lo&&(a[a.length-1]=r);continue}a.push(r)}if(!s){const r=m=>bt(m,e,0,e.size.w);let u=r(n);if(!u.ok){const m=n.map((c,g)=>g).sort((c,g)=>n[c].hi-n[c].lo-(n[g].hi-n[g].lo)),l=c=>{const g=new Set(m.slice(0,c));return n.filter((T,O)=>!g.has(O))};let f=1,h=n.length;for(;f<h;){const c=f+h>>1;r(l(c)).ok?h=c:f=c+1}u=r(l(f))}if(s===0||u.named.length>=a.length)return{angle:0,named:u.named}}return{angle:45,named:a.map(r=>({...r,label:D(r.label),lines:[D(r.label)],w:0,room:0,x:r.mid}))}}function et(t,e,i,o,n){const s=o===90?0:A,a=o===90?1:A;let r=0,u=0,m=0;for(const f of n){const h=e.textWidth(f.label,11),c=(h+11)*s;r=Math.max(r,h*a),i==="bottom"?u=Math.max(u,e.plot.x-(f.pos-c)):m=Math.max(m,f.pos+c-(e.plot.x+e.plot.w))}const l={overhang:{top:0,right:m,bottom:0,left:u}};return l[i]=I(t)+r+11*A+4+(x(t)?20.4:0),l}const nt={role:"guide",type:"axis",version:20,params:{scale:{kind:"scale",required:!0},position:{kind:"enum",values:["top","right","bottom","left"]},title:{kind:"string"},format:{kind:"format"},line:{kind:"enum",values:["auto","on","off"],default:"auto"},ticks:{kind:"boolean",default:!1},count:{kind:"number"},anchor:{kind:"enum",values:["start","end"],default:"start"},text:{kind:"field"},from:{kind:"field"},to:{kind:"field"}},fits:X,measure(t,e){if(!t.scale)return{};const i=L(t,e),o=i==="left"||i==="right";if(W(t,e)){const{angle:l,named:f}=tt(t,e,!0);if(Y.set(t,l),l)return et(t,e,i,l,f.map(d=>({pos:d.x,label:d.label})));const h=P(t,e);let c=0,g=0,T=0;for(const d of f)c=Math.max(c,d.lines.length>1?d.lines.length*N:e.measure(d.label,11).h),g=Math.max(g,h.x-(d.x-d.room/2)),T=Math.max(T,d.x+d.room/2-(h.x+h.w));const O={overhang:{top:0,right:T,bottom:0,left:g}};return O[i]=I(t)+c+4+(x(t)?20.4:0),O}const n=rt(t,e,i);if(n?F.set(t,n):F.delete(t),n)return et(t,e,i,n,U(t,e));let s=0;const a={top:0,right:0,bottom:0,left:0},r=e.plot,u=j(t,e,i);for(const l of R(t,e)){const f=u(l.label),h=f.reduce((c,g)=>{const T=e.measure(g,11);return{w:Math.max(c.w,T.w),h:c.h}},{w:0,h:f.length>1?f.length*N:e.measure(l.label,11).h});if(s=Math.max(s,o?h.w:h.h),o){const c=l.pos-(f.length-1)/2*N;a.top=Math.max(a.top,r.y-(l.pos-h.h/2),r.y-(c-it*11)),a.bottom=Math.max(a.bottom,l.pos+h.h/2-(r.y+r.h))}else a.left=Math.max(a.left,r.x-(l.pos-h.w/2)),a.right=Math.max(a.right,l.pos+h.w/2-(r.x+r.w))}const m={overhang:a};return m[i]=I(t)+s+4+(x(t)?20.4:0),m},render(t,e,i){if(!t.scale)return{};const o=L(t,e),{x:n,y:s,w:a,h:r}=e.plot,u=W(t,e),m=u?[]:U(t,e),l=[],f=x(t);let h,c=0;const g=I(t),T=t.ticks===!0;if(o==="left"||o==="right"){const d=o==="left"?-1:1,b=o==="left"?n-i.left:n+a+i.right;h=K(t,o)?`M${b} ${s}V${s+r}`:"";const k=j(t,e,o);for(const w of m){T&&(h+=`M${b} ${w.pos}H${b+d*5}`);const M=k(w.label),v=M.length===1&&M[0]===w.label?void 0:w.label;M.forEach(($,C)=>{c=Math.max(c,e.measure($,11).w),l.push({type:"text",x:b+d*g,y:w.pos+(C-(M.length-1)/2)*N,text:$,size:11,anchor:d<0?"end":"start",baseline:"middle",style:{fill:z},cls:"bc-axis-label",title:v})})}const y=b+d*(g+c+4+20.4/2);if(!!f&&Array.from(f).every(w=>e.wide(w))&&f.length*12*1.1<=r){const w=Array.from(f);w.forEach((M,v)=>{l.push({type:"text",x:y,y:s+r/2+(v-(w.length-1)/2)*12*1.1,text:M,size:12,weight:600,anchor:"middle",baseline:"middle",style:{fill:S},cls:"bc-axis-title"})})}else f&&l.push({type:"text",x:y,y:s+r/2,text:f,size:12,weight:600,anchor:"middle",baseline:"middle",rotate:d<0?-90:90,style:{fill:S},cls:"bc-axis-title"})}else{const d=o==="top"?-1:1,b=o==="top"?s-i.top:s+r+i.bottom;h=K(t,o)?`M${n} ${b}H${n+a}`:"";const k=(p,w,M)=>{c=Math.max(c,e.textWidth(w,11)*(M===90?1:A)+11*A),l.push({type:"text",x:p,y:b+d*g,text:w,size:11,anchor:d<0?"start":"end",baseline:"middle",rotate:-M,style:{fill:z},cls:"bc-axis-label"})},y=(p,w,M)=>{c=Math.max(c,M.length>1?M.length*N:e.measure(w,11).h),(d<0?M.slice().reverse():M).forEach(($,C)=>{l.push({type:"text",x:p,y:b+d*(g+C*N),text:$,size:11,anchor:"middle",baseline:d<0?"auto":"hanging",style:{fill:z},cls:"bc-axis-label"})})};if(u){const{angle:p,named:w}=tt(t,e,!1);for(const M of w)T&&(h+=`M${M.mid} ${b}V${b+d*5}`),p?k(M.mid,M.label,p):y(M.x,M.label,M.lines)}else{const p=j(t,e,o);for(const w of m)T&&(h+=`M${w.pos} ${b}V${b+d*5}`),F.has(t)?k(w.pos,w.label,F.get(t)):y(w.pos,w.label,p(w.label))}if(f){const p=b+d*(g+c+4+2);l.push({type:"text",x:n+a/2,y:p,text:f,size:12,weight:600,anchor:"middle",baseline:d<0?"auto":"hanging",style:{fill:S},cls:"bc-axis-title"})}}return{axes:[...h?[{type:"path",d:h,cls:"bc-axis",style:{fill:"none",stroke:ot,strokeWidth:1}}]:[],...l]}}};E.define(nt)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const u={role:"guide",type:"grid",version:3,narrow:!0,params:{scale:{kind:"scale",required:!0},count:{kind:"number"}},render(e,n){const t=e.scale;if(!t)return{};const c=n.orientation(t)==="vertical",{x:o,y:i,w:a,h:l}=n.plot;let r="";const s=typeof e.count=="number"&&e.count>=1?Math.round(e.count):void 0;for(const d of s===void 0?n.ticks(t):n.ticks(t,s))r+=c?`M${o} ${d.pos}H${o+a}`:`M${d.pos} ${i}V${i+l}`;return r?{grid:[{type:"path",d:r,cls:"bc-grid",style:{fill:"none",stroke:"var(--bc-grid, #e6e6e6)",strokeWidth:1}}]}:{}}};BC.define(u)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(u){const c={role:"guide",type:"grid",version:3,narrow:!0,params:{scale:{kind:"scale",required:!0},count:{kind:"number"}},render(e,n){const t=e.scale;if(!t)return{};const a=n.orientation(t)==="vertical",{x:o,y:i,w:l,h:f}=n.plot;let r="";const s=typeof e.count=="number"&&e.count>=1?Math.round(e.count):void 0;for(const d of s===void 0?n.ticks(t):n.ticks(t,s))r+=a?`M${o} ${d.pos}H${o+l}`:`M${d.pos} ${i}V${i+f}`;return r?{grid:[{type:"path",d:r,cls:"bc-grid",style:{fill:"none",stroke:"var(--bc-grid, #e6e6e6)",strokeWidth:1}}]}:{}}};u.define(c)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const v="var(--bc-label, var(--bc-text, #666))",D="var(--bc-kpi, var(--bc-text, #111))",C="var(--bc-good, #12a150)",P="var(--bc-bad, #e5484d)",T="var(--bc-label, #888)",F=["last","first","sum","mean","min","max","count"];function _(t){const o=[];if(!t)return o;for(let n=0;n<t.length;n++){const e=t[n];typeof e=="number"&&isFinite(e)&&o.push(e)}return o}function p(t,o){if(o==="count")return t.length;if(!t.length)return NaN;switch(o){case"first":return t[0];case"sum":return t.reduce((n,e)=>n+e,0);case"mean":return t.reduce((n,e)=>n+e,0)/t.length;case"min":return t.reduce((n,e)=>e<n?e:n);case"max":return t.reduce((n,e)=>e>n?e:n);default:return t[t.length-1]}}const c=(t,o)=>t.baseTable.columns[o]||t.table.columns[o];function $(t,o){const n=typeof t.aggregate=="string"&&F.indexOf(t.aggregate)>=0?t.aggregate:"last",e=_(c(o,t.field)),a=p(e,n);let i=NaN;if(typeof t.against=="string")i=p(_(c(o,t.against)),n);else{const r=t.compare==="first"||t.compare==="none"||t.compare==="previous"?t.compare:n==="last"?"previous":"none";r==="previous"&&e.length>1?i=e[e.length-2]:r==="first"&&e.length>1&&(i=e[0])}return{value:a,base:i}}const x=t=>typeof t.note=="string"?t.note:"";function I(t,o,n,e,a,i){const r=t.textWidth(o,n,e);return r<=a?n:Math.max(Math.min(i,n),Math.floor(n*a/r*2)/2)}function y(t,o,n,e,a){if(t.textWidth(o,n,e)<=a)return o;const i=Array.from(o);let r=0,l=i.length;for(;r<l;){const s=r+l+1>>1;t.textWidth(i.slice(0,s).join("")+"\u2026",n,e)<=a?r=s:l=s-1}return r?i.slice(0,r).join("").trimEnd()+"\u2026":""}function N(t,o){const n=Math.max(1,o.size.w-o.plot.x-2),e=typeof t.size=="number"&&t.size>0&&isFinite(t.size)?t.size:30,a=W(t,o),i=typeof t.label=="string"?t.label:"",r=i&&a?`${i}: ${a}`:i||a,l=I(o,r,12,500,n,10),s=y(o,r,l,500,n),{value:u,base:m}=$(t,o),E=t.format!==void 0?BC.formatter(t.format):d=>BC.formatter("compact")(d),h=isFinite(u)?E(u):"\u2013",w=I(o,h,e,650,n,8);let f="",B="",M=T;if(isFinite(u)&&isFinite(m)){const d=u-m,S=d>0,O=d===0,R=t.better==="down"?!S:S;M=O?T:R?C:P;const Z=t.deltaFormat!==void 0?BC.formatter(t.deltaFormat):null,z=b=>S&&!/^[+]/.test(b)?"+"+b:b;let k;if(t.delta==="absolute")k=z((Z||E)(d*(typeof t.deltaScale=="number"&&isFinite(t.deltaScale)?t.deltaScale:1)));else{const b=Z||BC.formatter({style:"percent",maximumFractionDigits:1});k=m!==0?z(b(d/Math.abs(m))):""}f=`${O?"\u25A0":S?"\u25B2":"\u25BC"} ${k}`.trim(),B=k}const g=x(t),L=f&&g?6:0,G=(d=>(f?o.textWidth(f,d,600):0)+(g?o.textWidth(g,d,400):0))(12),A=L+G<=n?12:Math.max(10,Math.floor(12*Math.max(0,n-L)/G*2)/2);f&&(f=y(o,f,A,600,n));const V=g?y(o,g,A,400,n-(f?o.textWidth(f,A,600)+L:0)):"",j=f||g?18:0,X=(r?18:0)+w+j+10,q=[r,h,[B,g].filter(Boolean).join(" ")];return{labelled:!!r,label:s,labelSize:l,value:h,valueSize:w,change:f,changeColor:M,note:V,lineSize:A,height:X,spoken:q}}function W(t,o){if(typeof t.rowField!="string")return"";const n=c(o,t.rowField),e=c(o,t.field);if(!n||!e)return"";const a=typeof t.aggregate=="string"?t.aggregate:"last";let i=-1;for(let l=0;l<e.length;l++){const s=e[l];if(typeof s!="number"||!isFinite(s))continue;const u=i<0?NaN:e[i];if((i<0||a==="last"||a==="max"&&s>u||a==="min"&&s<u)&&(i=l),a==="first")break}const r=i<0?null:n[i];return r==null||r!==r?"":t.rowFormat!==void 0?BC.formatter(t.rowFormat)(n[i]):String(n[i])}const U={role:"guide",type:"kpi",version:10,narrow:!0,params:{field:{kind:"field",required:!0},label:{kind:"string"},aggregate:{kind:"enum",values:F,default:"last"},compare:{kind:"enum",values:["previous","first","none"]},against:{kind:"field"},delta:{kind:"enum",values:["percent","absolute"],default:"percent"},deltaFormat:{kind:"format"},deltaScale:{kind:"number",default:1},better:{kind:"enum",values:["up","down"],default:"up"},format:{kind:"format"},note:{kind:"string"},rowField:{kind:"field"},rowFormat:{kind:"format"},size:{kind:"number",default:30}},measure(t,o){const n=typeof t.aggregate=="string"?t.aggregate:"last";if((t.compare==="previous"||t.compare==="first")&&n!=="last"&&typeof t.against!="string")throw new Error(`guide.kpi: compare "${t.compare}" compares one row with another, so it needs aggregate "last" (not "${n}"); to compare a ${n} with something, give "against" a field`);if(typeof t.rowField=="string"&&["last","first","min","max"].indexOf(n)<0)throw new Error(`guide.kpi: rowField names one row, and aggregate "${n}" comes from many; use last, first, min or max`);return{top:N(t,o).height}},render(t,o,n){if(typeof t.field!="string"||!c(o,t.field))return{};const e=N(t,o),a=o.plot.x;let i=o.plot.y-n.top-e.height;const r=[],l=(u,m,E,h,w,f)=>r.push({type:"text",x:m,y:i,text:u,size:E,weight:h,baseline:"hanging",style:{fill:w},cls:f});e.label&&l(e.label,a,e.labelSize,500,v,"bc-kpi-label"),e.labelled&&(i+=18),l(e.value,a,e.valueSize,650,D,"bc-kpi-value"),i+=e.valueSize+6;let s=a;e.change&&(l(e.change,a,e.lineSize,600,e.changeColor,"bc-kpi-delta"),s=a+o.textWidth(e.change,e.lineSize,600)+6),e.note&&l(e.note,s,e.lineSize,400,v,"bc-kpi-note");for(const u of e.spoken)o.say(u);return{axes:r}}};BC.define(U)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(m){const v="var(--bc-label, var(--bc-text, #666))",$="var(--bc-kpi, var(--bc-text, #111))",x="var(--bc-good, #12a150)",W="var(--bc-bad, #e5484d)",F="var(--bc-label, #888)",_=["last","first","sum","mean","min","max","count"];function p(t){const o=[];if(!t)return o;for(let n=0;n<t.length;n++){const e=t[n];typeof e=="number"&&isFinite(e)&&o.push(e)}return o}function I(t,o){if(o==="count")return t.length;if(!t.length)return NaN;switch(o){case"first":return t[0];case"sum":return t.reduce((n,e)=>n+e,0);case"mean":return t.reduce((n,e)=>n+e,0)/t.length;case"min":return t.reduce((n,e)=>e<n?e:n);case"max":return t.reduce((n,e)=>e>n?e:n);default:return t[t.length-1]}}const h=(t,o)=>t.baseTable.columns[o]||t.table.columns[o];function U(t,o){const n=typeof t.aggregate=="string"&&_.indexOf(t.aggregate)>=0?t.aggregate:"last",e=p(h(o,t.field)),a=I(e,n);let i=NaN;if(typeof t.against=="string")i=I(p(h(o,t.against)),n);else{const r=t.compare==="first"||t.compare==="none"||t.compare==="previous"?t.compare:n==="last"?"previous":"none";r==="previous"&&e.length>1?i=e[e.length-2]:r==="first"&&e.length>1&&(i=e[0])}return{value:a,base:i}}const V=t=>typeof t.note=="string"?t.note:"";function N(t,o,n,e,a,i){const r=t.textWidth(o,n,e);return r<=a?n:Math.max(Math.min(i,n),Math.floor(n*a/r*2)/2)}function L(t,o,n,e,a){if(t.textWidth(o,n,e)<=a)return o;const i=Array.from(o);let r=0,l=i.length;for(;r<l;){const s=r+l+1>>1;t.textWidth(i.slice(0,s).join("")+"\u2026",n,e)<=a?r=s:l=s-1}return r?i.slice(0,r).join("").trimEnd()+"\u2026":""}function M(t,o){const n=Math.max(1,o.size.w-o.plot.x-2),e=typeof t.size=="number"&&t.size>0&&isFinite(t.size)?t.size:30,a=B(t,o),i=typeof t.label=="string"?t.label:"",r=i&&a?`${i}: ${a}`:i||a,l=N(o,r,12,500,n,10),s=L(o,r,l,500,n),{value:u,base:c}=U(t,o),w=t.format!==void 0?m.formatter(t.format):d=>m.formatter("compact")(d),b=isFinite(u)?w(u):"\u2013",A=N(o,b,e,650,n,8);let f="",G="",O=F;if(isFinite(u)&&isFinite(c)){const d=u-c,k=d>0,z=d===0,J=t.better==="down"?!k:k;O=z?F:J?x:W;const D=t.deltaFormat!==void 0?m.formatter(t.deltaFormat):null,P=E=>k&&!/^[+]/.test(E)?"+"+E:E;let y;if(t.delta==="absolute")y=P((D||w)(d*(typeof t.deltaScale=="number"&&isFinite(t.deltaScale)?t.deltaScale:1)));else{const E=D||m.formatter({style:"percent",maximumFractionDigits:1});y=c!==0?P(E(d/Math.abs(c))):""}f=`${z?"\u25A0":k?"\u25B2":"\u25BC"} ${y}`.trim(),G=y}const g=V(t),T=f&&g?6:0,Z=(d=>(f?o.textWidth(f,d,600):0)+(g?o.textWidth(g,d,400):0))(12),S=T+Z<=n?12:Math.max(10,Math.floor(12*Math.max(0,n-T)/Z*2)/2);f&&(f=L(o,f,S,600,n));const X=g?L(o,g,S,400,n-(f?o.textWidth(f,S,600)+T:0)):"",q=f||g?18:0,R=(r?18:0)+A+q+10,H=[r,b,[G,g].filter(Boolean).join(" ")];return{labelled:!!r,label:s,labelSize:l,value:b,valueSize:A,change:f,changeColor:O,note:X,lineSize:S,height:R,spoken:H}}function B(t,o){if(typeof t.rowField!="string")return"";const n=h(o,t.rowField),e=h(o,t.field);if(!n||!e)return"";const a=typeof t.aggregate=="string"?t.aggregate:"last";let i=-1;for(let l=0;l<e.length;l++){const s=e[l];if(typeof s!="number"||!isFinite(s))continue;const u=i<0?NaN:e[i];if((i<0||a==="last"||a==="max"&&s>u||a==="min"&&s<u)&&(i=l),a==="first")break}const r=i<0?null:n[i];return r==null||r!==r?"":t.rowFormat!==void 0?m.formatter(t.rowFormat)(n[i]):String(n[i])}const j={role:"guide",type:"kpi",version:10,narrow:!0,params:{field:{kind:"field",required:!0},label:{kind:"string"},aggregate:{kind:"enum",values:_,default:"last"},compare:{kind:"enum",values:["previous","first","none"]},against:{kind:"field"},delta:{kind:"enum",values:["percent","absolute"],default:"percent"},deltaFormat:{kind:"format"},deltaScale:{kind:"number",default:1},better:{kind:"enum",values:["up","down"],default:"up"},format:{kind:"format"},note:{kind:"string"},rowField:{kind:"field"},rowFormat:{kind:"format"},size:{kind:"number",default:30}},measure(t,o){const n=typeof t.aggregate=="string"?t.aggregate:"last";if((t.compare==="previous"||t.compare==="first")&&n!=="last"&&typeof t.against!="string")throw new Error(`guide.kpi: compare "${t.compare}" compares one row with another, so it needs aggregate "last" (not "${n}"); to compare a ${n} with something, give "against" a field`);if(typeof t.rowField=="string"&&["last","first","min","max"].indexOf(n)<0)throw new Error(`guide.kpi: rowField names one row, and aggregate "${n}" comes from many; use last, first, min or max`);return{top:M(t,o).height}},render(t,o,n){if(typeof t.field!="string"||!h(o,t.field))return{};const e=M(t,o),a=o.plot.x;let i=o.plot.y-n.top-e.height;const r=[],l=(u,c,w,b,A,f)=>r.push({type:"text",x:c,y:i,text:u,size:w,weight:b,baseline:"hanging",style:{fill:A},cls:f});e.label&&l(e.label,a,e.labelSize,500,v,"bc-kpi-label"),e.labelled&&(i+=18),l(e.value,a,e.valueSize,650,$,"bc-kpi-value"),i+=e.valueSize+6;let s=a;e.change&&(l(e.change,a,e.lineSize,600,e.changeColor,"bc-kpi-delta"),s=a+o.textWidth(e.change,e.lineSize,600)+6),e.note&&l(e.note,s,e.lineSize,400,v,"bc-kpi-note");for(const u of e.spoken)o.say(u);return{axes:r}}};m.define(j)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const M="var(--bc-text, #444)",z=t=>t.output==="color"&&t.input==="category";function j(t,e){const n=t.scale?e.scales[t.scale]:void 0;if(!n||!(n.output==="color"||n.output==="size"&&n.input==="number"))throw new Error("guide.legend needs a scale of colors, or of sizes for numbers");return n}function G(t,e,n){return x(t,e,3).filter(o=>isFinite(o.pos)&&o.pos>0).map(o=>({label:o.label,r:o.pos,w:E(o.label,n),drawn:n.textWidth(o.label,11)}))}const $="var(--bc-label, var(--bc-text, #888))",N=t=>2*t.r+6+t.w,tt=t=>2*t.r+6+t.drawn,p=(t,e)=>{const n=Y(t,e);return Math.max(1,t.size.w-Math.max(8,n.left)-Math.max(8,n.right))},Y=(t,e)=>e==="top"||e==="bottom"?t.edgeTaken(e):{left:0,right:0},W=(t,e,n,s)=>{const o=Y(t,e);return Math.max(Math.max(8,o.left),Math.min(n,t.size.w-Math.max(8,o.right)-s))};function q(t,e){const n=[];let s=0;for(const o of t){const r=n[n.length-1];!r||r.items.length&&s+O+N(o)>e?(n.push({items:[o],h:Math.max(2*o.r,16)+4}),s=N(o)):(r.items.push(o),r.h=Math.max(r.h,Math.max(2*o.r,16)+4),s+=O+N(o))}return n}const E=(t,e)=>Math.max(e.measure(t,11).w,e.textWidth(t,11));function F(t,e,n=1/0){const s=new Set(t.domain()),o=t.range();return t.baseDomain().map((r,i)=>{const l=String(r),h=K(l,n-10-6,e);return{label:h,full:l,color:o[i],w:E(h,e),drawn:e.textWidth(h,11),hidden:!s.has(r),index:i}})}function K(t,e,n){if(!(e<1/0)||E(t,n)<=e)return t;const s=Array.from(t);let o=0,r=s.length;for(;o<r;){const i=o+r+1>>1;E(s.slice(0,i).join("")+"\u2026",n)<=e?o=i:r=i-1}return s.slice(0,o).join("").trimEnd()+"\u2026"}function x(t,e,n=4){const s=t.ticks?t.ticks(n):[];if(e.format===void 0)return s;const o=BC.formatter(e.format,"number");return s.map(r=>({value:r.value,pos:r.pos,label:o(r.value)}))}const R=t=>typeof t.title=="string"&&t.title?t.title:"",H=t=>R(t)?16:0,et=(t,e)=>R(t)?e.measure(R(t),11).w:0,nt=.2;function ot(t,e){if(!z(t))return"right";const n=p(e,"top");return I(F(t,e,n),n).length<=2?"top":"right"}function k(t,e,n){const s=et(t,n),o=H(t);if(e.output==="size"){const i=G(e,t,n),l=i.reduce((h,b)=>Math.max(h,b.r),0);return{w:Math.max(2*l+6+i.reduce((h,b)=>Math.max(h,b.w),0),s)+16,h:4+o+i.reduce((h,b)=>h+Math.max(2*b.r,16)+4,0)}}if(!z(e)){const i=x(e,t).reduce((l,h)=>Math.max(l,n.measure(h.label,11).w),0);return{w:Math.max(18+i,s)+16,h:0}}const r=F(e,n);return{w:Math.max(16+r.reduce((i,l)=>Math.max(i,l.w),0),s)+16,h:4+o+r.length*16+4}}function U(t,e,n){const s=t.position==="auto"?ot(e,n):t.position||"right";if(!B(s))return s;const o=k(t,e,n);return o.w<=n.size.w*nt&&o.h<=n.size.h?s:"top"}const B=t=>t==="left"||t==="right",X=(t,e,n)=>Math.max(e,Math.min(n,t)),O=14,Z=t=>16+t.w,st=t=>16+t.drawn;function I(t,e){const n=[];let s=[],o=0;for(const r of t){const i=Z(r);s.length&&o+O+i>e&&(n.push(s),s=[],o=0),o+=(s.length?O:0)+i,s.push(r)}return s.length&&n.push(s),n}function it(t,e){return t?X(e.plot.h*.6,80,200):X(e.plot.w*.4,100,240)}const rt={role:"guide",type:"legend",version:16,shownOnce:!0,params:{scale:{kind:"scale",required:!0},position:{kind:"enum",values:["top","right","bottom","left","auto"],default:"right"},title:{kind:"string"},format:{kind:"format"}},measure(t,e){const n=j(t,e),s=U(t,n,e),o=B(s),r=H(t),i={};if(n.output==="size"){const b=G(n,t,e);return i[s]=b.length?o?k(t,n,e).w:q(b,p(e,s)).reduce((T,w)=>T+w.h,0)+8+r:0,i}if(!z(n))return i[s]=o?k(t,n,e).w:12+e.measure("0",11).h+16+r,i;const l=p(e,s),h=F(n,e,o?1/0:l);return i[s]=h.length?o?k(t,n,e).w:I(h,l).length*16+8+r:0,i},render(t,e,n){const s=j(t,e),o=U(t,s,e),r=B(o),{x:i,y:l,w:h,h:b}=e.plot,T=[],w=H(t),v=r?R(t):K(R(t),p(e,o),e),y=v?e.measure(v,11).w:0,S=(u,d)=>{w&&T.push({type:"text",x:u,y:d+16/2,text:v,size:11,weight:600,baseline:"middle",style:{fill:M},cls:"bc-legend-title"})};if(s.output==="size"){const u=G(s,t,e),d=u.reduce((m,f)=>Math.max(m,f.r),0),a=(m,f,A,c)=>{T.push({type:"circle",cx:m,cy:f,r:A.r,style:{fill:"none",stroke:$,strokeWidth:1},cls:"bc-legend-size"}),T.push({type:"text",x:c,y:f,text:A.label,size:11,baseline:"middle",style:{fill:M}})};if(r){const m=Math.max(2*d+6+u.reduce((c,g)=>Math.max(c,g.w),0),y)+16,f=(o==="right"?i+h+n.right:i-n.left-m)+8;S(f,l+4);let A=l+4+w;for(const c of u){const g=Math.max(2*c.r,16)+4;a(f+d,A+g/2,c,f+2*d+6),A+=g}}else{const m=q(u,p(e,o));let f=o==="top"?l-n.top-(m.reduce((A,c)=>A+c.h,0)+8+w):l+b+n.bottom+8/2;S(W(e,o,i,y),f),f+=w;for(const A of m){let c=W(e,o,i,A.items.reduce((g,D,C)=>g+(C?O:0)+N(D),0));for(const g of A.items)a(c+g.r,f+A.h/2,g,c+2*g.r+6),c+=tt(g)+O;f+=A.h}}return{axes:T}}if(!z(s)){const[u,d]=s.domain(),a=it(r,e),m=x(s,t),f=m.reduce((P,L)=>Math.max(P,e.measure(L.label,11).w),0),A=Math.max(18+f,y)+16,c=o==="right"?i+h+n.right+8:i-n.left-A+8,g=o==="top"?l-n.top-(12+e.measure("0",11).h+16+w)+8:l+b+n.bottom+8,D=g+w,C=l+4+w+(w?11/2:0);r?S(c,l+4):S(W(e,o,i,y),g);const Q=a/48*1.05;for(let P=0;P<48;P++){const L=r?d-(P+.5)/48*(d-u):u+(P+.5)/48*(d-u),V=s(L);T.push(r?{type:"rect",x:c,y:C+P*a/48,w:12,h:Q,style:{fill:V},cls:"bc-legend-bar"}:{type:"rect",x:i+P*a/48,y:D,w:Q,h:12,style:{fill:V},cls:"bc-legend-bar"})}for(const P of m)T.push(r?{type:"text",x:c+12+6,y:C+(1-P.pos)*a,text:P.label,size:11,baseline:"middle",style:{fill:M}}:{type:"text",x:i+P.pos*a,y:D+12+3,text:P.label,size:11,anchor:"middle",baseline:"hanging",style:{fill:M}});return{axes:T}}const _=F(s,e,r?1/0:p(e,o)),lt=e.toggled(String(t.scale)),J=(u,d,a)=>{T.push({type:"g",cls:"bc-legend-item",data:{"bc-legend-scale":String(t.scale),"bc-legend-index":String(a.index)},pressed:lt?!a.hidden:void 0,style:a.hidden?{opacity:.4}:void 0,title:a.label!==a.full?a.full:void 0,children:[{type:"rect",x:u,y:d+6/2,w:10,h:10,r:10/2,style:{fill:a.color},cls:"bc-legend-swatch"},{type:"text",x:u+10+6,y:d+16/2,text:a.label,size:11,baseline:"middle",style:{fill:M}}]})};if(r){const u=Math.max(16+_.reduce((a,m)=>Math.max(a,m.w),0),y)+16,d=o==="right"?i+h+n.right:i-n.left-u;S(d+8,l+4),_.forEach((a,m)=>J(d+8,l+4+w+m*16,a))}else{const u=I(_,p(e,o)),d=o==="top"?l-n.top-(u.length*16+8+w):l+b+n.bottom+8/2,a=d+w;S(W(e,o,i,y),d),u.forEach((m,f)=>{let A=W(e,o,i,m.reduce((c,g,D)=>c+(D?O:0)+Z(g),0));for(const c of m)J(A,a+f*16,c),A+=st(c)+O})}return{axes:T}}};BC.define(rt)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(j){const M="var(--bc-text, #444)",z=t=>t.output==="color"&&t.input==="category";function Y(t,e){const n=t.scale?e.scales[t.scale]:void 0;if(!n||!(n.output==="color"||n.output==="size"&&n.input==="number"))throw new Error("guide.legend needs a scale of colors, or of sizes for numbers");return n}function x(t,e,n){return C(t,e,3).filter(o=>isFinite(o.pos)&&o.pos>0).map(o=>({label:o.label,r:o.pos,w:E(o.label,n),drawn:n.textWidth(o.label,11)}))}const tt="var(--bc-label, var(--bc-text, #888))",N=t=>2*t.r+6+t.w,et=t=>2*t.r+6+t.drawn,p=(t,e)=>{const n=q(t,e);return Math.max(1,t.size.w-Math.max(8,n.left)-Math.max(8,n.right))},q=(t,e)=>e==="top"||e==="bottom"?t.edgeTaken(e):{left:0,right:0},W=(t,e,n,s)=>{const o=q(t,e);return Math.max(Math.max(8,o.left),Math.min(n,t.size.w-Math.max(8,o.right)-s))};function K(t,e){const n=[];let s=0;for(const o of t){const r=n[n.length-1];!r||r.items.length&&s+O+N(o)>e?(n.push({items:[o],h:Math.max(2*o.r,16)+4}),s=N(o)):(r.items.push(o),r.h=Math.max(r.h,Math.max(2*o.r,16)+4),s+=O+N(o))}return n}const E=(t,e)=>Math.max(e.measure(t,11).w,e.textWidth(t,11));function F(t,e,n=1/0){const s=new Set(t.domain()),o=t.range();return t.baseDomain().map((r,i)=>{const l=String(r),h=U(l,n-10-6,e);return{label:h,full:l,color:o[i],w:E(h,e),drawn:e.textWidth(h,11),hidden:!s.has(r),index:i}})}function U(t,e,n){if(!(e<1/0)||E(t,n)<=e)return t;const s=Array.from(t);let o=0,r=s.length;for(;o<r;){const i=o+r+1>>1;E(s.slice(0,i).join("")+"\u2026",n)<=e?o=i:r=i-1}return s.slice(0,o).join("").trimEnd()+"\u2026"}function C(t,e,n=4){const s=t.ticks?t.ticks(n):[];if(e.format===void 0)return s;const o=j.formatter(e.format,"number");return s.map(r=>({value:r.value,pos:r.pos,label:o(r.value)}))}const R=t=>typeof t.title=="string"&&t.title?t.title:"",H=t=>R(t)?16:0,nt=(t,e)=>R(t)?e.measure(R(t),11).w:0,ot=.2;function st(t,e){if(!z(t))return"right";const n=p(e,"top");return I(F(t,e,n),n).length<=2?"top":"right"}function k(t,e,n){const s=nt(t,n),o=H(t);if(e.output==="size"){const i=x(e,t,n),l=i.reduce((h,b)=>Math.max(h,b.r),0);return{w:Math.max(2*l+6+i.reduce((h,b)=>Math.max(h,b.w),0),s)+16,h:4+o+i.reduce((h,b)=>h+Math.max(2*b.r,16)+4,0)}}if(!z(e)){const i=C(e,t).reduce((l,h)=>Math.max(l,n.measure(h.label,11).w),0);return{w:Math.max(18+i,s)+16,h:0}}const r=F(e,n);return{w:Math.max(16+r.reduce((i,l)=>Math.max(i,l.w),0),s)+16,h:4+o+r.length*16+4}}function X(t,e,n){const s=t.position==="auto"?st(e,n):t.position||"right";if(!B(s))return s;const o=k(t,e,n);return o.w<=n.size.w*ot&&o.h<=n.size.h?s:"top"}const B=t=>t==="left"||t==="right",Z=(t,e,n)=>Math.max(e,Math.min(n,t)),O=14,J=t=>16+t.w,it=t=>16+t.drawn;function I(t,e){const n=[];let s=[],o=0;for(const r of t){const i=J(r);s.length&&o+O+i>e&&(n.push(s),s=[],o=0),o+=(s.length?O:0)+i,s.push(r)}return s.length&&n.push(s),n}function rt(t,e){return t?Z(e.plot.h*.6,80,200):Z(e.plot.w*.4,100,240)}const lt={role:"guide",type:"legend",version:16,shownOnce:!0,params:{scale:{kind:"scale",required:!0},position:{kind:"enum",values:["top","right","bottom","left","auto"],default:"right"},title:{kind:"string"},format:{kind:"format"}},measure(t,e){const n=Y(t,e),s=X(t,n,e),o=B(s),r=H(t),i={};if(n.output==="size"){const b=x(n,t,e);return i[s]=b.length?o?k(t,n,e).w:K(b,p(e,s)).reduce((T,w)=>T+w.h,0)+8+r:0,i}if(!z(n))return i[s]=o?k(t,n,e).w:12+e.measure("0",11).h+16+r,i;const l=p(e,s),h=F(n,e,o?1/0:l);return i[s]=h.length?o?k(t,n,e).w:I(h,l).length*16+8+r:0,i},render(t,e,n){const s=Y(t,e),o=X(t,s,e),r=B(o),{x:i,y:l,w:h,h:b}=e.plot,T=[],w=H(t),v=r?R(t):U(R(t),p(e,o),e),y=v?e.measure(v,11).w:0,S=(u,d)=>{w&&T.push({type:"text",x:u,y:d+16/2,text:v,size:11,weight:600,baseline:"middle",style:{fill:M},cls:"bc-legend-title"})};if(s.output==="size"){const u=x(s,t,e),d=u.reduce((m,f)=>Math.max(m,f.r),0),a=(m,f,A,c)=>{T.push({type:"circle",cx:m,cy:f,r:A.r,style:{fill:"none",stroke:tt,strokeWidth:1},cls:"bc-legend-size"}),T.push({type:"text",x:c,y:f,text:A.label,size:11,baseline:"middle",style:{fill:M}})};if(r){const m=Math.max(2*d+6+u.reduce((c,g)=>Math.max(c,g.w),0),y)+16,f=(o==="right"?i+h+n.right:i-n.left-m)+8;S(f,l+4);let A=l+4+w;for(const c of u){const g=Math.max(2*c.r,16)+4;a(f+d,A+g/2,c,f+2*d+6),A+=g}}else{const m=K(u,p(e,o));let f=o==="top"?l-n.top-(m.reduce((A,c)=>A+c.h,0)+8+w):l+b+n.bottom+8/2;S(W(e,o,i,y),f),f+=w;for(const A of m){let c=W(e,o,i,A.items.reduce((g,D,G)=>g+(G?O:0)+N(D),0));for(const g of A.items)a(c+g.r,f+A.h/2,g,c+2*g.r+6),c+=et(g)+O;f+=A.h}}return{axes:T}}if(!z(s)){const[u,d]=s.domain(),a=rt(r,e),m=C(s,t),f=m.reduce((P,L)=>Math.max(P,e.measure(L.label,11).w),0),A=Math.max(18+f,y)+16,c=o==="right"?i+h+n.right+8:i-n.left-A+8,g=o==="top"?l-n.top-(12+e.measure("0",11).h+16+w)+8:l+b+n.bottom+8,D=g+w,G=l+4+w+(w?11/2:0);r?S(c,l+4):S(W(e,o,i,y),g);const V=a/48*1.05;for(let P=0;P<48;P++){const L=r?d-(P+.5)/48*(d-u):u+(P+.5)/48*(d-u),$=s(L);T.push(r?{type:"rect",x:c,y:G+P*a/48,w:12,h:V,style:{fill:$},cls:"bc-legend-bar"}:{type:"rect",x:i+P*a/48,y:D,w:V,h:12,style:{fill:$},cls:"bc-legend-bar"})}for(const P of m)T.push(r?{type:"text",x:c+12+6,y:G+(1-P.pos)*a,text:P.label,size:11,baseline:"middle",style:{fill:M}}:{type:"text",x:i+P.pos*a,y:D+12+3,text:P.label,size:11,anchor:"middle",baseline:"hanging",style:{fill:M}});return{axes:T}}const _=F(s,e,r?1/0:p(e,o)),at=e.toggled(String(t.scale)),Q=(u,d,a)=>{T.push({type:"g",cls:"bc-legend-item",data:{"bc-legend-scale":String(t.scale),"bc-legend-index":String(a.index)},pressed:at?!a.hidden:void 0,style:a.hidden?{opacity:.4}:void 0,title:a.label!==a.full?a.full:void 0,children:[{type:"rect",x:u,y:d+6/2,w:10,h:10,r:10/2,style:{fill:a.color},cls:"bc-legend-swatch"},{type:"text",x:u+10+6,y:d+16/2,text:a.label,size:11,baseline:"middle",style:{fill:M}}]})};if(r){const u=Math.max(16+_.reduce((a,m)=>Math.max(a,m.w),0),y)+16,d=o==="right"?i+h+n.right:i-n.left-u;S(d+8,l+4),_.forEach((a,m)=>Q(d+8,l+4+w+m*16,a))}else{const u=I(_,p(e,o)),d=o==="top"?l-n.top-(u.length*16+8+w):l+b+n.bottom+8/2,a=d+w;S(W(e,o,i,y),d),u.forEach((m,f)=>{let A=W(e,o,i,m.reduce((c,g,D)=>c+(D?O:0)+J(g),0));for(const c of m)Q(A,a+f*16,c),A+=it(c)+O})}return{axes:T}}};j.define(lt)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const d=typeof WeakMap=="function"?new WeakMap:null,l=()=>typeof performance=="object"&&performance&&typeof performance.now=="function"?performance.now():Date.now();function m(t){const e=BC.get(`mark.${t.type}`);return e&&e.enter}function x(t){const e=t.marks.map(m);return e.indexOf("pop")>=0?"pop":e.indexOf("grow")>=0&&e.indexOf("wipe")<0?"grow":e.indexOf("wipe")>=0?"wipe":"fade"}function b(t){const e=t.spec.marks.find(r=>m(r)==="grow");let a=!1;if(e)try{const r=t.channel(e,"y");a=!!(r.scale&&r.scale.bandwidth!==void 0)}catch{a=!1}const n=t.plot,i=a?t.scales.x:t.scales.y,o=i&&i.input==="number"?i(0):NaN;return a?{horizontal:a,at:isFinite(o)&&o>=n.x&&o<=n.x+n.w?o:n.x}:{horizontal:a,at:isFinite(o)&&o>=n.y&&o<=n.y+n.h?o:n.y+n.h}}const g={role:"interaction",type:"animate",version:4,params:{effect:{kind:"enum",values:["auto","grow","wipe","pop","fade"],default:"auto"},duration:{kind:"number",default:700},delay:{kind:"number",default:0}},attach(t,e){const a=e.root;let n=0;const i=d?d.get(e.host):void 0;i!==void 0?n=Math.max(0,l()-i):d&&d.set(e.host,l());const o=e.host.ownerDocument&&e.host.ownerDocument.defaultView||(typeof window<"u"?window:void 0);if(o&&typeof o.matchMedia=="function"&&o.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=typeof t.duration=="number"&&t.duration>=0?Math.min(1e4,t.duration):700,y=typeof t.delay=="number"&&t.delay>=0?Math.min(1e4,t.delay):0,k={duration:r,delay:y,easing:"cubic-bezier(.2,.7,.2,1)",fill:"backwards"};if(i!==void 0&&n>=y+r)return;const p=t.effect==="grow"||t.effect==="wipe"||t.effect==="pop"||t.effect==="fade"?t.effect:x(e.spec),s=typeof a.querySelector=="function"?a.querySelector('[data-bc-layer="marks"]'):null,w=s||a;if(typeof w.animate!="function")return;const f=e.plot;let u;if(!s||p==="fade")u=[{opacity:0},{opacity:1}];else if(p==="wipe"){const c=e.size.w-(f.x+f.w);u=[{clipPath:`inset(0 ${e.size.w-f.x}px 0 0)`},{clipPath:`inset(0 ${Math.max(0,c-4)}px 0 0)`,offset:.999},{clipPath:"none"}]}else if(p==="pop")s.style.transformBox="view-box",s.style.transformOrigin=`${f.x+f.w/2}px ${f.y+f.h/2}px`,u=[{transform:"scale(0.6) rotate(-30deg)",opacity:0},{transform:"none",opacity:1}];else{const c=b(e);s.style.transformBox="view-box",s.style.transformOrigin=c.horizontal?`${c.at}px 0px`:`0px ${c.at}px`,u=[{transform:c.horizontal?"scaleX(0)":"scaleY(0)"},{transform:"none"}]}const h=w.animate(u,k);n>0&&(h.currentTime=n),e.cleanup(()=>{try{h.cancel()}catch{}})}};BC.define(g)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(l){const d=typeof WeakMap=="function"?new WeakMap:null,m=()=>typeof performance=="object"&&performance&&typeof performance.now=="function"?performance.now():Date.now();function y(t){const e=l.get(`mark.${t.type}`);return e&&e.enter}function b(t){const e=t.marks.map(y);return e.indexOf("pop")>=0?"pop":e.indexOf("grow")>=0&&e.indexOf("wipe")<0?"grow":e.indexOf("wipe")>=0?"wipe":"fade"}function g(t){const e=t.spec.marks.find(r=>y(r)==="grow");let a=!1;if(e)try{const r=t.channel(e,"y");a=!!(r.scale&&r.scale.bandwidth!==void 0)}catch{a=!1}const n=t.plot,i=a?t.scales.x:t.scales.y,o=i&&i.input==="number"?i(0):NaN;return a?{horizontal:a,at:isFinite(o)&&o>=n.x&&o<=n.x+n.w?o:n.x}:{horizontal:a,at:isFinite(o)&&o>=n.y&&o<=n.y+n.h?o:n.y+n.h}}const k={role:"interaction",type:"animate",version:4,params:{effect:{kind:"enum",values:["auto","grow","wipe","pop","fade"],default:"auto"},duration:{kind:"number",default:700},delay:{kind:"number",default:0}},attach(t,e){const a=e.root;let n=0;const i=d?d.get(e.host):void 0;i!==void 0?n=Math.max(0,m()-i):d&&d.set(e.host,m());const o=e.host.ownerDocument&&e.host.ownerDocument.defaultView||(typeof window<"u"?window:void 0);if(o&&typeof o.matchMedia=="function"&&o.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=typeof t.duration=="number"&&t.duration>=0?Math.min(1e4,t.duration):700,w=typeof t.delay=="number"&&t.delay>=0?Math.min(1e4,t.delay):0,M={duration:r,delay:w,easing:"cubic-bezier(.2,.7,.2,1)",fill:"backwards"};if(i!==void 0&&n>=w+r)return;const p=t.effect==="grow"||t.effect==="wipe"||t.effect==="pop"||t.effect==="fade"?t.effect:b(e.spec),s=typeof a.querySelector=="function"?a.querySelector('[data-bc-layer="marks"]'):null,h=s||a;if(typeof h.animate!="function")return;const f=e.plot;let u;if(!s||p==="fade")u=[{opacity:0},{opacity:1}];else if(p==="wipe"){const c=e.size.w-(f.x+f.w);u=[{clipPath:`inset(0 ${e.size.w-f.x}px 0 0)`},{clipPath:`inset(0 ${Math.max(0,c-4)}px 0 0)`,offset:.999},{clipPath:"none"}]}else if(p==="pop")s.style.transformBox="view-box",s.style.transformOrigin=`${f.x+f.w/2}px ${f.y+f.h/2}px`,u=[{transform:"scale(0.6) rotate(-30deg)",opacity:0},{transform:"none",opacity:1}];else{const c=g(e);s.style.transformBox="view-box",s.style.transformOrigin=c.horizontal?`${c.at}px 0px`:`0px ${c.at}px`,u=[{transform:c.horizontal?"scaleX(0)":"scaleY(0)"},{transform:"none"}]}const x=h.animate(u,M);n>0&&(x.currentTime=n),e.cleanup(()=>{try{x.cancel()}catch{}})}};l.define(k)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const k=()=>BC.get("lib.pointer").exports,R="bc-brush",j={role:"interaction",type:"brush",version:5,requires:["lib.pointer"],params:{scales:{kind:"list",default:["x"]},modifier:{kind:"enum",values:["shift","alt","ctrl","none"],default:"shift"},fit:{kind:"list"},minSize:{kind:"number",default:6}},attach(s,e){const a=(Array.isArray(s.scales)?s.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const n=e.scales[t],o=!!n&&e.orientation(t)!==null&&(!!n.invert||n.bandwidth!==void 0);return o||console.warn(`[blockcharts] interaction.brush: scale "${t}" is not a positional scale that can be selected on, ignored`),o});if(!a.length)return;const E=(Array.isArray(s.fit)?s.fit:[]).filter(t=>{const n=typeof t=="string"&&!!e.scales[t]&&a.indexOf(t)<0;return!n&&typeof t=="string"&&console.warn(`[blockcharts] interaction.brush: cannot fit scale "${t}"`),n}),h=s.modifier==="alt"||s.modifier==="ctrl"||s.modifier==="none"?s.modifier:"shift",L=typeof s.minSize=="number"&&s.minSize>=0?s.minSize:6,r=e.root,y=e.host,p=y.ownerDocument||document,g=a.some(t=>e.orientation(t)==="horizontal"),w=a.some(t=>e.orientation(t)==="vertical");let u=null;const m=t=>k().toLogical(e,t),z=t=>k().inPlot(e,t),M=t=>{const n=e.plot;return{x:Math.max(n.x,Math.min(n.x+n.w,t.x)),y:Math.max(n.y,Math.min(n.y+n.h,t.y))}},C=t=>h==="none"||(h==="shift"?t.shiftKey:h==="alt"?t.altKey:t.ctrlKey||t.metaKey);e.claimDrag(C);let i=null;const S=t=>{const n=e.plot;return{x0:g?Math.min(t.x0,t.x1):n.x,x1:g?Math.max(t.x0,t.x1):n.x+n.w,y0:w?Math.min(t.y0,t.y1):n.y,y1:w?Math.max(t.y0,t.y1):n.y+n.h}},v=()=>{if(!i)return;const t=S(i),n=r.getBoundingClientRect(),o=y.getBoundingClientRect(),c=n.width/e.size.w;Object.assign(i.box.style,{left:n.left-o.left+t.x0*c+"px",top:n.top-o.top+t.y0*c+"px",width:(t.x1-t.x0)*c+"px",height:(t.y1-t.y0)*c+"px"})},x=()=>{i&&(i.box.parentNode&&i.box.parentNode.removeChild(i.box),i=null,p.removeEventListener("keydown",A),u&&(u(),u=null))},I=t=>{if(!(g&&t.x1-t.x0<L)&&!(w&&t.y1-t.y0<L)){for(const n of a){const o=e.scales[n],c=e.orientation(n)==="horizontal"?t.x0:t.y0,N=e.orientation(n)==="horizontal"?t.x1:t.y1;if(o.invert){const b=Number(o.invert(c)),f=Number(o.invert(N)),d=Math.min(b,f),l=Math.max(b,f),[O,q]=o.baseDomain(),$=q<O?[l,d]:[d,l];e.setView(n,l-d>=Math.abs(q-O)*(1-1e-9)?null:$)}else{const b=o.bandwidth,f=o.domain().filter(d=>{const l=o(d);return isFinite(l)&&l+b>=c&&l<=N});if(!f.length)continue;e.setView(n,f.length===o.baseDomain().length?null:f)}}for(const n of E)e.setView(n,e.fit(n,a[0]))}},A=t=>{t.key==="Escape"&&x()},D=t=>{if(t.button!==0||!C(t))return;const n=m(t);if(!z(n))return;const o=p.createElement("div");o.setAttribute("class",R),Object.assign(o.style,{position:"absolute",pointerEvents:"none",boxSizing:"border-box",zIndex:"5",background:"var(--bc-brush-fill, rgba(78,121,167,.22))",border:"1px solid var(--bc-brush-line, rgba(78,121,167,.9))"}),u=e.claimPosition(),y.appendChild(o),i={x0:n.x,y0:n.y,x1:n.x,y1:n.y,box:o},r.setPointerCapture&&r.setPointerCapture(t.pointerId),p.addEventListener("keydown",A),v(),t.preventDefault()},P=t=>{if(!i)return;const n=M(m(t));i.x1=n.x,i.y1=n.y,v()},V=t=>{if(!i)return;const n=M(m(t));i.x1=n.x,i.y1=n.y;const o=S(i);x(),I(o)},B=()=>x(),K=t=>{if(z(m(t))){for(const n of a)e.setView(n,null);for(const n of E)e.setView(n,e.fit(n,a[0]))}};r.addEventListener("pointerdown",D),r.addEventListener("pointermove",P),r.addEventListener("pointerup",V),r.addEventListener("pointercancel",B),r.addEventListener("dblclick",K),e.cleanup(()=>{x(),r.removeEventListener("pointerdown",D),r.removeEventListener("pointermove",P),r.removeEventListener("pointerup",V),r.removeEventListener("pointercancel",B),r.removeEventListener("dblclick",K)})}};BC.define(j)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(k){const E=()=>k.get("lib.pointer").exports,j="bc-brush",I={role:"interaction",type:"brush",version:5,requires:["lib.pointer"],params:{scales:{kind:"list",default:["x"]},modifier:{kind:"enum",values:["shift","alt","ctrl","none"],default:"shift"},fit:{kind:"list"},minSize:{kind:"number",default:6}},attach(s,e){const a=(Array.isArray(s.scales)?s.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const n=e.scales[t],o=!!n&&e.orientation(t)!==null&&(!!n.invert||n.bandwidth!==void 0);return o||console.warn(`[blockcharts] interaction.brush: scale "${t}" is not a positional scale that can be selected on, ignored`),o});if(!a.length)return;const L=(Array.isArray(s.fit)?s.fit:[]).filter(t=>{const n=typeof t=="string"&&!!e.scales[t]&&a.indexOf(t)<0;return!n&&typeof t=="string"&&console.warn(`[blockcharts] interaction.brush: cannot fit scale "${t}"`),n}),h=s.modifier==="alt"||s.modifier==="ctrl"||s.modifier==="none"?s.modifier:"shift",z=typeof s.minSize=="number"&&s.minSize>=0?s.minSize:6,r=e.root,y=e.host,p=y.ownerDocument||document,g=a.some(t=>e.orientation(t)==="horizontal"),w=a.some(t=>e.orientation(t)==="vertical");let u=null;const m=t=>E().toLogical(e,t),M=t=>E().inPlot(e,t),C=t=>{const n=e.plot;return{x:Math.max(n.x,Math.min(n.x+n.w,t.x)),y:Math.max(n.y,Math.min(n.y+n.h,t.y))}},S=t=>h==="none"||(h==="shift"?t.shiftKey:h==="alt"?t.altKey:t.ctrlKey||t.metaKey);e.claimDrag(S);let i=null;const v=t=>{const n=e.plot;return{x0:g?Math.min(t.x0,t.x1):n.x,x1:g?Math.max(t.x0,t.x1):n.x+n.w,y0:w?Math.min(t.y0,t.y1):n.y,y1:w?Math.max(t.y0,t.y1):n.y+n.h}},A=()=>{if(!i)return;const t=v(i),n=r.getBoundingClientRect(),o=y.getBoundingClientRect(),c=n.width/e.size.w;Object.assign(i.box.style,{left:n.left-o.left+t.x0*c+"px",top:n.top-o.top+t.y0*c+"px",width:(t.x1-t.x0)*c+"px",height:(t.y1-t.y0)*c+"px"})},b=()=>{i&&(i.box.parentNode&&i.box.parentNode.removeChild(i.box),i=null,p.removeEventListener("keydown",D),u&&(u(),u=null))},T=t=>{if(!(g&&t.x1-t.x0<z)&&!(w&&t.y1-t.y0<z)){for(const n of a){const o=e.scales[n],c=e.orientation(n)==="horizontal"?t.x0:t.y0,q=e.orientation(n)==="horizontal"?t.x1:t.y1;if(o.invert){const x=Number(o.invert(c)),f=Number(o.invert(q)),d=Math.min(x,f),l=Math.max(x,f),[B,R]=o.baseDomain(),$=R<B?[l,d]:[d,l];e.setView(n,l-d>=Math.abs(R-B)*(1-1e-9)?null:$)}else{const x=o.bandwidth,f=o.domain().filter(d=>{const l=o(d);return isFinite(l)&&l+x>=c&&l<=q});if(!f.length)continue;e.setView(n,f.length===o.baseDomain().length?null:f)}}for(const n of L)e.setView(n,e.fit(n,a[0]))}},D=t=>{t.key==="Escape"&&b()},P=t=>{if(t.button!==0||!S(t))return;const n=m(t);if(!M(n))return;const o=p.createElement("div");o.setAttribute("class",j),Object.assign(o.style,{position:"absolute",pointerEvents:"none",boxSizing:"border-box",zIndex:"5",background:"var(--bc-brush-fill, rgba(78,121,167,.22))",border:"1px solid var(--bc-brush-line, rgba(78,121,167,.9))"}),u=e.claimPosition(),y.appendChild(o),i={x0:n.x,y0:n.y,x1:n.x,y1:n.y,box:o},r.setPointerCapture&&r.setPointerCapture(t.pointerId),p.addEventListener("keydown",D),A(),t.preventDefault()},V=t=>{if(!i)return;const n=C(m(t));i.x1=n.x,i.y1=n.y,A()},K=t=>{if(!i)return;const n=C(m(t));i.x1=n.x,i.y1=n.y;const o=v(i);b(),T(o)},N=()=>b(),O=t=>{if(M(m(t))){for(const n of a)e.setView(n,null);for(const n of L)e.setView(n,e.fit(n,a[0]))}};r.addEventListener("pointerdown",P),r.addEventListener("pointermove",V),r.addEventListener("pointerup",K),r.addEventListener("pointercancel",N),r.addEventListener("dblclick",O),e.cleanup(()=>{b(),r.removeEventListener("pointerdown",P),r.removeEventListener("pointermove",V),r.removeEventListener("pointerup",K),r.removeEventListener("pointercancel",N),r.removeEventListener("dblclick",O)})}};k.define(I)})(globalThis.BC);
3
3
 
@@ -0,0 +1,3 @@
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(p){const x=["bc-mark","bc-row","bc-layer"],s=()=>p.get("lib.pointer").exports,L={role:"interaction",type:"click",version:1,requires:["lib.pointer"],events:["bc-click"],params:{cursor:{kind:"boolean",default:!0}},attach(O,o){const c=o.root,u=o.host,g=u.ownerDocument||document,C=t=>{const n=o.dataAt(t);return!!n&&Object.keys(n).some(l=>x.indexOf(l)<0)},w=t=>{const n=s().toLogical(o,t);return!s().inPlot(o,n,12)||C(t)?null:s().pickAt(o,n)};let a=null;const b=t=>{a={x:t.clientX,y:t.clientY}},m=t=>{const n=a;if(a=null,t.detail>1||n&&Math.hypot(t.clientX-n.x,t.clientY-n.y)>4)return;const l=w(t);if(!l)return;const{pick:e,mark:D,index:A}=l,d=o.table,y={};for(const E of Object.keys(d.columns))y[E]=d.columns[E][e.row];const P={row:e.row,rows:e.rows&&e.rows.length?e.rows.slice():[e.row],values:y,mark:D,markIndex:A,x:e.x,y:e.y,table:d,event:t},h=g.defaultView||globalThis;typeof h.CustomEvent!="function"||typeof u.dispatchEvent!="function"||u.dispatchEvent(new h.CustomEvent("bc-click",{bubbles:!0,detail:P}))};c.addEventListener("pointerdown",b),c.addEventListener("click",m);let i=!1,k="";const r=c.style,f=()=>{i&&r.cursor==="pointer"&&(r.cursor=k),i=!1};O.cursor!==!1&&r&&s().follow(o,t=>{if(!w(t))return f();i||r.cursor==="pointer"||(k=r.cursor||"",r.cursor="pointer",i=!0)},f,!0),o.cleanup(()=>{c.removeEventListener("pointerdown",b),c.removeEventListener("click",m),f()})}};p.define(L)})(globalThis.BC);
3
+
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const y=()=>BC.get("lib.pointer").exports,C=(r,t,f,x)=>BC.get("lib.pointer").exports.follow(r,t,f,x);function B(r){const t=BC.get(`mark.${r.type}`);return!!(t&&t.series)}const j={role:"interaction",type:"crosshair",version:6,requires:["lib.pointer"],alongX:!0,params:{snap:{kind:"enum",values:["lines","all","off"],default:"lines"},horizontal:{kind:"boolean",default:!1}},attach(r,t){const f=t.host,x=t.root,z=f.ownerDocument||document,E=t.claimPosition(),g=r.snap==="all"||r.snap==="off"?r.snap:"lines",m=(e,s)=>{const n=z.createElement("div");return n.setAttribute("class",e),Object.assign(n.style,s?{position:"absolute",display:"none",pointerEvents:"none",width:"0",marginLeft:"-0.5px",borderLeft:"1px dashed var(--bc-crosshair, var(--bc-axis, #999))"}:{position:"absolute",display:"none",pointerEvents:"none",height:"0",marginTop:"-0.5px",borderTop:"1px dashed var(--bc-crosshair, var(--bc-axis, #999))"}),f.appendChild(n),n},b=m("bc-crosshair",!0),d=r.horizontal===!0?m("bc-crosshair-h",!1):null,u=()=>{b.style.display="none",d&&(d.style.display="none")},L=(e,s)=>{let n=null;for(const o of t.spec.marks){if(g==="lines"&&!B(o))continue;let p,a=null,l=0;try{const i=t.channel(o,"x");if(!i.scale)continue;p=i.mapped,l=i.half;const c=t.channel(o,"y");c.scale&&(a=c.mapped)}catch{continue}const{from:h,to:O}=t.rows(o),{x:w,w:F}=t.plot;for(let i=h;i<O;i++){const c=p[i]+l;if(!isFinite(c)||c<w-.5||c>w+F+.5)continue;const k=Math.abs(c-e);(!n||k<n.d)&&(n={x:c,y:a&&isFinite(a[i])?a[i]:s,d:k})}}return n};C(t,e=>{const s=x.getBoundingClientRect(),n=f.getBoundingClientRect();if(!s.width)return u();const o=s.width/t.size.w,{x:p,y:a}=y().toLogical(t,e),l=t.plot;if(!y().inPlot(t,{x:p,y:a}))return u();const h=g==="off"?{x:p,y:a}:L(p,a);if(!h)return u();Object.assign(b.style,{left:s.left-n.left+h.x*o+"px",top:s.top-n.top+l.y*o+"px",height:l.h*o+"px",display:"block"}),d&&Object.assign(d.style,{top:s.top-n.top+h.y*o+"px",left:s.left-n.left+l.x*o+"px",width:l.w*o+"px",display:"block"})},u,!0),t.cleanup(()=>{for(const e of[b,d])e&&e.parentNode&&e.parentNode.removeChild(e);E()})}};BC.define(j)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(u){const g=()=>u.get("lib.pointer").exports,z=(r,t,f,b)=>u.get("lib.pointer").exports.follow(r,t,f,b);function E(r){const t=u.get(`mark.${r.type}`);return!!(t&&t.series)}const L={role:"interaction",type:"crosshair",version:6,requires:["lib.pointer"],alongX:!0,params:{snap:{kind:"enum",values:["lines","all","off"],default:"lines"},horizontal:{kind:"boolean",default:!1}},attach(r,t){const f=t.host,b=t.root,O=f.ownerDocument||document,T=t.claimPosition(),m=r.snap==="all"||r.snap==="off"?r.snap:"lines",w=(e,s)=>{const o=O.createElement("div");return o.setAttribute("class",e),Object.assign(o.style,s?{position:"absolute",display:"none",pointerEvents:"none",width:"0",marginLeft:"-0.5px",borderLeft:"1px dashed var(--bc-crosshair, var(--bc-axis, #999))"}:{position:"absolute",display:"none",pointerEvents:"none",height:"0",marginTop:"-0.5px",borderTop:"1px dashed var(--bc-crosshair, var(--bc-axis, #999))"}),f.appendChild(o),o},y=w("bc-crosshair",!0),d=r.horizontal===!0?w("bc-crosshair-h",!1):null,x=()=>{y.style.display="none",d&&(d.style.display="none")},C=(e,s)=>{let o=null;for(const n of t.spec.marks){if(m==="lines"&&!E(n))continue;let p,a=null,l=0;try{const i=t.channel(n,"x");if(!i.scale)continue;p=i.mapped,l=i.half;const c=t.channel(n,"y");c.scale&&(a=c.mapped)}catch{continue}const{from:h,to:F}=t.rows(n),{x:k,w:N}=t.plot;for(let i=h;i<F;i++){const c=p[i]+l;if(!isFinite(c)||c<k-.5||c>k+N+.5)continue;const j=Math.abs(c-e);(!o||j<o.d)&&(o={x:c,y:a&&isFinite(a[i])?a[i]:s,d:j})}}return o};z(t,e=>{const s=b.getBoundingClientRect(),o=f.getBoundingClientRect();if(!s.width)return x();const n=s.width/t.size.w,{x:p,y:a}=g().toLogical(t,e),l=t.plot;if(!g().inPlot(t,{x:p,y:a}))return x();const h=m==="off"?{x:p,y:a}:C(p,a);if(!h)return x();Object.assign(y.style,{left:s.left-o.left+h.x*n+"px",top:s.top-o.top+l.y*n+"px",height:l.h*n+"px",display:"block"}),d&&Object.assign(d.style,{top:s.top-o.top+h.y*n+"px",left:s.left-o.left+l.x*n+"px",width:l.w*n+"px",display:"block"})},x,!0),t.cleanup(()=>{for(const e of[y,d])e&&e.parentNode&&e.parentNode.removeChild(e);T()})}};u.define(L)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const x="bc-legend-scale",O="bc-legend-index",K="bc-legend-filter",A=s=>s.output==="color"&&s.input==="category",E=(s,o,a)=>{const l=(o.guides||[]).find(m=>typeof m.scale=="string"&&!!a[m.scale]&&A(a[m.scale])),d=typeof s.scale=="string"?s.scale:l?l.scale:void 0;return d&&a[d]&&A(a[d])?d:void 0},S=s=>s.key==="Enter"||s.key===" "||s.key==="Spacebar",I={role:"interaction",type:"legend-filter",version:6,outerLegend:!0,params:{scale:{kind:"scale"},legend:{kind:"string"},fit:{kind:"list"}},toggles:(s,o)=>typeof s.legend=="string"?void 0:E(s,o.spec,o.scales),attach(s,o){const a=typeof s.legend=="string"?s.legend:null,l=E(s,o.spec,o.scales),d=l?o.scales[l]:void 0;if(!l||!d){console.warn('[blockcharts] interaction.legend-filter: needs a categorical color scale (set "scale", or add a legend guide for one); ignored');return}const m=(Array.isArray(s.fit)?s.fit:[]).filter(t=>{const e=typeof t=="string"&&!!o.scales[t]&&t!==l;return!e&&typeof t=="string"&&console.warn(`[blockcharts] interaction.legend-filter: cannot fit scale "${t}"`),e}),i=o.root,c=d.baseDomain(),T=o.host.ownerDocument||document,f=a?T.getElementById(a):null;if(a&&!f)return;const k=()=>o.getView()[l],h=t=>{o.setView(l,t.length===0||t.length===c.length?null:t);for(const e of m)o.setView(e,o.fit(e,l));if(f){const e=t.length?t:c;f.querySelectorAll("[data-bc-legend-index]").forEach(n=>{const r=e.indexOf(c[Number(n.getAttribute("data-bc-legend-index"))])>=0;n.setAttribute("aria-pressed",r?"true":"false")})}},p=t=>{if(f){const r=t.target?.closest?.("[data-bc-legend-index]"),u=r?Number(r.getAttribute("data-bc-legend-index")):NaN;return Number.isInteger(u)&&u>=0&&u<c.length?{value:c[u]}:null}const e=o.dataAt(t);if(!e||e[x]!==l)return null;const n=Number(e[O]);return Number.isInteger(n)&&n>=0&&n<c.length?{value:c[n]}:null};let g=null;const v=t=>{if(t.detail>1)return;const e=p(t);if(!e)return;const n=k();g={shown:n.slice(),at:Date.now()},h(c.filter(r=>r===e.value?n.indexOf(r)<0:n.indexOf(r)>=0))},L=t=>{const e=p(t);if(!e)return;t.preventDefault();const n=g&&Date.now()-g.at<700?g.shown:k();g=null,h(n.length===1&&n[0]===e.value?c.slice():[e.value])},C=t=>{const e=t;if(!S(e)||e.altKey||e.ctrlKey||e.metaKey)return;const n=p(t);if(!n||(t.preventDefault(),e.repeat))return;const r=k();g=null,e.shiftKey?h(r.length===1&&r[0]===n.value?c.slice():[n.value]):h(c.filter(u=>u===n.value?r.indexOf(u)<0:r.indexOf(u)>=0))},b=f||i;b.addEventListener("click",v),b.addEventListener("dblclick",L),b.addEventListener("keydown",C);let y=null;const N=t=>{const e=i.style,n=!!p(t);n&&y===null?(y=e.cursor,e.cursor="pointer"):!n&&y!==null&&(e.cursor=y,y=null)},D=!f&&typeof i.getContext=="function";D&&i.addEventListener("pointermove",N);const w=i.getAttribute("class");i.setAttribute("class",((w||"")+" "+K).trim()),o.cleanup(()=>{b.removeEventListener("click",v),b.removeEventListener("dblclick",L),b.removeEventListener("keydown",C),D&&i.removeEventListener("pointermove",N),w===null?i.removeAttribute?i.removeAttribute("class"):i.setAttribute("class",""):i.setAttribute("class",w)})}};BC.define(I)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(x){const O="bc-legend-scale",K="bc-legend-index",S="bc-legend-filter",A=s=>s.output==="color"&&s.input==="category",E=(s,o,a)=>{const l=(o.guides||[]).find(m=>typeof m.scale=="string"&&!!a[m.scale]&&A(a[m.scale])),d=typeof s.scale=="string"?s.scale:l?l.scale:void 0;return d&&a[d]&&A(a[d])?d:void 0},T=s=>s.key==="Enter"||s.key===" "||s.key==="Spacebar",I={role:"interaction",type:"legend-filter",version:6,outerLegend:!0,params:{scale:{kind:"scale"},legend:{kind:"string"},fit:{kind:"list"}},toggles:(s,o)=>typeof s.legend=="string"?void 0:E(s,o.spec,o.scales),attach(s,o){const a=typeof s.legend=="string"?s.legend:null,l=E(s,o.spec,o.scales),d=l?o.scales[l]:void 0;if(!l||!d){console.warn('[blockcharts] interaction.legend-filter: needs a categorical color scale (set "scale", or add a legend guide for one); ignored');return}const m=(Array.isArray(s.fit)?s.fit:[]).filter(t=>{const e=typeof t=="string"&&!!o.scales[t]&&t!==l;return!e&&typeof t=="string"&&console.warn(`[blockcharts] interaction.legend-filter: cannot fit scale "${t}"`),e}),i=o.root,c=d.baseDomain(),V=o.host.ownerDocument||document,f=a?V.getElementById(a):null;if(a&&!f)return;const k=()=>o.getView()[l],h=t=>{o.setView(l,t.length===0||t.length===c.length?null:t);for(const e of m)o.setView(e,o.fit(e,l));if(f){const e=t.length?t:c;f.querySelectorAll("[data-bc-legend-index]").forEach(n=>{const r=e.indexOf(c[Number(n.getAttribute("data-bc-legend-index"))])>=0;n.setAttribute("aria-pressed",r?"true":"false")})}},p=t=>{if(f){const r=t.target?.closest?.("[data-bc-legend-index]"),u=r?Number(r.getAttribute("data-bc-legend-index")):NaN;return Number.isInteger(u)&&u>=0&&u<c.length?{value:c[u]}:null}const e=o.dataAt(t);if(!e||e[O]!==l)return null;const n=Number(e[K]);return Number.isInteger(n)&&n>=0&&n<c.length?{value:c[n]}:null};let g=null;const v=t=>{if(t.detail>1)return;const e=p(t);if(!e)return;const n=k();g={shown:n.slice(),at:Date.now()},h(c.filter(r=>r===e.value?n.indexOf(r)<0:n.indexOf(r)>=0))},L=t=>{const e=p(t);if(!e)return;t.preventDefault();const n=g&&Date.now()-g.at<700?g.shown:k();g=null,h(n.length===1&&n[0]===e.value?c.slice():[e.value])},C=t=>{const e=t;if(!T(e)||e.altKey||e.ctrlKey||e.metaKey)return;const n=p(t);if(!n||(t.preventDefault(),e.repeat))return;const r=k();g=null,e.shiftKey?h(r.length===1&&r[0]===n.value?c.slice():[n.value]):h(c.filter(u=>u===n.value?r.indexOf(u)<0:r.indexOf(u)>=0))},b=f||i;b.addEventListener("click",v),b.addEventListener("dblclick",L),b.addEventListener("keydown",C);let y=null;const N=t=>{const e=i.style,n=!!p(t);n&&y===null?(y=e.cursor,e.cursor="pointer"):!n&&y!==null&&(e.cursor=y,y=null)},D=!f&&typeof i.getContext=="function";D&&i.addEventListener("pointermove",N);const w=i.getAttribute("class");i.setAttribute("class",((w||"")+" "+S).trim()),o.cleanup(()=>{b.removeEventListener("click",v),b.removeEventListener("dblclick",L),b.removeEventListener("keydown",C),D&&i.removeEventListener("pointermove",N),w===null?i.removeAttribute?i.removeAttribute("class"):i.setAttribute("class",""):i.setAttribute("class",w)})}};x.define(I)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const ut=i=>i==null||i===""||typeof i=="number"&&isNaN(i),ht=/\d|[a-z][A-Z]|_/;function bt(i){if(i==null)return"\u2013";if(typeof i=="number")return isNaN(i)?"\u2013":Number.isInteger(i)?String(i):String(+i.toPrecision(6));const o=String(i);return o.length>80?o.slice(0,79)+"\u2026":o}const U=()=>BC.get("lib.pointer").exports,gt=(i,o,S,P)=>BC.get("lib.pointer").exports.follow(i,o,S,P),yt={role:"interaction",type:"tooltip",version:23,requires:["lib.pointer"],params:{fields:{kind:"fields"},formats:{kind:"formats"},labels:{kind:"any"},content:{kind:"any"},heading:{kind:"field"},marker:{kind:"enum",values:["auto","dot","box","none"],default:"auto"}},attach(i,o){const S=o.host,P=o.root,u=S.ownerDocument||document,D={};if(i.formats&&typeof i.formats=="object"&&!Array.isArray(i.formats)){const t=i.formats;for(const n of Object.keys(t))try{D[n]=o.format(t[n])}catch(r){console.warn(`[blockcharts] interaction.tooltip: format of "${n}" ignored: ${r instanceof Error?r.message:String(r)}`)}}else i.formats!==void 0&&console.warn('[blockcharts] interaction.tooltip: "formats" must be an object of field name to format; ignored');const Y=o.format("date"),W={};for(const t of Array.isArray(o.spec.transforms)?o.spec.transforms:[]){const n=t&&BC.get(`transform.${t.type}`);if(!(!n||typeof n.labels!="function"))try{Object.assign(W,n.labels(t))}catch{}}if(i.labels&&typeof i.labels=="object"&&!Array.isArray(i.labels)){const t=i.labels;for(const n of Object.keys(t))o.table.columns[n]?typeof t[n]!="string"?console.warn(`[blockcharts] interaction.tooltip: label of "${n}" must be text; ignored`):W[n]=t[n]:console.warn(`[blockcharts] interaction.tooltip: label of "${n}" ignored: no such field`)}else i.labels!==void 0&&console.warn('[blockcharts] interaction.tooltip: "labels" must be an object of field name to text; ignored');const X=Array.isArray(i.fields)?i.fields.filter(t=>typeof t=="string"):null,mt=o.claimPosition(),a=u.createElement("div");a.setAttribute("class","bc-tooltip"),a.setAttribute("role","tooltip"),Object.assign(a.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"10",boxSizing:"border-box",whiteSpace:"normal",overflowWrap:"anywhere",fontSize:"12px",lineHeight:"1.45",fontVariantNumeric:"tabular-nums",padding:"8px 11px",borderRadius:"10px",background:"var(--bc-tooltip-bg, #fff)",color:"var(--bc-text, #333)",border:"1px solid var(--bc-tooltip-border, rgba(127,127,127,.22))",boxShadow:"var(--bc-tooltip-shadow, 0 10px 28px rgba(15,23,42,.14), 0 2px 6px rgba(15,23,42,.08))"});const b=u.createElement("div");b.setAttribute("class","bc-tooltip-dot"),Object.assign(b.style,{position:"absolute",display:"none",pointerEvents:"none",width:"12px",height:"12px",marginLeft:"-6px",marginTop:"-6px",boxSizing:"border-box",borderRadius:"50%",border:"2.5px solid var(--bc-tooltip-bg, #fff)",background:"var(--bc-text, #333)",boxShadow:"0 1px 4px rgba(15,23,42,.3)"});const j=u.createElement("div");j.setAttribute("class","bc-tooltip-highlight"),Object.assign(j.style,{position:"absolute",display:"none",pointerEvents:"none",boxSizing:"border-box",borderRadius:"3px",background:"var(--bc-tooltip-highlight-fill, rgba(127,127,127,.14))",outline:"1.5px solid var(--bc-tooltip-highlight-line, rgba(127,127,127,.45))",outlineOffset:"-1.5px"});const m=u.createElementNS("http://www.w3.org/2000/svg","svg");m.setAttribute("class","bc-tooltip-flows"),Object.assign(m.style,{position:"absolute",display:"none",pointerEvents:"none"}),S.appendChild(m),S.appendChild(b),S.appendChild(j),S.appendChild(a);const H=i.marker==="dot"||i.marker==="box"||i.marker==="none"?i.marker:"auto";let v=!1,tt=!1;const xt=()=>{const t=i.content;if(typeof t=="function")return t;if(typeof t!="string")return;const n=BC.getFn(t);return!n&&!v&&(v=!0,console.warn(`[blockcharts] interaction.tooltip: no function "${t}" is registered (BC.defineFn); showing the default content`)),n},wt=t=>!!t&&typeof t=="object"&&typeof t.nodeType=="number",et=t=>{if(!(t==null||t===!1)){if(typeof t=="string"||typeof t=="number"){if(t==="")return;const n=u.createElement("div");n.textContent=String(t),a.appendChild(n)}else if(Array.isArray(t))t.forEach(et);else if(wt(t))a.appendChild(t);else if(typeof t.html=="string"){const n=u.createElement("div");n.innerHTML=t.html,a.appendChild(n)}}},_=()=>{a.style.display="none",b.style.display="none",j.style.display="none",m.style.display="none"},M=(t,n)=>{const r=o.table.columns[t][n];return D[t]?D[t](r)||"\u2013":bt(r)};function nt(t){if(typeof i.heading=="string"&&o.table.columns[i.heading])return i.heading;for(const n of["category","date"])for(const r of["x","y"])try{const e=o.channel(t,r);if(e.field&&e.scale&&e.scale.input===n&&o.table.columns[e.field])return e.field}catch{}return null}function ot(t,n){for(const[r,e]of[["x","x2"],["y","y2"]])try{const s=o.channel(t,r),d=o.channel(t,e);if(!s.field||!d.field||s.field===d.field||!s.scale||s.scale!==d.scale||s.scale.input==="category"||!o.table.columns[s.field]||!o.table.columns[d.field]||n.indexOf(s.field)<0||n.indexOf(d.field)<0)continue;return{from:s.field,to:d.field,date:s.scale.input==="date"}}catch{}return null}const V=t=>BC.get(`mark.${t.type}`);function q(t,n,r){const e=V(t);if(!e||typeof e.color!="function")return"";try{const s=e.color(t,o,n,r);return typeof s=="string"?s:""}catch{return""}}function I(t,n){const r=[];for(const e of Object.keys(n.channels))try{const s=o.channel(t,e);s.field&&r.push(s.field)}catch{}return typeof t.group=="string"&&r.push(t.group),r}function kt(t,n,r,e,s){const d=q(t,r,e);if(s===null||I(t,n).includes(s))return d;const p=o.spec.marks;for(let c=p.length-1;c>=0;c--){const x=V(p[c]);if(c===r||!x||!I(p[c],x).includes(s))continue;const h=q(p[c],c,e);if(h)return h}return d}function st(t,n){const r=new Set;for(const e of Object.keys(n.channels))try{const s=o.channel(t,e);s.field&&s.scale&&s.scale.input==="date"&&r.add(s.field)}catch{}return(e,s)=>!D[e]&&r.has(e)&&Y(o.table.columns[e][s])||M(e,s)}function Et(t,n,r,e,s){const d=[],p=[],c=new Set(s),x=st(t,n),h=w=>{const N=o.table.columns[w];if(!N||c.has(w)||(c.add(w),ut(N[r])))return;const k=x(w,r);e.some(T=>x(w,T)!==k)||(d.push([W[w]||w,k]),p.push(w))};return(X||I(t,n)).forEach(h),{lines:d,fields:p}}function Ct(t){const n=U().toLogical(o,t);if(!U().inPlot(o,n,12))return _();let r=null;if(o.spec.marks.forEach((f,l)=>{const g=BC.get(`mark.${f.type}`);if(!g||!g.pick)return;let y=null;try{y=g.pick(f,o,l,n.x,n.y)}catch{return}y&&isFinite(y.dist)&&(!r||y.dist<=r.pick.dist)&&(r={pick:y,mark:f,def:g,index:l})}),!r)return _();const{pick:e,mark:s,def:d,index:p}=r,c=e.card,x=e.rows&&e.rows.length>1?e.rows:[e.row],h=c?null:nt(s),w=typeof i.heading=="string"&&!!o.table.columns[i.heading],N=c||w?null:ot(s,X||I(s,d)),k=N&&(!h||h===N.from||h===N.to)?N:null,T=c?M:st(s,d),E=k&&x.every(f=>T(k.from,f)===T(k.from,e.row)&&T(k.to,f)===T(k.to,e.row))?k:null,A=!k&&h&&x.every(f=>M(h,f)===M(h,e.row))?h:null,it=c?{lines:c.lines,fields:[]}:Et(s,d,e.row,x,E?[E.from,E.to]:[]),Z=it.lines,rt=A?W[A]||A:null;let B;const lt=c?void 0:xt();if(lt){const f={};for(const l of Object.keys(o.table.columns))f[l]=o.table.columns[l][e.row];try{B=lt({row:e.row,values:f,rows:x,lines:Z,mark:s,markIndex:p,x:e.x,y:e.y,table:o.table})}catch(l){tt||(tt=!0,console.error("[blockcharts] interaction.tooltip: the content function threw, showing the default content:",l)),B=void 0}}if(B===null||B===!1)return _();a.textContent="";const At=q(s,p,e.row),at=it.fields.find((f,l)=>Z[l][0]!==rt),ct=c?c.color||"":kt(s,d,p,e.row,X&&at!==void 0?at:null);if(B===void 0){if(A||c||E){const l=u.createElement("div");if(l.setAttribute("class","bc-tooltip-heading"),A?l.setAttribute("data-bc-field",A):E&&l.setAttribute("data-bc-field",`${E.from} ${E.to}`),Object.assign(l.style,{display:"flex",alignItems:"center",gap:"7px",fontWeight:"600",marginBottom:"4px"}),ct){const F=u.createElement("span");F.setAttribute("class","bc-tooltip-swatch"),Object.assign(F.style,{width:"8px",height:"8px",borderRadius:"50%",background:ct,boxShadow:"inset 0 0 0 1px var(--bc-tooltip-highlight-line, rgba(127,127,127,.45))",flex:"none"}),l.appendChild(F)}const g=u.createElement("span"),y=o.table.columns[A],z=(()=>{for(const F of["x","y"])try{const R=o.channel(s,F);if(R.field===A&&R.scale&&R.scale.input==="date")return!0}catch{}return!1})(),Q=A;if(c)g.textContent=c.title;else if(E){const F=[T(E.from,e.row),T(E.to,e.row)];g.textContent=F.join(F.some(R=>R.indexOf(" ")>=0)?" \u2013 ":"\u2013")}else g.textContent=!D[Q]&&z&&Y(y[e.row])||M(Q,e.row);l.appendChild(g),a.appendChild(l)}const f=u.createElement("div");f.setAttribute("class","bc-tooltip-lines"),Object.assign(f.style,{display:"grid",gridTemplateColumns:"auto auto",columnGap:"16px",rowGap:"1px"});for(const[l,g]of Z){if(l===rt)continue;const y=u.createElement("span");y.textContent=l,y.style.opacity="0.68";const z=u.createElement("span");z.textContent=g,Object.assign(z.style,{textAlign:"right",fontWeight:"600"}),f.appendChild(y),f.appendChild(z)}f.children.length&&a.appendChild(f)}else et(B);if(!(a.childNodes?a.childNodes.length>0:a.children.length>0))return _();const O=P.getBoundingClientRect(),C=S.getBoundingClientRect(),$=O.width/o.size.w,L=O.left-C.left+e.x*$,G=O.top-C.top+e.y*$;m.textContent="";for(const f of e.flows||[]){const l=u.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",f.d),l.setAttribute("fill",f.fill),l.setAttribute("fill-opacity","0.5"),m.appendChild(l)}e.flows&&e.flows.length?(m.setAttribute("viewBox",`0 0 ${o.size.w} ${o.size.h}`),Object.assign(m.style,{left:O.left-C.left+"px",top:O.top-C.top+"px",width:O.width+"px",height:O.height+"px",display:"block"})):m.style.display="none",(H==="box"||H==="auto"&&!!e.box)&&e.box?(Object.assign(j.style,{left:O.left-C.left+e.box.x*$+"px",top:O.top-C.top+e.box.y*$+"px",width:Math.max(0,e.box.w*$)+"px",height:Math.max(0,e.box.h*$)+"px",display:"block"}),b.style.display="none"):H!=="none"?(b.style.left=L+"px",b.style.top=G+"px",b.style.background=At||"var(--bc-text, #333)",b.style.display="block",j.style.display="none"):(b.style.display="none",j.style.display="none");const J=u.defaultView||globalThis,K=Math.max(0,-C.left),ft=typeof J.innerWidth=="number"&&J.innerWidth>0?Math.min(C.width,J.innerWidth-C.left):C.width;a.style.display="block",a.style.maxWidth=Math.max(120,ft-K)+"px",a.style.left=K+"px";const dt=a.offsetWidth||0,pt=a.offsetHeight||0,Ot=L+12+dt>ft?L-12-dt:L+12,St=G-12-pt>=0?G-12-pt:G+12;a.style.left=Math.max(K,Ot)+"px",a.style.top=Math.max(0,St)+"px"}if(i.content===void 0&&o.table){const t=[];for(const n of o.spec.marks){const r=V(n);if(!r||!r.pick)continue;const e=X||I(n,r),s=nt(n),d=typeof i.heading=="string"?null:ot(n,e);for(const p of e)p===s||d&&(p===d.from||p===d.to)||!W[p]&&ht.test(p)&&o.table.columns[p]&&t.indexOf(p)<0&&t.push(p)}t.length&&console.warn(`[blockcharts] interaction.tooltip: the card shows ${t.map(n=>`"${n}"`).join(", ")} under ${t.length>1?"their own names; give them names":"its own name; give it a name"} a reader knows in "labels"`)}gt(o,Ct,_),o.cleanup(()=>{for(const t of[a,b,j,m])t.parentNode&&t.parentNode.removeChild(t);mt()})}};BC.define(yt)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(M){const ht=i=>i==null||i===""||typeof i=="number"&&isNaN(i),bt=/\d|[a-z][A-Z]|_/;function gt(i){if(i==null)return"\u2013";if(typeof i=="number")return isNaN(i)?"\u2013":Number.isInteger(i)?String(i):String(+i.toPrecision(6));const s=String(i);return s.length>80?s.slice(0,79)+"\u2026":s}const H=()=>M.get("lib.pointer").exports,yt=(i,s,O,V)=>M.get("lib.pointer").exports.follow(i,s,O,V),mt={role:"interaction",type:"tooltip",version:24,requires:["lib.pointer"],params:{fields:{kind:"fields"},formats:{kind:"formats"},labels:{kind:"any"},content:{kind:"any"},heading:{kind:"field"},marker:{kind:"enum",values:["auto","dot","box","none"],default:"auto"}},attach(i,s){const O=s.host,V=s.root,u=O.ownerDocument||document,D={};if(i.formats&&typeof i.formats=="object"&&!Array.isArray(i.formats)){const t=i.formats;for(const n of Object.keys(t))try{D[n]=s.format(t[n])}catch(r){console.warn(`[blockcharts] interaction.tooltip: format of "${n}" ignored: ${r instanceof Error?r.message:String(r)}`)}}else i.formats!==void 0&&console.warn('[blockcharts] interaction.tooltip: "formats" must be an object of field name to format; ignored');const v=s.format("date"),W={};for(const t of Array.isArray(s.spec.transforms)?s.spec.transforms:[]){const n=t&&M.get(`transform.${t.type}`);if(!(!n||typeof n.labels!="function"))try{Object.assign(W,n.labels(t))}catch{}}if(i.labels&&typeof i.labels=="object"&&!Array.isArray(i.labels)){const t=i.labels;for(const n of Object.keys(t))s.table.columns[n]?typeof t[n]!="string"?console.warn(`[blockcharts] interaction.tooltip: label of "${n}" must be text; ignored`):W[n]=t[n]:console.warn(`[blockcharts] interaction.tooltip: label of "${n}" ignored: no such field`)}else i.labels!==void 0&&console.warn('[blockcharts] interaction.tooltip: "labels" must be an object of field name to text; ignored');const B=Array.isArray(i.fields)?i.fields.filter(t=>typeof t=="string"):null,xt=s.claimPosition(),l=u.createElement("div");l.setAttribute("class","bc-tooltip"),l.setAttribute("role","tooltip"),Object.assign(l.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"10",boxSizing:"border-box",whiteSpace:"normal",overflowWrap:"anywhere",fontSize:"12px",lineHeight:"1.45",fontVariantNumeric:"tabular-nums",padding:"8px 11px",borderRadius:"10px",background:"var(--bc-tooltip-bg, #fff)",color:"var(--bc-text, #333)",border:"1px solid var(--bc-tooltip-border, rgba(127,127,127,.22))",boxShadow:"var(--bc-tooltip-shadow, 0 10px 28px rgba(15,23,42,.14), 0 2px 6px rgba(15,23,42,.08))"});const b=u.createElement("div");b.setAttribute("class","bc-tooltip-dot"),Object.assign(b.style,{position:"absolute",display:"none",pointerEvents:"none",width:"12px",height:"12px",marginLeft:"-6px",marginTop:"-6px",boxSizing:"border-box",borderRadius:"50%",border:"2.5px solid var(--bc-tooltip-bg, #fff)",background:"var(--bc-text, #333)",boxShadow:"0 1px 4px rgba(15,23,42,.3)"});const C=u.createElement("div");C.setAttribute("class","bc-tooltip-highlight"),Object.assign(C.style,{position:"absolute",display:"none",pointerEvents:"none",boxSizing:"border-box",borderRadius:"3px",background:"var(--bc-tooltip-highlight-fill, rgba(127,127,127,.14))",outline:"1.5px solid var(--bc-tooltip-highlight-line, rgba(127,127,127,.45))",outlineOffset:"-1.5px"});const g=u.createElementNS("http://www.w3.org/2000/svg","svg");g.setAttribute("class","bc-tooltip-flows"),Object.assign(g.style,{position:"absolute",display:"none",pointerEvents:"none"}),O.appendChild(g),O.appendChild(b),O.appendChild(C),O.appendChild(l);const q=i.marker==="dot"||i.marker==="box"||i.marker==="none"?i.marker:"auto";let tt=!1,et=!1;const wt=()=>{const t=i.content;if(typeof t=="function")return t;if(typeof t!="string")return;const n=M.getFn(t);return!n&&!tt&&(tt=!0,console.warn(`[blockcharts] interaction.tooltip: no function "${t}" is registered (BC.defineFn); showing the default content`)),n},kt=t=>!!t&&typeof t=="object"&&typeof t.nodeType=="number",nt=t=>{if(!(t==null||t===!1)){if(typeof t=="string"||typeof t=="number"){if(t==="")return;const n=u.createElement("div");n.textContent=String(t),l.appendChild(n)}else if(Array.isArray(t))t.forEach(nt);else if(kt(t))l.appendChild(t);else if(typeof t.html=="string"){const n=u.createElement("div");n.innerHTML=t.html,l.appendChild(n)}}},_=()=>{l.style.display="none",b.style.display="none",C.style.display="none",g.style.display="none"},T=(t,n)=>{const r=s.table.columns[t][n];return D[t]?D[t](r)||"\u2013":gt(r)};function ot(t){if(typeof i.heading=="string"&&s.table.columns[i.heading])return i.heading;for(const n of["category","date"])for(const r of["x","y"])try{const e=s.channel(t,r);if(e.field&&e.scale&&e.scale.input===n&&s.table.columns[e.field])return e.field}catch{}return null}function st(t,n){for(const[r,e]of[["x","x2"],["y","y2"]])try{const o=s.channel(t,r),f=s.channel(t,e);if(!o.field||!f.field||o.field===f.field||!o.scale||o.scale!==f.scale||o.scale.input==="category"||!s.table.columns[o.field]||!s.table.columns[f.field]||n.indexOf(o.field)<0||n.indexOf(f.field)<0)continue;return{from:o.field,to:f.field,date:o.scale.input==="date"}}catch{}return null}const Z=t=>M.get(`mark.${t.type}`);function J(t,n,r){const e=Z(t);if(!e||typeof e.color!="function")return"";try{const o=e.color(t,s,n,r);return typeof o=="string"?o:""}catch{return""}}function I(t,n){const r=[];for(const e of Object.keys(n.channels))try{const o=s.channel(t,e);o.field&&r.push(o.field)}catch{}return typeof t.group=="string"&&r.push(t.group),r}function Et(t,n,r,e,o){const f=J(t,r,e);if(o===null||I(t,n).includes(o))return f;const d=s.spec.marks;for(let a=d.length-1;a>=0;a--){const y=Z(d[a]);if(a===r||!y||!I(d[a],y).includes(o))continue;const h=J(d[a],a,e);if(h)return h}return f}function it(t,n){const r=new Set;for(const e of Object.keys(n.channels))try{const o=s.channel(t,e);o.field&&o.scale&&o.scale.input==="date"&&r.add(o.field)}catch{}return(e,o)=>!D[e]&&r.has(e)&&v(s.table.columns[e][o])||T(e,o)}function At(t,n,r,e,o){const f=[],d=[],a=new Set(o),y=it(t,n),h=m=>{const F=s.table.columns[m];if(!F||a.has(m)||(a.add(m),ht(F[r])))return;const x=y(m,r);e.some(S=>y(m,S)!==x)||(f.push([W[m]||m,x]),d.push(m))};return(B||I(t,n)).forEach(h),{lines:f,fields:d}}function Ot(t){const n=H().toLogical(s,t);if(!H().inPlot(s,n,12))return _();const r=H().pickAt(s,n);if(!r)return _();const{pick:e,mark:o,def:f,index:d}=r,a=e.card,y=e.rows&&e.rows.length>1?e.rows:[e.row],h=a?null:ot(o),m=typeof i.heading=="string"&&!!s.table.columns[i.heading],F=a||m?null:st(o,B||I(o,f)),x=F&&(!h||h===F.from||h===F.to)?F:null,S=a?T:it(o,f),w=x&&y.every(p=>S(x.from,p)===S(x.from,e.row)&&S(x.to,p)===S(x.to,e.row))?x:null,E=!x&&h&&y.every(p=>T(h,p)===T(h,e.row))?h:null,rt=a?{lines:a.lines,fields:[]}:At(o,f,e.row,y,w?[w.from,w.to]:[]),K=rt.lines,lt=E?W[E]||E:null;let N;const at=a?void 0:wt();if(at){const p={};for(const c of Object.keys(s.table.columns))p[c]=s.table.columns[c][e.row];try{N=at({row:e.row,values:p,rows:y,lines:K,mark:o,markIndex:d,x:e.x,y:e.y,table:s.table})}catch(c){et||(et=!0,console.error("[blockcharts] interaction.tooltip: the content function threw, showing the default content:",c)),N=void 0}}if(N===null||N===!1)return _();l.textContent="";const Ct=J(o,d,e.row),ct=rt.fields.find((p,c)=>K[c][0]!==lt),ft=a?a.color||"":Et(o,f,d,e.row,B&&ct!==void 0?ct:null);if(N===void 0){if(E||a||w){const c=u.createElement("div");if(c.setAttribute("class","bc-tooltip-heading"),E?c.setAttribute("data-bc-field",E):w&&c.setAttribute("data-bc-field",`${w.from} ${w.to}`),Object.assign(c.style,{display:"flex",alignItems:"center",gap:"7px",fontWeight:"600",marginBottom:"4px"}),ft){const j=u.createElement("span");j.setAttribute("class","bc-tooltip-swatch"),Object.assign(j.style,{width:"8px",height:"8px",borderRadius:"50%",background:ft,boxShadow:"inset 0 0 0 1px var(--bc-tooltip-highlight-line, rgba(127,127,127,.45))",flex:"none"}),c.appendChild(j)}const z=u.createElement("span"),X=s.table.columns[E],L=(()=>{for(const j of["x","y"])try{const R=s.channel(o,j);if(R.field===E&&R.scale&&R.scale.input==="date")return!0}catch{}return!1})(),Y=E;if(a)z.textContent=a.title;else if(w){const j=[S(w.from,e.row),S(w.to,e.row)];z.textContent=j.join(j.some(R=>R.indexOf(" ")>=0)?" \u2013 ":"\u2013")}else z.textContent=!D[Y]&&L&&v(X[e.row])||T(Y,e.row);c.appendChild(z),l.appendChild(c)}const p=u.createElement("div");p.setAttribute("class","bc-tooltip-lines"),Object.assign(p.style,{display:"grid",gridTemplateColumns:"auto auto",columnGap:"16px",rowGap:"1px"});for(const[c,z]of K){if(c===lt)continue;const X=u.createElement("span");X.textContent=c,X.style.opacity="0.68";const L=u.createElement("span");L.textContent=z,Object.assign(L.style,{textAlign:"right",fontWeight:"600"}),p.appendChild(X),p.appendChild(L)}p.children.length&&l.appendChild(p)}else nt(N);if(!(l.childNodes?l.childNodes.length>0:l.children.length>0))return _();const A=V.getBoundingClientRect(),k=O.getBoundingClientRect(),$=A.width/s.size.w,G=A.left-k.left+e.x*$,P=A.top-k.top+e.y*$;g.textContent="";for(const p of e.flows||[]){const c=u.createElementNS("http://www.w3.org/2000/svg","path");c.setAttribute("d",p.d),c.setAttribute("fill",p.fill),c.setAttribute("fill-opacity","0.5"),g.appendChild(c)}e.flows&&e.flows.length?(g.setAttribute("viewBox",`0 0 ${s.size.w} ${s.size.h}`),Object.assign(g.style,{left:A.left-k.left+"px",top:A.top-k.top+"px",width:A.width+"px",height:A.height+"px",display:"block"})):g.style.display="none",(q==="box"||q==="auto"&&!!e.box)&&e.box?(Object.assign(C.style,{left:A.left-k.left+e.box.x*$+"px",top:A.top-k.top+e.box.y*$+"px",width:Math.max(0,e.box.w*$)+"px",height:Math.max(0,e.box.h*$)+"px",display:"block"}),b.style.display="none"):q!=="none"?(b.style.left=G+"px",b.style.top=P+"px",b.style.background=Ct||"var(--bc-text, #333)",b.style.display="block",C.style.display="none"):(b.style.display="none",C.style.display="none");const Q=u.defaultView||globalThis,U=Math.max(0,-k.left),dt=typeof Q.innerWidth=="number"&&Q.innerWidth>0?Math.min(k.width,Q.innerWidth-k.left):k.width;l.style.display="block",l.style.maxWidth=Math.max(120,dt-U)+"px",l.style.left=U+"px";const pt=l.offsetWidth||0,ut=l.offsetHeight||0,St=G+12+pt>dt?G-12-pt:G+12,jt=P-12-ut>=0?P-12-ut:P+12;l.style.left=Math.max(U,St)+"px",l.style.top=Math.max(0,jt)+"px"}if(i.content===void 0&&s.table){const t=[];for(const n of s.spec.marks){const r=Z(n);if(!r||!r.pick)continue;const e=B||I(n,r),o=ot(n),f=typeof i.heading=="string"?null:st(n,e);for(const d of e)d===o||f&&(d===f.from||d===f.to)||!W[d]&&bt.test(d)&&s.table.columns[d]&&t.indexOf(d)<0&&t.push(d)}t.length&&console.warn(`[blockcharts] interaction.tooltip: the card shows ${t.map(n=>`"${n}"`).join(", ")} under ${t.length>1?"their own names; give them names":"its own name; give it a name"} a reader knows in "labels"`)}yt(s,Ot,_),s.cleanup(()=>{for(const t of[l,b,C,g])t.parentNode&&t.parentNode.removeChild(t);xt()})}};M.define(mt)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const y=()=>BC.get("lib.view").exports,k={role:"interaction",type:"zoom-controls",version:6,requires:["lib.view"],params:{scales:{kind:"list",default:["x"]},fit:{kind:"list"},step:{kind:"number",default:.5},maxZoom:{kind:"number",default:50},titles:{kind:"any"},corner:{kind:"enum",values:["top-right","top-left","bottom-right","bottom-left"],default:"top-right"}},corner(o,e){const[u,r]=(typeof o.corner=="string"?o.corner:"top-right").split("-"),f=(Array.isArray(o.scales)?o.scales:["x"]).some(a=>typeof a=="string"&&!!e.scales[a]&&!!e.scales[a].invert);return{edge:u,side:r,width:f?120:64}},attach(o,e){const r=(Array.isArray(o.scales)?o.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const n=e.scales[t],c=!!n&&e.orientation(t)!==null&&(!!n.invert||n.bandwidth!==void 0);return c||console.warn(`[blockcharts] interaction.zoom-controls: scale "${t}" is not a positional scale, ignored`),c});if(!r.length)return;const l=r.filter(t=>!!e.scales[t].invert),f=(Array.isArray(o.fit)?o.fit:[]).filter(t=>{const n=typeof t=="string"&&!!e.scales[t]&&r.indexOf(t)<0;return!n&&typeof t=="string"&&console.warn(`[blockcharts] interaction.zoom-controls: cannot fit scale "${t}"`),n}),a=()=>{for(const t of f)e.setView(t,e.fit(t,r[0]))},b=typeof o.step=="number"&&o.step>0&&o.step<1?o.step:.5,w=typeof o.maxZoom=="number"&&o.maxZoom>1?o.maxZoom:50,A=o.corner==="top-left"||o.corner==="bottom-right"||o.corner==="bottom-left"?o.corner:"top-right",[z,v]=A.split("-"),E=()=>{for(const t of r)e.setView(t,null);a()},p=t=>{for(const n of l)y().zoom(e,n,t,w);a()},g=e.host,h=g.ownerDocument||document,i=h.createElement("div");i.setAttribute("class","bc-zoom-controls"),Object.assign(i.style,{position:"absolute",[z]:"8px",[v]:"8px",zIndex:"6",display:"flex",gap:"4px",font:"12px/1 system-ui, sans-serif"});const d=(t,n,c)=>{const s=h.createElement("button");return s.type="button",s.textContent=t,s.setAttribute("aria-label",n),s.title=n,Object.assign(s.style,{minWidth:"22px",height:"22px",padding:"0 6px",lineHeight:"20px",textAlign:"center",border:"1px solid var(--bc-axis, #ccc)",borderRadius:"4px",cursor:"pointer",whiteSpace:"nowrap",background:"var(--bc-tooltip-bg, #fff)",color:"var(--bc-text, #333)"}),s.addEventListener("click",C=>{C.preventDefault(),c()}),i.appendChild(s),s},x=o.titles&&typeof o.titles=="object"?o.titles:{},m=(t,n)=>typeof x[t]=="string"?x[t]:n;d("100%",m("reset","Reset zoom to the full range"),E),l.length&&(d("\u2212",m("out","Zoom out"),()=>p(1/b)),d("+",m("in","Zoom in"),()=>p(b)));const Z=e.claimPosition();g.appendChild(i),e.cleanup(()=>{i.parentNode&&i.parentNode.removeChild(i),Z()})}};BC.define(k)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(u){const k=()=>u.get("lib.view").exports,w={role:"interaction",type:"zoom-controls",version:6,requires:["lib.view"],params:{scales:{kind:"list",default:["x"]},fit:{kind:"list"},step:{kind:"number",default:.5},maxZoom:{kind:"number",default:50},titles:{kind:"any"},corner:{kind:"enum",values:["top-right","top-left","bottom-right","bottom-left"],default:"top-right"}},corner(o,e){const[b,r]=(typeof o.corner=="string"?o.corner:"top-right").split("-"),f=(Array.isArray(o.scales)?o.scales:["x"]).some(a=>typeof a=="string"&&!!e.scales[a]&&!!e.scales[a].invert);return{edge:b,side:r,width:f?120:64}},attach(o,e){const r=(Array.isArray(o.scales)?o.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const n=e.scales[t],c=!!n&&e.orientation(t)!==null&&(!!n.invert||n.bandwidth!==void 0);return c||console.warn(`[blockcharts] interaction.zoom-controls: scale "${t}" is not a positional scale, ignored`),c});if(!r.length)return;const l=r.filter(t=>!!e.scales[t].invert),f=(Array.isArray(o.fit)?o.fit:[]).filter(t=>{const n=typeof t=="string"&&!!e.scales[t]&&r.indexOf(t)<0;return!n&&typeof t=="string"&&console.warn(`[blockcharts] interaction.zoom-controls: cannot fit scale "${t}"`),n}),a=()=>{for(const t of f)e.setView(t,e.fit(t,r[0]))},p=typeof o.step=="number"&&o.step>0&&o.step<1?o.step:.5,A=typeof o.maxZoom=="number"&&o.maxZoom>1?o.maxZoom:50,z=o.corner==="top-left"||o.corner==="bottom-right"||o.corner==="bottom-left"?o.corner:"top-right",[v,E]=z.split("-"),T=()=>{for(const t of r)e.setView(t,null);a()},g=t=>{for(const n of l)k().zoom(e,n,t,A);a()},h=e.host,x=h.ownerDocument||document,i=x.createElement("div");i.setAttribute("class","bc-zoom-controls"),Object.assign(i.style,{position:"absolute",[v]:"8px",[E]:"8px",zIndex:"6",display:"flex",gap:"4px",font:"12px/1 system-ui, sans-serif"});const d=(t,n,c)=>{const s=x.createElement("button");return s.type="button",s.textContent=t,s.setAttribute("aria-label",n),s.title=n,Object.assign(s.style,{minWidth:"22px",height:"22px",padding:"0 6px",lineHeight:"20px",textAlign:"center",border:"1px solid var(--bc-axis, #ccc)",borderRadius:"4px",cursor:"pointer",whiteSpace:"nowrap",background:"var(--bc-tooltip-bg, #fff)",color:"var(--bc-text, #333)"}),s.addEventListener("click",D=>{D.preventDefault(),c()}),i.appendChild(s),s},y=o.titles&&typeof o.titles=="object"?o.titles:{},m=(t,n)=>typeof y[t]=="string"?y[t]:n;d("100%",m("reset","Reset zoom to the full range"),T),l.length&&(d("\u2212",m("out","Zoom out"),()=>g(1/p)),d("+",m("in","Zoom in"),()=>g(p)));const Z=e.claimPosition();h.appendChild(i),e.cleanup(()=>{i.parentNode&&i.parentNode.removeChild(i),Z()})}};u.define(w)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const g=()=>BC.get("lib.pointer").exports,p=()=>BC.get("lib.view").exports,P={role:"interaction",type:"zoom",version:7,requires:["lib.pointer","lib.view"],params:{scales:{kind:"list",default:["x"]},wheel:{kind:"enum",values:["ctrl","always","off"],default:"ctrl"},fit:{kind:"list"},pan:{kind:"boolean",default:!0},maxZoom:{kind:"number",default:50}},attach(r,e){const a=(Array.isArray(r.scales)?r.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const o=!!e.scales[t]&&!!e.scales[t].invert&&e.orientation(t)!==null;return o||console.warn(`[blockcharts] interaction.zoom: scale "${t}" is not a continuous positional scale, ignored`),o});if(!a.length)return;const Z=(Array.isArray(r.fit)?r.fit:[]).filter(t=>{const o=typeof t=="string"&&!!e.scales[t]&&a.indexOf(t)<0;return!o&&typeof t=="string"&&console.warn(`[blockcharts] interaction.zoom: cannot fit scale "${t}"`),o}),y=()=>{for(const t of Z)e.setView(t,e.fit(t,a[0]))},h=r.wheel==="always"||r.wheel==="off"?r.wheel:"ctrl",A=r.pan!==!1,q=typeof r.maxZoom=="number"&&r.maxZoom>1?r.maxZoom:50,n=e.root,f=t=>g().toLogical(e,t),w=t=>g().inPlot(e,t),B=(t,o)=>e.orientation(t)==="horizontal"?o.x:o.y,L=t=>p().current(e,t),k=t=>{if(h==="off"||h==="ctrl"&&!(t.ctrlKey||t.metaKey))return;const o=f(t);if(!w(o))return;t.preventDefault();const s=t.deltaMode===1?t.deltaY*16:t.deltaY,i=Math.exp(s*.002);for(const c of a){const[u,x]=L(c),[b,m]=e.scales[c].range();p().zoom(e,c,i,q,u+(B(c,o)-b)/(m-b)*(x-u))}y()};let l=null;const E=t=>{if(t.button!==0||e.dragClaimed(t))return;const o=f(t);if(!w(o))return;const s={};for(const i of a)s[i]=L(i);l={x:o.x,y:o.y,start:s},n.setPointerCapture&&n.setPointerCapture(t.pointerId),n.style.cursor="grabbing"},C=t=>{if(!l)return;const o=f(t);for(const s of a){const[i,c]=l.start[s],[u,x]=e.scales[s].range(),m=-(e.orientation(s)==="horizontal"?o.x-l.x:o.y-l.y)/(x-u)*(c-i);p().show(e,s,i+m,c+m)}y()},d=()=>{l=null,n.style.cursor="grab"},z=t=>{if(w(f(t))){for(const o of a)e.setView(o,null);y()}};n.addEventListener("wheel",k,{passive:!1}),n.addEventListener("dblclick",z),A&&(n.addEventListener("pointerdown",E),n.addEventListener("pointermove",C),n.addEventListener("pointerup",d),n.addEventListener("pointercancel",d),n.style.cursor="grab"),e.cleanup(()=>{n.removeEventListener("wheel",k),n.removeEventListener("dblclick",z),n.removeEventListener("pointerdown",E),n.removeEventListener("pointermove",C),n.removeEventListener("pointerup",d),n.removeEventListener("pointercancel",d),n.style.cursor=""})}};BC.define(P)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(p){const h=()=>p.get("lib.pointer").exports,y=()=>p.get("lib.view").exports,A={role:"interaction",type:"zoom",version:7,requires:["lib.pointer","lib.view"],params:{scales:{kind:"list",default:["x"]},wheel:{kind:"enum",values:["ctrl","always","off"],default:"ctrl"},fit:{kind:"list"},pan:{kind:"boolean",default:!0},maxZoom:{kind:"number",default:50}},attach(r,e){const a=(Array.isArray(r.scales)?r.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const o=!!e.scales[t]&&!!e.scales[t].invert&&e.orientation(t)!==null;return o||console.warn(`[blockcharts] interaction.zoom: scale "${t}" is not a continuous positional scale, ignored`),o});if(!a.length)return;const q=(Array.isArray(r.fit)?r.fit:[]).filter(t=>{const o=typeof t=="string"&&!!e.scales[t]&&a.indexOf(t)<0;return!o&&typeof t=="string"&&console.warn(`[blockcharts] interaction.zoom: cannot fit scale "${t}"`),o}),w=()=>{for(const t of q)e.setView(t,e.fit(t,a[0]))},L=r.wheel==="always"||r.wheel==="off"?r.wheel:"ctrl",C=r.pan!==!1,D=typeof r.maxZoom=="number"&&r.maxZoom>1?r.maxZoom:50,n=e.root,f=t=>h().toLogical(e,t),b=t=>h().inPlot(e,t),M=(t,o)=>e.orientation(t)==="horizontal"?o.x:o.y,k=t=>y().current(e,t),E=t=>{if(L==="off"||L==="ctrl"&&!(t.ctrlKey||t.metaKey))return;const o=f(t);if(!b(o))return;t.preventDefault();const s=t.deltaMode===1?t.deltaY*16:t.deltaY,i=Math.exp(s*.002);for(const c of a){const[u,g]=k(c),[x,m]=e.scales[c].range();y().zoom(e,c,i,D,u+(M(c,o)-x)/(m-x)*(g-u))}w()};let l=null;const z=t=>{if(t.button!==0||e.dragClaimed(t))return;const o=f(t);if(!b(o))return;const s={};for(const i of a)s[i]=k(i);l={x:o.x,y:o.y,start:s},n.setPointerCapture&&n.setPointerCapture(t.pointerId),n.style.cursor="grabbing"},P=t=>{if(!l)return;const o=f(t);for(const s of a){const[i,c]=l.start[s],[u,g]=e.scales[s].range(),m=-(e.orientation(s)==="horizontal"?o.x-l.x:o.y-l.y)/(g-u)*(c-i);y().show(e,s,i+m,c+m)}w()},d=()=>{l=null,n.style.cursor="grab"},Z=t=>{if(b(f(t))){for(const o of a)e.setView(o,null);w()}};n.addEventListener("wheel",E,{passive:!1}),n.addEventListener("dblclick",Z),C&&(n.addEventListener("pointerdown",z),n.addEventListener("pointermove",P),n.addEventListener("pointerup",d),n.addEventListener("pointercancel",d),n.style.cursor="grab"),e.cleanup(()=>{n.removeEventListener("wheel",E),n.removeEventListener("dblclick",Z),n.removeEventListener("pointerdown",z),n.removeEventListener("pointermove",P),n.removeEventListener("pointerup",d),n.removeEventListener("pointercancel",d),n.style.cursor=""})}};p.define(A)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){function r(c,f,s,h,l){const o=e=>{throw new Error(c+": "+e)},a=e=>Object.prototype.hasOwnProperty.call(f.columns,e);for(const[e,n]of s)n!==void 0&&(typeof n!="string"||!a(n))&&o(`unknown field "${String(n)}" in "${e}"`);const t=new Map;for(const[e,n]of h)n==="__proto__"&&o(`a column cannot be named "__proto__": give "${e}" another name`),t.has(n)&&o(`"${t.get(n)}" and "${e}" both name the new column "${n}"`),t.set(n,e),a(n)&&l.indexOf(n)<0&&o(`"${n}" is already a column of the data: give the new one another name with "${e}"`)}const i={role:"lib",type:"columns",version:2,exports:{check:r}};BC.define(i)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(i){function r(c,f,l,h,m){const o=e=>{throw new Error(c+": "+e)},a=e=>Object.prototype.hasOwnProperty.call(f.columns,e);for(const[e,n]of l)n!==void 0&&(typeof n!="string"||!a(n))&&o(`unknown field "${String(n)}" in "${e}"`);const t=new Map;for(const[e,n]of h)n==="__proto__"&&o(`a column cannot be named "__proto__": give "${e}" another name`),t.has(n)&&o(`"${t.get(n)}" and "${e}" both name the new column "${n}"`),t.set(n,e),a(n)&&m.indexOf(n)<0&&o(`"${n}" is already a column of the data: give the new one another name with "${e}"`)}const s={role:"lib",type:"columns",version:2,exports:{check:r}};i.define(s)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){const e=n=>Math.round(n*100)/100;function u(n,f){const l=n.length,r=[];for(let o=0;o<l-1;o++){const h=n[o+1]-n[o];r.push(h?(f[o+1]-f[o])/h:0)}const s=new Array(l);s[0]=r[0]||0,s[l-1]=r[l-2]||0;for(let o=1;o<l-1;o++)s[o]=r[o-1]*r[o]<=0?0:(r[o-1]+r[o])/2;for(let o=0;o<l-1;o++){if(!r[o]){s[o]=0,s[o+1]=0;continue}const h=s[o]/r[o],i=s[o+1]/r[o],t=h*h+i*i;if(t>9){const c=3/Math.sqrt(t);s[o]=c*h*r[o],s[o+1]=c*i*r[o]}}return s}function k(n,f,l,r){const s=n.length;let o="";if(l==="step"){if(r)for(let t=s-1;t>0;t--)o+="V"+e(f[t-1])+"H"+e(n[t-1]);else for(let t=1;t<s;t++)o+="H"+e(n[t])+"V"+e(f[t]);return o}if(!(l===!0||l==="smooth")||s<3){if(r)for(let t=s-2;t>=0;t--)o+="L"+e(n[t])+" "+e(f[t]);else for(let t=1;t<s;t++)o+="L"+e(n[t])+" "+e(f[t]);return o}const i=u(n,f);if(r)for(let t=s-1;t>0;t--){const c=(n[t]-n[t-1])/3;o+="C"+e(n[t]-c)+" "+e(f[t]-i[t]*c)+" "+e(n[t-1]+c)+" "+e(f[t-1]+i[t-1]*c)+" "+e(n[t-1])+" "+e(f[t-1])}else for(let t=0;t<s-1;t++){const c=(n[t+1]-n[t])/3;o+="C"+e(n[t]+c)+" "+e(f[t]+i[t]*c)+" "+e(n[t+1]-c)+" "+e(f[t+1]-i[t+1]*c)+" "+e(n[t+1])+" "+e(f[t+1])}return o}const d={role:"lib",type:"curve",version:2,exports:{through:k}};BC.define(d)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(u){const e=n=>Math.round(n*100)/100;function k(n,f){const c=n.length,r=[];for(let o=0;o<c-1;o++){const h=n[o+1]-n[o];r.push(h?(f[o+1]-f[o])/h:0)}const s=new Array(c);s[0]=r[0]||0,s[c-1]=r[c-2]||0;for(let o=1;o<c-1;o++)s[o]=r[o-1]*r[o]<=0?0:(r[o-1]+r[o])/2;for(let o=0;o<c-1;o++){if(!r[o]){s[o]=0,s[o+1]=0;continue}const h=s[o]/r[o],i=s[o+1]/r[o],t=h*h+i*i;if(t>9){const l=3/Math.sqrt(t);s[o]=l*h*r[o],s[o+1]=l*i*r[o]}}return s}function d(n,f,c,r){const s=n.length;let o="";if(c==="step"){if(r)for(let t=s-1;t>0;t--)o+="V"+e(f[t-1])+"H"+e(n[t-1]);else for(let t=1;t<s;t++)o+="H"+e(n[t])+"V"+e(f[t]);return o}if(!(c===!0||c==="smooth")||s<3){if(r)for(let t=s-2;t>=0;t--)o+="L"+e(n[t])+" "+e(f[t]);else for(let t=1;t<s;t++)o+="L"+e(n[t])+" "+e(f[t]);return o}const i=k(n,f);if(r)for(let t=s-1;t>0;t--){const l=(n[t]-n[t-1])/3;o+="C"+e(n[t]-l)+" "+e(f[t]-i[t]*l)+" "+e(n[t-1]+l)+" "+e(f[t-1]+i[t-1]*l)+" "+e(n[t-1])+" "+e(f[t-1])}else for(let t=0;t<s-1;t++){const l=(n[t+1]-n[t])/3;o+="C"+e(n[t]+l)+" "+e(f[t]+i[t]*l)+" "+e(n[t+1]-l)+" "+e(f[t+1]-i[t+1]*l)+" "+e(n[t+1])+" "+e(f[t+1])}return o}const g={role:"lib",type:"curve",version:2,exports:{through:d}};u.define(g)})(globalThis.BC);
3
3
 
@@ -1,3 +1,3 @@
1
- /*! blockcharts 0.0.1 | MIT License */
2
- "use strict";(function(){function w(n,r){const e=n.root.getBoundingClientRect();return{x:(r.clientX-e.left)*n.size.w/e.width,y:(r.clientY-e.top)*n.size.h/e.height}}function y(n,r,e=0){const i=n.plot;return r.x>=i.x-e&&r.x<=i.x+i.w+e&&r.y>=i.y-e&&r.y<=i.y+i.h+e}function h(n){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>n()):setTimeout(n,0)}function x(n,r,e,i){const o=n.root,d=n.host,u=d.ownerDocument||document;let s=null,a=!1,v=!1;const l=t=>t.pointerType==="touch",p=t=>{if(t.buttons&&!l(t))return s=null,e();s=t,!a&&(a=!0,h(()=>{if(a=!1,v||!s)return;const f=s;s=null;try{r(f)}catch{e()}}))},L=t=>{(!i||l(t))&&p(t)},c=()=>{s=null,e()},m=t=>{l(t)||c()},E=t=>{const f=t.target;l(t)&&f&&typeof d.contains=="function"&&!d.contains(f)&&c()};o.addEventListener("pointermove",p),o.addEventListener("pointerdown",L),o.addEventListener("pointerleave",m),o.addEventListener("pointercancel",c),o.addEventListener("wheel",c),typeof u.addEventListener=="function"&&u.addEventListener("pointerdown",E,!0),n.cleanup(()=>{v=!0,o.removeEventListener("pointermove",p),o.removeEventListener("pointerdown",L),o.removeEventListener("pointerleave",m),o.removeEventListener("pointercancel",c),o.removeEventListener("wheel",c),typeof u.removeEventListener=="function"&&u.removeEventListener("pointerdown",E,!0)})}const b={role:"lib",type:"pointer",version:2,exports:{toLogical:w,inPlot:y,follow:x}};BC.define(b)})();
1
+ /*! blockcharts 0.0.3 | MIT License */
2
+ "use strict";(function(v){function m(t,i){const e=t.root.getBoundingClientRect();return{x:(i.clientX-e.left)*t.size.w/e.width,y:(i.clientY-e.top)*t.size.h/e.height}}function w(t,i,e=0){const r=t.plot;return i.x>=r.x-e&&i.x<=r.x+r.w+e&&i.y>=r.y-e&&i.y<=r.y+r.h+e}function x(t,i){let e=null;return t.spec.marks.forEach((r,n)=>{const c=v.get(`mark.${r.type}`);if(!c||!c.pick)return;let s=null;try{s=c.pick(r,t,n,i.x,i.y)}catch{return}s&&isFinite(s.dist)&&(!e||s.dist<=e.pick.dist)&&(e={pick:s,mark:r,def:c,index:n})}),e}function b(t){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>t()):setTimeout(t,0)}function g(t,i,e,r){const n=t.root,c=t.host,s=c.ownerDocument||document;let u=null,a=!1,L=!1;const f=o=>o.pointerType==="touch",p=o=>{if(o.buttons&&!f(o))return u=null,e();u=o,!a&&(a=!0,b(()=>{if(a=!1,L||!u)return;const d=u;u=null;try{i(d)}catch{e()}}))},y=o=>{(!r||f(o))&&p(o)},l=()=>{u=null,e()},E=o=>{f(o)||l()},h=o=>{const d=o.target;f(o)&&d&&typeof c.contains=="function"&&!c.contains(d)&&l()};n.addEventListener("pointermove",p),n.addEventListener("pointerdown",y),n.addEventListener("pointerleave",E),n.addEventListener("pointercancel",l),n.addEventListener("wheel",l),typeof s.addEventListener=="function"&&s.addEventListener("pointerdown",h,!0),t.cleanup(()=>{L=!0,n.removeEventListener("pointermove",p),n.removeEventListener("pointerdown",y),n.removeEventListener("pointerleave",E),n.removeEventListener("pointercancel",l),n.removeEventListener("wheel",l),typeof s.removeEventListener=="function"&&s.removeEventListener("pointerdown",h,!0)})}const k={role:"lib",type:"pointer",version:3,exports:{toLogical:m,inPlot:w,pickAt:x,follow:g}};v.define(k)})(globalThis.BC);
3
3