@toclocoinc/lattice-grid 1.63.3 → 1.64.0

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 (163) hide show
  1. package/README.md +2 -1
  2. package/docs/API.html +285 -24
  3. package/docs/CHART-CODES.md +24 -0
  4. package/docs/api-detail.html +80 -5
  5. package/lattice-grid.d.ts +93 -1
  6. package/lattice-grid.esm.min.js +154 -95
  7. package/lattice-grid.min.cjs +154 -95
  8. package/lattice-grid.min.js +154 -95
  9. package/modules/ai.d.ts +1 -1
  10. package/modules/ai.esm.min.js +3 -6
  11. package/modules/ai.min.cjs +3 -6
  12. package/modules/ai.min.js +3 -6
  13. package/modules/angular.d.ts +1 -1
  14. package/modules/angular.esm.min.js +1 -4
  15. package/modules/angular.min.cjs +1 -4
  16. package/modules/angular.min.js +1 -4
  17. package/modules/chart-alluvial.d.ts +1 -1
  18. package/modules/chart-alluvial.esm.min.js +1 -1
  19. package/modules/chart-alluvial.min.cjs +1 -1
  20. package/modules/chart-alluvial.min.js +1 -1
  21. package/modules/chart-arc.d.ts +1 -1
  22. package/modules/chart-arc.esm.min.js +1 -1
  23. package/modules/chart-arc.min.cjs +1 -1
  24. package/modules/chart-arc.min.js +1 -1
  25. package/modules/chart-bubblemap.d.ts +1 -1
  26. package/modules/chart-bubblemap.esm.min.js +1 -1
  27. package/modules/chart-bubblemap.min.cjs +1 -1
  28. package/modules/chart-bubblemap.min.js +1 -1
  29. package/modules/chart-bump.d.ts +1 -1
  30. package/modules/chart-bump.esm.min.js +1 -1
  31. package/modules/chart-bump.min.cjs +1 -1
  32. package/modules/chart-bump.min.js +1 -1
  33. package/modules/chart-calendar.d.ts +1 -1
  34. package/modules/chart-calendar.esm.min.js +1 -1
  35. package/modules/chart-calendar.min.cjs +1 -1
  36. package/modules/chart-calendar.min.js +1 -1
  37. package/modules/chart-decomposition.d.ts +1 -1
  38. package/modules/chart-decomposition.esm.min.js +1 -1
  39. package/modules/chart-decomposition.min.cjs +1 -1
  40. package/modules/chart-decomposition.min.js +1 -1
  41. package/modules/chart-diverging.d.ts +1 -1
  42. package/modules/chart-diverging.esm.min.js +1 -1
  43. package/modules/chart-diverging.min.cjs +1 -1
  44. package/modules/chart-diverging.min.js +1 -1
  45. package/modules/chart-dumbbell.d.ts +1 -1
  46. package/modules/chart-dumbbell.esm.min.js +1 -1
  47. package/modules/chart-dumbbell.min.cjs +1 -1
  48. package/modules/chart-dumbbell.min.js +1 -1
  49. package/modules/chart-fan.d.ts +1 -1
  50. package/modules/chart-fan.esm.min.js +1 -1
  51. package/modules/chart-fan.min.cjs +1 -1
  52. package/modules/chart-fan.min.js +1 -1
  53. package/modules/chart-hexbin.d.ts +1 -1
  54. package/modules/chart-hexbin.esm.min.js +1 -1
  55. package/modules/chart-hexbin.min.cjs +1 -1
  56. package/modules/chart-hexbin.min.js +1 -1
  57. package/modules/chart-hexmap.d.ts +1 -1
  58. package/modules/chart-hexmap.esm.min.js +1 -1
  59. package/modules/chart-hexmap.min.cjs +1 -1
  60. package/modules/chart-hexmap.min.js +1 -1
  61. package/modules/chart-icicle.d.ts +1 -1
  62. package/modules/chart-icicle.esm.min.js +1 -1
  63. package/modules/chart-icicle.min.cjs +1 -1
  64. package/modules/chart-icicle.min.js +1 -1
  65. package/modules/chart-markermap.d.ts +29 -0
  66. package/modules/chart-markermap.esm.min.js +313 -0
  67. package/modules/chart-markermap.min.cjs +317 -0
  68. package/modules/chart-markermap.min.js +317 -0
  69. package/modules/chart-parallel.d.ts +1 -1
  70. package/modules/chart-parallel.esm.min.js +1 -1
  71. package/modules/chart-parallel.min.cjs +1 -1
  72. package/modules/chart-parallel.min.js +1 -1
  73. package/modules/chart-ridgeline.d.ts +1 -1
  74. package/modules/chart-ridgeline.esm.min.js +1 -1
  75. package/modules/chart-ridgeline.min.cjs +1 -1
  76. package/modules/chart-ridgeline.min.js +1 -1
  77. package/modules/chart-roc.d.ts +1 -1
  78. package/modules/chart-roc.esm.min.js +1 -1
  79. package/modules/chart-roc.min.cjs +1 -1
  80. package/modules/chart-roc.min.js +1 -1
  81. package/modules/chart-slope.d.ts +1 -1
  82. package/modules/chart-slope.esm.min.js +1 -1
  83. package/modules/chart-slope.min.cjs +1 -1
  84. package/modules/chart-slope.min.js +1 -1
  85. package/modules/chart-splom.d.ts +1 -1
  86. package/modules/chart-splom.esm.min.js +1 -1
  87. package/modules/chart-splom.min.cjs +1 -1
  88. package/modules/chart-splom.min.js +1 -1
  89. package/modules/chart-waffle.d.ts +1 -1
  90. package/modules/chart-waffle.esm.min.js +1 -1
  91. package/modules/chart-waffle.min.cjs +1 -1
  92. package/modules/chart-waffle.min.js +1 -1
  93. package/modules/charts.d.ts +1 -1
  94. package/modules/charts.esm.min.js +395 -33
  95. package/modules/charts.min.cjs +395 -33
  96. package/modules/charts.min.js +395 -33
  97. package/modules/data-router.d.ts +1 -1
  98. package/modules/data-router.esm.min.js +3 -6
  99. package/modules/data-router.min.cjs +3 -6
  100. package/modules/data-router.min.js +3 -6
  101. package/modules/devtools.d.ts +1 -1
  102. package/modules/devtools.esm.min.js +1 -4
  103. package/modules/devtools.min.cjs +1 -4
  104. package/modules/devtools.min.js +1 -4
  105. package/modules/dhtmlx-compat.d.ts +1 -1
  106. package/modules/dhtmlx-compat.esm.min.js +3 -6
  107. package/modules/dhtmlx-compat.min.cjs +3 -6
  108. package/modules/dhtmlx-compat.min.js +3 -6
  109. package/modules/gantt.d.ts +1 -1
  110. package/modules/gantt.esm.min.js +3 -6
  111. package/modules/gantt.min.cjs +3 -6
  112. package/modules/gantt.min.js +3 -6
  113. package/modules/geo-europe-nuts.d.ts +1 -1
  114. package/modules/geo-europe-nuts.esm.min.js +1 -1
  115. package/modules/geo-uk.d.ts +1 -1
  116. package/modules/geo-uk.esm.min.js +1 -1
  117. package/modules/geo-us-states.d.ts +1 -1
  118. package/modules/geo-us-states.esm.min.js +1 -1
  119. package/modules/geo-world-110m.d.ts +1 -1
  120. package/modules/geo-world-110m.esm.min.js +1 -1
  121. package/modules/geo-world-50m.d.ts +1 -1
  122. package/modules/geo-world-50m.esm.min.js +1 -1
  123. package/modules/htmx.d.ts +1 -1
  124. package/modules/htmx.esm.min.js +154 -95
  125. package/modules/htmx.min.cjs +154 -95
  126. package/modules/htmx.min.js +154 -95
  127. package/modules/kanban.d.ts +1 -1
  128. package/modules/kanban.esm.min.js +3 -6
  129. package/modules/kanban.min.cjs +3 -6
  130. package/modules/kanban.min.js +3 -6
  131. package/modules/kpi.d.ts +56 -3
  132. package/modules/kpi.esm.min.js +202 -10
  133. package/modules/kpi.min.cjs +202 -10
  134. package/modules/kpi.min.js +202 -10
  135. package/modules/layout.d.ts +1 -1
  136. package/modules/layout.esm.min.js +3 -6
  137. package/modules/layout.min.cjs +3 -6
  138. package/modules/layout.min.js +3 -6
  139. package/modules/mock-socket.d.ts +1 -1
  140. package/modules/mock-socket.esm.min.js +1 -4
  141. package/modules/mock-socket.min.cjs +1 -4
  142. package/modules/mock-socket.min.js +1 -4
  143. package/modules/react.d.ts +1 -1
  144. package/modules/react.esm.min.js +3 -6
  145. package/modules/react.min.cjs +3 -6
  146. package/modules/react.min.js +3 -6
  147. package/modules/svelte.d.ts +1 -1
  148. package/modules/svelte.esm.min.js +1 -4
  149. package/modules/svelte.min.cjs +1 -4
  150. package/modules/svelte.min.js +1 -4
  151. package/modules/tabs.d.ts +1 -1
  152. package/modules/tabs.esm.min.js +3 -6
  153. package/modules/tabs.min.cjs +3 -6
  154. package/modules/tabs.min.js +3 -6
  155. package/modules/vue.d.ts +1 -1
  156. package/modules/vue.esm.min.js +1 -4
  157. package/modules/vue.min.cjs +1 -4
  158. package/modules/vue.min.js +1 -4
  159. package/modules/webcomponent.d.ts +1 -1
  160. package/modules/webcomponent.esm.min.js +154 -95
  161. package/modules/webcomponent.min.cjs +154 -95
  162. package/modules/webcomponent.min.js +154 -95
  163. package/package.json +1 -1
@@ -0,0 +1,313 @@
1
+ /*!
2
+ * Lattice Grid 1.64.0, chart-markermap module
3
+ * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
+ * https://latticegrid.dev
5
+ */
6
+ import*as __ext_0 from"@toclocoinc/lattice-grid/modules/charts";
7
+ var __mods=Object.create(null);
8
+ var __cache=Object.create(null);
9
+ function __def(id,fn){__mods[id]=fn;}
10
+ function __req(id){
11
+ var hit=__cache[id];
12
+ if(hit)return hit;
13
+ var exports=Object.create(null);
14
+ __cache[id]=exports;
15
+ var fn=__mods[id];
16
+ if(!fn)throw new Error('[lattice] missing module: '+id);
17
+ fn(exports,__req);
18
+ return exports;
19
+ }
20
+ var __extmods=Object.create(null);
21
+ __extmods["@toclocoinc/lattice-grid/modules/charts"]=__ext_0;
22
+ function __ext(spec){
23
+ var mod=__extmods[spec];
24
+ var g=typeof globalThis!=='undefined'?globalThis:(typeof self!=='undefined'?self:null);
25
+ if(mod)return mod;
26
+ if(spec==="@toclocoinc/lattice-grid/modules/charts"&&g&&g["LatticeGrid"])return g["LatticeGrid"];
27
+ throw new Error('[lattice] this module shares the Lattice core with the page, but it was not found. Load lattice-grid (or its script build) before this module. Missing: '+spec);
28
+ }
29
+ __def("packages/modules/chart-markermap/index.js",function(__exports,__req){
30
+ 'use strict';
31
+ Object.defineProperty(__exports,"bindMarkerMap",{enumerable:true,get:function(){return bindMarkerMap;}});
32
+ Object.defineProperty(__exports,"drawMarkerMap",{enumerable:true,get:function(){return drawMarkerMap;}});
33
+ Object.defineProperty(__exports,"default",{enumerable:true,get:function(){return __default;}});
34
+ const __m0=__ext("@toclocoinc/lattice-grid/modules/charts");
35
+ const registerChartType=__m0["registerChartType"];
36
+ const LABEL_GAP=4;
37
+ const RADIUS=5;
38
+ function fillOf(style){
39
+ if(!style||typeof style!=='object')return null;
40
+ const background=style.background===undefined||style.background===null
41
+ ?null:String(style.background);
42
+ if(background&&!background.includes('gradient('))return background;
43
+ const colour=style.color===undefined||style.color===null?null:String(style.color);
44
+ return colour||null;
45
+ }
46
+ function coordinate(raw){
47
+ if(raw===null||raw===undefined||raw===''||typeof raw==='boolean')return NaN;
48
+ return Number(raw);
49
+ }
50
+ function bindMarkerMap(grid,spec){
51
+ const points=[];
52
+ let unplaced=0;
53
+ const valueCol=spec.value||spec.y||null;
54
+ const formatting=grid.formatting;
55
+ const n=grid.rows.count();
56
+ for(let i=0;i<n;i++){
57
+ const row=grid.rows.get(i);
58
+ if(!row||row.group)continue;
59
+ const lon=coordinate(grid.rows.value(row.key,spec.lon));
60
+ const lat=coordinate(grid.rows.value(row.key,spec.lat));
61
+ if(!Number.isFinite(lon)||!Number.isFinite(lat)
62
+ ||Math.abs(lon)>180||Math.abs(lat)>90){
63
+ unplaced++;
64
+ continue;
65
+ }
66
+ const value=valueCol?grid.rows.value(row.key,valueCol):null;
67
+ const style=valueCol&&formatting&&typeof formatting.styleFor==='function'
68
+ ?formatting.styleFor(valueCol,value)
69
+ :null;
70
+ points.push({
71
+ rowKey:row.key,
72
+ lon,
73
+ lat,
74
+ value:typeof value==='number'&&Number.isFinite(value)?value:null,
75
+ text:valueCol?grid.rows.text(row.key,valueCol):'',
76
+ label:spec.label?grid.rows.text(row.key,spec.label):'',
77
+ fill:fillOf(style),
78
+ });
79
+ }
80
+ return{points,unplaced,empty:points.length===0};
81
+ }
82
+ function markerLegend(grid,valueCol,points){
83
+ const formatting=grid&&grid.formatting;
84
+ if(!valueCol||!formatting||typeof formatting.list!=='function')return[];
85
+ const worn=new Set();
86
+ for(const point of points)if(point.fill)worn.add(point.fill);
87
+ if(!worn.size)return[];
88
+ const rules=[...formatting.list('*'),...formatting.list(valueCol)];
89
+ const out=[];
90
+ const taken=new Set();
91
+ for(const rule of rules){
92
+ if(!rule||rule.enabled===false)continue;
93
+ const colour=fillOf(typeof rule.style==='function'?null:rule.style);
94
+ if(!colour||!worn.has(colour)||taken.has(colour))continue;
95
+ taken.add(colour);
96
+ out.push({
97
+ key:rule.id||colour,
98
+ label:rule.label||thresholdText(rule),
99
+ colour,
100
+ index:out.length,
101
+ });
102
+ }
103
+ return out;
104
+ }
105
+ function thresholdText(rule){
106
+ const when=(rule&&rule.when)||null;
107
+ if(!when||when.value===undefined||when.value===null)return'';
108
+ const symbols={
109
+ gt:'>',gte:'≥',lt:'<',lte:'≤',eq:'=',ne:'≠',
110
+ };
111
+ if(when.op==='between'&&when.value2!==undefined)return`${when.value} – ${when.value2}`;
112
+ const symbol=symbols[when.op];
113
+ return symbol?`${symbol} ${when.value}`:String(when.value);
114
+ }
115
+ function placement(ctx,points){
116
+ const{
117
+ spec,plot,helpers,geoView,
118
+ }=ctx;
119
+ const{
120
+ resolvePack,packRegions,fitted,resolveProjection,extent,linearScale,
121
+ }=helpers;
122
+ const resolved=spec&&spec.shapes?resolvePack(spec.shapes,spec.layer):null;
123
+ if(resolved){
124
+ const all=packRegions(resolved.topology);
125
+ const antarctic=points.some((point)=>point.lat<-60);
126
+ const regions=antarctic
127
+ ?all
128
+ :all.filter((region)=>region.code!=='AQ'&&region.code!=='AN');
129
+ const project=resolveProjection(
130
+ spec.projection||resolved.pack.projection,
131
+ {...(resolved.pack.projectionOptions||{}),...(spec.projectionOptions||{})},
132
+ );
133
+ const fit=fitted({
134
+ project,
135
+ rings:regions.flatMap((region)=>region.rings),
136
+ plot,
137
+ zoom:geoView&&geoView.zoom,
138
+ centreOffset:geoView&&geoView.offset,
139
+ });
140
+ return{
141
+ to:fit.to,
142
+ regions,
143
+ scale:fit.scale,
144
+ aspect:fit.aspect,
145
+ attribution:resolved.pack.attribution||'',
146
+ packed:true,
147
+ };
148
+ }
149
+ const lonD=extent(points.map((p)=>p.lon))||{min:0,max:1};
150
+ const latD=extent(points.map((p)=>p.lat))||{min:0,max:1};
151
+ const pad=RADIUS*3;
152
+ const xScale=linearScale(lonD,[plot.left+pad,plot.right-pad]);
153
+ const yScale=linearScale(latD,[plot.bottom-pad,plot.top+pad]);
154
+ return{
155
+ to:(lon,lat)=>[xScale.of(lon),yScale.of(lat)],
156
+ regions:null,
157
+ scale:null,
158
+ aspect:null,
159
+ attribution:'',
160
+ packed:false,
161
+ };
162
+ }
163
+ function placeLabel(opts){
164
+ const width=opts.textWidth(opts.text,opts.size);
165
+ const height=opts.size;
166
+ const near=RADIUS+LABEL_GAP;
167
+ const candidates=[
168
+ {x:opts.x+near,y:opts.y,anchor:'start'},
169
+ {x:opts.x-near,y:opts.y,anchor:'end'},
170
+ {x:opts.x,y:opts.y-near-height/2,anchor:'middle'},
171
+ {x:opts.x,y:opts.y+near+height/2,anchor:'middle'},
172
+ ];
173
+ for(const candidate of candidates){
174
+ const left=candidate.anchor==='start'?candidate.x
175
+ :(candidate.anchor==='end'?candidate.x-width:candidate.x-width/2);
176
+ const box={
177
+ x:left,y:candidate.y-height/2,width,height,
178
+ };
179
+ if(box.x<opts.plot.left||box.x+box.width>opts.plot.right)continue;
180
+ if(box.y<opts.plot.top||box.y+box.height>opts.plot.bottom)continue;
181
+ if(opts.collides(box,opts.placed,2))continue;
182
+ return{...candidate,box};
183
+ }
184
+ return null;
185
+ }
186
+ function drawMarkerMap(ctx){
187
+ const{
188
+ plot,bound,scheme,groups,spec,helpers,grid,fontSize,
189
+ }=ctx;
190
+ const{
191
+ Pool,attrs,round,resolveScheme,NS,projectedPath,setText,applySize,
192
+ textWidth,collides,
193
+ }=helpers;
194
+ const sch=scheme||resolveScheme();
195
+ const fallback=sch.series(0);
196
+ const{points}=bound;
197
+ new Pool(groups.axis).finish();
198
+ new Pool(groups.rules).finish();
199
+ const fit=placement(ctx,points);
200
+ const base=new Pool(groups.grid);
201
+ if(fit.regions){
202
+ for(const region of fit.regions){
203
+ const d=region.rings.map((ring)=>projectedPath(ring,fit.to)).filter(Boolean).join(' ');
204
+ if(!d)continue;
205
+ attrs(base.next('path',`${NS}__region`),{
206
+ d,
207
+ fill:'var(--lattice-chart-empty, #eceff1)',
208
+ 'data-code':region.code,
209
+ class:`${NS}__region`,
210
+ });
211
+ }
212
+ }
213
+ base.finish();
214
+ const marks=new Pool(groups.marks);
215
+ const ordered=[...points].sort((a,b)=>(b.value||0)-(a.value||0)
216
+ ||String(a.rowKey).localeCompare(String(b.rowKey)));
217
+ const legend=markerLegend(grid,spec.value||spec.y||null,points);
218
+ const hiddenFills=new Set();
219
+ for(const entry of legend)if(ctx.hidden&&ctx.hidden.has(entry.key))hiddenFills.add(entry.colour);
220
+ const markers=[];
221
+ for(const point of ordered){
222
+ if(point.fill&&hiddenFills.has(point.fill))continue;
223
+ const[x,y]=fit.to(point.lon,point.lat);
224
+ if(!Number.isFinite(x)||!Number.isFinite(y))continue;
225
+ const fill=point.fill||fallback;
226
+ const element=marks.next('circle',`${NS}__markermap-dot ${NS}__mark`);
227
+ attrs(element,{
228
+ cx:round(x),
229
+ cy:round(y),
230
+ r:RADIUS,
231
+ fill,
232
+ stroke:'var(--lattice-background, #fff)',
233
+ 'stroke-width':1.5,
234
+ 'data-row':point.rowKey,
235
+ class:`${NS}__markermap-dot ${NS}__mark`,
236
+ });
237
+ markers.push({
238
+ rowKey:point.rowKey,
239
+ label:point.label,
240
+ value:point.value,
241
+ text:point.text,
242
+ lon:point.lon,
243
+ lat:point.lat,
244
+ fill,
245
+ x,
246
+ y,
247
+ r:RADIUS,
248
+ element,
249
+ });
250
+ }
251
+ marks.finish();
252
+ const wantLabels=ctx.labels?ctx.labels.names!==false:true;
253
+ const labels=new Pool(groups.labels);
254
+ let labelsDrawn=0;
255
+ if(wantLabels){
256
+ const placed=[];
257
+ for(const marker of markers){
258
+ const text=[marker.label,marker.text].filter(Boolean).join(' ');
259
+ if(!text)continue;
260
+ const at=placeLabel({
261
+ x:marker.x,
262
+ y:marker.y,
263
+ text,
264
+ size:fontSize,
265
+ placed,
266
+ plot,
267
+ textWidth,
268
+ collides,
269
+ });
270
+ if(!at)continue;
271
+ placed.push(at.box);
272
+ const node=labels.next('text',`${NS}__data-label`);
273
+ applySize(node,fontSize);
274
+ attrs(node,{
275
+ x:round(at.x),
276
+ y:round(at.y),
277
+ 'text-anchor':at.anchor,
278
+ 'dominant-baseline':'middle',
279
+ class:`${NS}__data-label`,
280
+ });
281
+ setText(node,text);
282
+ labelsDrawn++;
283
+ }
284
+ }
285
+ labels.finish();
286
+ const overlay=new Pool(groups.overlay);
287
+ if(bound.unplaced){
288
+ const note=overlay.next('text',`${NS}__geo-note`);
289
+ attrs(note,{x:round(plot.left),y:round(plot.bottom),'text-anchor':'start'});
290
+ setText(note,grid.messages.t('chart.geoUnmatched',{count:bound.unplaced}));
291
+ }
292
+ overlay.finish();
293
+ return{
294
+ markers,
295
+ unplaced:bound.unplaced,
296
+ legend,
297
+ packed:fit.packed,
298
+ scale:fit.scale,
299
+ aspect:fit.aspect,
300
+ attribution:fit.attribution,
301
+ labelsDrawn,
302
+ };
303
+ }
304
+ registerChartType('markermap',{
305
+ draw:drawMarkerMap,bind:bindMarkerMap,freeform:true,labelled:true,
306
+ });
307
+ const __default=drawMarkerMap;
308
+ });
309
+ const __entry=__req("packages/modules/chart-markermap/index.js");
310
+ export const
311
+ bindMarkerMap=__entry.bindMarkerMap,
312
+ drawMarkerMap=__entry.drawMarkerMap;
313
+ export default __entry.default;
@@ -0,0 +1,317 @@
1
+ /*!
2
+ * Lattice Grid 1.64.0, chart-markermap module
3
+ * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
+ * https://latticegrid.dev
5
+ */
6
+ (function(root){
7
+ 'use strict';
8
+ var __mods=Object.create(null);
9
+ var __cache=Object.create(null);
10
+ function __def(id,fn){__mods[id]=fn;}
11
+ function __req(id){
12
+ var hit=__cache[id];
13
+ if(hit)return hit;
14
+ var exports=Object.create(null);
15
+ __cache[id]=exports;
16
+ var fn=__mods[id];
17
+ if(!fn)throw new Error('[lattice] missing module: '+id);
18
+ fn(exports,__req);
19
+ return exports;
20
+ }
21
+ var __extmods=Object.create(null);
22
+ __extmods["@toclocoinc/lattice-grid/modules/charts"]=(root["LatticeGrid"]||null);
23
+ function __ext(spec){
24
+ var mod=__extmods[spec];
25
+ var g=typeof globalThis!=='undefined'?globalThis:(typeof self!=='undefined'?self:null);
26
+ if(mod)return mod;
27
+ if(spec==="@toclocoinc/lattice-grid/modules/charts"&&g&&g["LatticeGrid"])return g["LatticeGrid"];
28
+ throw new Error('[lattice] this module shares the Lattice core with the page, but it was not found. Load lattice-grid (or its script build) before this module. Missing: '+spec);
29
+ }
30
+ __def("packages/modules/chart-markermap/index.js",function(__exports,__req){
31
+ 'use strict';
32
+ Object.defineProperty(__exports,"bindMarkerMap",{enumerable:true,get:function(){return bindMarkerMap;}});
33
+ Object.defineProperty(__exports,"drawMarkerMap",{enumerable:true,get:function(){return drawMarkerMap;}});
34
+ Object.defineProperty(__exports,"default",{enumerable:true,get:function(){return __default;}});
35
+ const __m0=__ext("@toclocoinc/lattice-grid/modules/charts");
36
+ const registerChartType=__m0["registerChartType"];
37
+ const LABEL_GAP=4;
38
+ const RADIUS=5;
39
+ function fillOf(style){
40
+ if(!style||typeof style!=='object')return null;
41
+ const background=style.background===undefined||style.background===null
42
+ ?null:String(style.background);
43
+ if(background&&!background.includes('gradient('))return background;
44
+ const colour=style.color===undefined||style.color===null?null:String(style.color);
45
+ return colour||null;
46
+ }
47
+ function coordinate(raw){
48
+ if(raw===null||raw===undefined||raw===''||typeof raw==='boolean')return NaN;
49
+ return Number(raw);
50
+ }
51
+ function bindMarkerMap(grid,spec){
52
+ const points=[];
53
+ let unplaced=0;
54
+ const valueCol=spec.value||spec.y||null;
55
+ const formatting=grid.formatting;
56
+ const n=grid.rows.count();
57
+ for(let i=0;i<n;i++){
58
+ const row=grid.rows.get(i);
59
+ if(!row||row.group)continue;
60
+ const lon=coordinate(grid.rows.value(row.key,spec.lon));
61
+ const lat=coordinate(grid.rows.value(row.key,spec.lat));
62
+ if(!Number.isFinite(lon)||!Number.isFinite(lat)
63
+ ||Math.abs(lon)>180||Math.abs(lat)>90){
64
+ unplaced++;
65
+ continue;
66
+ }
67
+ const value=valueCol?grid.rows.value(row.key,valueCol):null;
68
+ const style=valueCol&&formatting&&typeof formatting.styleFor==='function'
69
+ ?formatting.styleFor(valueCol,value)
70
+ :null;
71
+ points.push({
72
+ rowKey:row.key,
73
+ lon,
74
+ lat,
75
+ value:typeof value==='number'&&Number.isFinite(value)?value:null,
76
+ text:valueCol?grid.rows.text(row.key,valueCol):'',
77
+ label:spec.label?grid.rows.text(row.key,spec.label):'',
78
+ fill:fillOf(style),
79
+ });
80
+ }
81
+ return{points,unplaced,empty:points.length===0};
82
+ }
83
+ function markerLegend(grid,valueCol,points){
84
+ const formatting=grid&&grid.formatting;
85
+ if(!valueCol||!formatting||typeof formatting.list!=='function')return[];
86
+ const worn=new Set();
87
+ for(const point of points)if(point.fill)worn.add(point.fill);
88
+ if(!worn.size)return[];
89
+ const rules=[...formatting.list('*'),...formatting.list(valueCol)];
90
+ const out=[];
91
+ const taken=new Set();
92
+ for(const rule of rules){
93
+ if(!rule||rule.enabled===false)continue;
94
+ const colour=fillOf(typeof rule.style==='function'?null:rule.style);
95
+ if(!colour||!worn.has(colour)||taken.has(colour))continue;
96
+ taken.add(colour);
97
+ out.push({
98
+ key:rule.id||colour,
99
+ label:rule.label||thresholdText(rule),
100
+ colour,
101
+ index:out.length,
102
+ });
103
+ }
104
+ return out;
105
+ }
106
+ function thresholdText(rule){
107
+ const when=(rule&&rule.when)||null;
108
+ if(!when||when.value===undefined||when.value===null)return'';
109
+ const symbols={
110
+ gt:'>',gte:'≥',lt:'<',lte:'≤',eq:'=',ne:'≠',
111
+ };
112
+ if(when.op==='between'&&when.value2!==undefined)return`${when.value} – ${when.value2}`;
113
+ const symbol=symbols[when.op];
114
+ return symbol?`${symbol} ${when.value}`:String(when.value);
115
+ }
116
+ function placement(ctx,points){
117
+ const{
118
+ spec,plot,helpers,geoView,
119
+ }=ctx;
120
+ const{
121
+ resolvePack,packRegions,fitted,resolveProjection,extent,linearScale,
122
+ }=helpers;
123
+ const resolved=spec&&spec.shapes?resolvePack(spec.shapes,spec.layer):null;
124
+ if(resolved){
125
+ const all=packRegions(resolved.topology);
126
+ const antarctic=points.some((point)=>point.lat<-60);
127
+ const regions=antarctic
128
+ ?all
129
+ :all.filter((region)=>region.code!=='AQ'&&region.code!=='AN');
130
+ const project=resolveProjection(
131
+ spec.projection||resolved.pack.projection,
132
+ {...(resolved.pack.projectionOptions||{}),...(spec.projectionOptions||{})},
133
+ );
134
+ const fit=fitted({
135
+ project,
136
+ rings:regions.flatMap((region)=>region.rings),
137
+ plot,
138
+ zoom:geoView&&geoView.zoom,
139
+ centreOffset:geoView&&geoView.offset,
140
+ });
141
+ return{
142
+ to:fit.to,
143
+ regions,
144
+ scale:fit.scale,
145
+ aspect:fit.aspect,
146
+ attribution:resolved.pack.attribution||'',
147
+ packed:true,
148
+ };
149
+ }
150
+ const lonD=extent(points.map((p)=>p.lon))||{min:0,max:1};
151
+ const latD=extent(points.map((p)=>p.lat))||{min:0,max:1};
152
+ const pad=RADIUS*3;
153
+ const xScale=linearScale(lonD,[plot.left+pad,plot.right-pad]);
154
+ const yScale=linearScale(latD,[plot.bottom-pad,plot.top+pad]);
155
+ return{
156
+ to:(lon,lat)=>[xScale.of(lon),yScale.of(lat)],
157
+ regions:null,
158
+ scale:null,
159
+ aspect:null,
160
+ attribution:'',
161
+ packed:false,
162
+ };
163
+ }
164
+ function placeLabel(opts){
165
+ const width=opts.textWidth(opts.text,opts.size);
166
+ const height=opts.size;
167
+ const near=RADIUS+LABEL_GAP;
168
+ const candidates=[
169
+ {x:opts.x+near,y:opts.y,anchor:'start'},
170
+ {x:opts.x-near,y:opts.y,anchor:'end'},
171
+ {x:opts.x,y:opts.y-near-height/2,anchor:'middle'},
172
+ {x:opts.x,y:opts.y+near+height/2,anchor:'middle'},
173
+ ];
174
+ for(const candidate of candidates){
175
+ const left=candidate.anchor==='start'?candidate.x
176
+ :(candidate.anchor==='end'?candidate.x-width:candidate.x-width/2);
177
+ const box={
178
+ x:left,y:candidate.y-height/2,width,height,
179
+ };
180
+ if(box.x<opts.plot.left||box.x+box.width>opts.plot.right)continue;
181
+ if(box.y<opts.plot.top||box.y+box.height>opts.plot.bottom)continue;
182
+ if(opts.collides(box,opts.placed,2))continue;
183
+ return{...candidate,box};
184
+ }
185
+ return null;
186
+ }
187
+ function drawMarkerMap(ctx){
188
+ const{
189
+ plot,bound,scheme,groups,spec,helpers,grid,fontSize,
190
+ }=ctx;
191
+ const{
192
+ Pool,attrs,round,resolveScheme,NS,projectedPath,setText,applySize,
193
+ textWidth,collides,
194
+ }=helpers;
195
+ const sch=scheme||resolveScheme();
196
+ const fallback=sch.series(0);
197
+ const{points}=bound;
198
+ new Pool(groups.axis).finish();
199
+ new Pool(groups.rules).finish();
200
+ const fit=placement(ctx,points);
201
+ const base=new Pool(groups.grid);
202
+ if(fit.regions){
203
+ for(const region of fit.regions){
204
+ const d=region.rings.map((ring)=>projectedPath(ring,fit.to)).filter(Boolean).join(' ');
205
+ if(!d)continue;
206
+ attrs(base.next('path',`${NS}__region`),{
207
+ d,
208
+ fill:'var(--lattice-chart-empty, #eceff1)',
209
+ 'data-code':region.code,
210
+ class:`${NS}__region`,
211
+ });
212
+ }
213
+ }
214
+ base.finish();
215
+ const marks=new Pool(groups.marks);
216
+ const ordered=[...points].sort((a,b)=>(b.value||0)-(a.value||0)
217
+ ||String(a.rowKey).localeCompare(String(b.rowKey)));
218
+ const legend=markerLegend(grid,spec.value||spec.y||null,points);
219
+ const hiddenFills=new Set();
220
+ for(const entry of legend)if(ctx.hidden&&ctx.hidden.has(entry.key))hiddenFills.add(entry.colour);
221
+ const markers=[];
222
+ for(const point of ordered){
223
+ if(point.fill&&hiddenFills.has(point.fill))continue;
224
+ const[x,y]=fit.to(point.lon,point.lat);
225
+ if(!Number.isFinite(x)||!Number.isFinite(y))continue;
226
+ const fill=point.fill||fallback;
227
+ const element=marks.next('circle',`${NS}__markermap-dot ${NS}__mark`);
228
+ attrs(element,{
229
+ cx:round(x),
230
+ cy:round(y),
231
+ r:RADIUS,
232
+ fill,
233
+ stroke:'var(--lattice-background, #fff)',
234
+ 'stroke-width':1.5,
235
+ 'data-row':point.rowKey,
236
+ class:`${NS}__markermap-dot ${NS}__mark`,
237
+ });
238
+ markers.push({
239
+ rowKey:point.rowKey,
240
+ label:point.label,
241
+ value:point.value,
242
+ text:point.text,
243
+ lon:point.lon,
244
+ lat:point.lat,
245
+ fill,
246
+ x,
247
+ y,
248
+ r:RADIUS,
249
+ element,
250
+ });
251
+ }
252
+ marks.finish();
253
+ const wantLabels=ctx.labels?ctx.labels.names!==false:true;
254
+ const labels=new Pool(groups.labels);
255
+ let labelsDrawn=0;
256
+ if(wantLabels){
257
+ const placed=[];
258
+ for(const marker of markers){
259
+ const text=[marker.label,marker.text].filter(Boolean).join(' ');
260
+ if(!text)continue;
261
+ const at=placeLabel({
262
+ x:marker.x,
263
+ y:marker.y,
264
+ text,
265
+ size:fontSize,
266
+ placed,
267
+ plot,
268
+ textWidth,
269
+ collides,
270
+ });
271
+ if(!at)continue;
272
+ placed.push(at.box);
273
+ const node=labels.next('text',`${NS}__data-label`);
274
+ applySize(node,fontSize);
275
+ attrs(node,{
276
+ x:round(at.x),
277
+ y:round(at.y),
278
+ 'text-anchor':at.anchor,
279
+ 'dominant-baseline':'middle',
280
+ class:`${NS}__data-label`,
281
+ });
282
+ setText(node,text);
283
+ labelsDrawn++;
284
+ }
285
+ }
286
+ labels.finish();
287
+ const overlay=new Pool(groups.overlay);
288
+ if(bound.unplaced){
289
+ const note=overlay.next('text',`${NS}__geo-note`);
290
+ attrs(note,{x:round(plot.left),y:round(plot.bottom),'text-anchor':'start'});
291
+ setText(note,grid.messages.t('chart.geoUnmatched',{count:bound.unplaced}));
292
+ }
293
+ overlay.finish();
294
+ return{
295
+ markers,
296
+ unplaced:bound.unplaced,
297
+ legend,
298
+ packed:fit.packed,
299
+ scale:fit.scale,
300
+ aspect:fit.aspect,
301
+ attribution:fit.attribution,
302
+ labelsDrawn,
303
+ };
304
+ }
305
+ registerChartType('markermap',{
306
+ draw:drawMarkerMap,bind:bindMarkerMap,freeform:true,labelled:true,
307
+ });
308
+ const __default=drawMarkerMap;
309
+ });
310
+ var __entry=__req("packages/modules/chart-markermap/index.js");
311
+ if(typeof module==='object'&&module.exports){module.exports=__entry;}
312
+ else if(typeof define==='function'&&define.amd){define(function(){return __entry;});}
313
+ else{
314
+ var __t=root["LatticeGrid"]||(root["LatticeGrid"]={});
315
+ for(var __k in __entry){if(__k!=='default')__t[__k]=__entry[__k];}
316
+ }
317
+ })(typeof globalThis!=='undefined'?globalThis:this);