@toclocoinc/lattice-grid 1.62.0 → 1.63.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.
- package/README.md +23 -8
- package/docs/API.html +526 -16
- package/docs/CHART-CODES.md +141 -2
- package/docs/api-detail.html +194 -5
- package/lattice-grid.d.ts +235 -5
- package/lattice-grid.esm.min.js +856 -78
- package/lattice-grid.min.cjs +856 -78
- package/lattice-grid.min.js +856 -78
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +13 -16
- package/modules/ai.min.cjs +13 -16
- package/modules/ai.min.js +13 -16
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +147 -0
- package/modules/chart-alluvial.min.js +147 -0
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +106 -0
- package/modules/chart-arc.min.js +106 -0
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +42 -6
- package/modules/chart-bubblemap.min.cjs +126 -0
- package/modules/chart-bubblemap.min.js +126 -0
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +110 -0
- package/modules/chart-bump.min.js +110 -0
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +1 -1
- package/modules/chart-calendar.min.cjs +129 -0
- package/modules/chart-calendar.min.js +129 -0
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +131 -0
- package/modules/chart-decomposition.min.js +131 -0
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +104 -0
- package/modules/chart-diverging.min.js +104 -0
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +114 -0
- package/modules/chart-dumbbell.min.js +114 -0
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +139 -0
- package/modules/chart-fan.min.js +139 -0
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +1 -1
- package/modules/chart-hexbin.min.cjs +148 -0
- package/modules/chart-hexbin.min.js +148 -0
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +46 -6
- package/modules/chart-hexmap.min.cjs +164 -0
- package/modules/chart-hexmap.min.js +164 -0
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +97 -0
- package/modules/chart-icicle.min.js +97 -0
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +123 -0
- package/modules/chart-parallel.min.js +123 -0
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +119 -0
- package/modules/chart-ridgeline.min.js +119 -0
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +181 -0
- package/modules/chart-roc.min.js +181 -0
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +100 -0
- package/modules/chart-slope.min.js +100 -0
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +124 -0
- package/modules/chart-splom.min.js +124 -0
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +97 -0
- package/modules/chart-waffle.min.js +97 -0
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +1917 -662
- package/modules/charts.min.cjs +1917 -662
- package/modules/charts.min.js +1917 -662
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +129 -20
- package/modules/data-router.min.cjs +129 -20
- package/modules/data-router.min.js +129 -20
- package/modules/devtools.d.ts +1 -1
- package/modules/devtools.esm.min.js +2 -2
- package/modules/devtools.min.cjs +2 -2
- package/modules/devtools.min.js +2 -2
- package/modules/dhtmlx-compat.d.ts +1 -1
- package/modules/dhtmlx-compat.esm.min.js +4 -16
- package/modules/dhtmlx-compat.min.cjs +4 -16
- package/modules/dhtmlx-compat.min.js +4 -16
- package/modules/gantt.d.ts +1 -1
- package/modules/gantt.esm.min.js +187 -82
- package/modules/gantt.min.cjs +187 -82
- package/modules/gantt.min.js +187 -82
- package/modules/geo-europe-nuts.d.ts +16 -0
- package/modules/geo-europe-nuts.esm.min.js +29 -0
- package/modules/geo-uk.d.ts +18 -0
- package/modules/geo-uk.esm.min.js +29 -0
- package/modules/geo-us-states.d.ts +16 -0
- package/modules/geo-us-states.esm.min.js +29 -0
- package/modules/geo-world-110m.d.ts +17 -0
- package/modules/geo-world-110m.esm.min.js +29 -0
- package/modules/geo-world-50m.d.ts +16 -0
- package/modules/geo-world-50m.esm.min.js +29 -0
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +856 -78
- package/modules/htmx.min.cjs +856 -78
- package/modules/htmx.min.js +856 -78
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +4 -16
- package/modules/kanban.min.cjs +4 -16
- package/modules/kanban.min.js +4 -16
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +29 -24
- package/modules/kpi.min.cjs +29 -24
- package/modules/kpi.min.js +29 -24
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +4 -16
- package/modules/layout.min.cjs +4 -16
- package/modules/layout.min.js +4 -16
- package/modules/mock-socket.d.ts +1 -1
- package/modules/mock-socket.esm.min.js +2 -2
- package/modules/mock-socket.min.cjs +2 -2
- package/modules/mock-socket.min.js +2 -2
- package/modules/react.d.ts +308 -3
- package/modules/react.esm.min.js +1072 -22
- package/modules/react.min.cjs +1056 -21
- package/modules/react.min.js +1056 -21
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +4 -16
- package/modules/tabs.min.cjs +4 -16
- package/modules/tabs.min.js +4 -16
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +856 -78
- package/modules/webcomponent.min.cjs +856 -78
- package/modules/webcomponent.min.js +856 -78
- package/package.json +1 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Lattice Grid 1.63.0, chart-hexbin 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-hexbin/index.js",function(__exports,__req){
|
|
31
|
+
'use strict';
|
|
32
|
+
Object.defineProperty(__exports,"bindHexbin",{enumerable:true,get:function(){return bindHexbin;}});
|
|
33
|
+
Object.defineProperty(__exports,"drawHexbin",{enumerable:true,get:function(){return drawHexbin;}});
|
|
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 DEFAULT_RADIUS=10;
|
|
38
|
+
function bindHexbin(grid,spec){
|
|
39
|
+
const xCol=spec.x;
|
|
40
|
+
const yCol=spec.y&&typeof spec.y==='object'?spec.y.col:spec.y;
|
|
41
|
+
const points=[];
|
|
42
|
+
const n=grid.rows.count();
|
|
43
|
+
for(let i=0;i<n;i++){
|
|
44
|
+
const row=grid.rows.get(i);
|
|
45
|
+
if(!row||row.group)continue;
|
|
46
|
+
const x=Number(grid.rows.value(row.key,xCol));
|
|
47
|
+
const y=Number(grid.rows.value(row.key,yCol));
|
|
48
|
+
if(Number.isFinite(x)&&Number.isFinite(y))points.push({x,y});
|
|
49
|
+
}
|
|
50
|
+
return{points,xCol,yCol,empty:points.length===0};
|
|
51
|
+
}
|
|
52
|
+
function binHex(pts,r){
|
|
53
|
+
const dx=r*2*Math.sin(Math.PI/3);
|
|
54
|
+
const dy=r*1.5;
|
|
55
|
+
const bins=new Map();
|
|
56
|
+
for(const{px,py}of pts){
|
|
57
|
+
const y=py/dy;
|
|
58
|
+
let pj=Math.round(y);
|
|
59
|
+
const x=px/dx-(pj&1)/2;
|
|
60
|
+
let pi=Math.round(x);
|
|
61
|
+
const py1=y-pj;
|
|
62
|
+
if(Math.abs(py1)*3>1){
|
|
63
|
+
const px1=x-pi;
|
|
64
|
+
const pi2=pi+(x<pi?-1:1)/2;
|
|
65
|
+
const pj2=pj+(y<pj?-1:1);
|
|
66
|
+
const px2=x-pi2;
|
|
67
|
+
const py2=y-pj2;
|
|
68
|
+
if(px1*px1+py1*py1>px2*px2+py2*py2){pi=pi2+((pj&1)?1:-1)/2;pj=pj2;}
|
|
69
|
+
}
|
|
70
|
+
const k=`${pi}:${pj}`;
|
|
71
|
+
let bin=bins.get(k);
|
|
72
|
+
if(!bin){bin={x:(pi+(pj&1)/2)*dx,y:pj*dy,count:0};bins.set(k,bin);}
|
|
73
|
+
bin.count+=1;
|
|
74
|
+
}
|
|
75
|
+
return[...bins.values()];
|
|
76
|
+
}
|
|
77
|
+
function drawHexbin(ctx){
|
|
78
|
+
const{
|
|
79
|
+
plot,bound,scheme,fontSize,groups,grid,spec,helpers,
|
|
80
|
+
}=ctx;
|
|
81
|
+
const{
|
|
82
|
+
extent,measureDomain,linearScale,linearTicks,colourRamp,
|
|
83
|
+
Pool,attrs,path,round,setText,formatters,resolveScheme,NS,
|
|
84
|
+
}=helpers;
|
|
85
|
+
const sch=scheme||resolveScheme();
|
|
86
|
+
const xDomain=extent(bound.points.map((p)=>p.x))||{min:0,max:1};
|
|
87
|
+
const yDomain=extent(bound.points.map((p)=>p.y))||{min:0,max:1};
|
|
88
|
+
const xScale=linearScale(xDomain,[plot.left,plot.right]);
|
|
89
|
+
const yScale=linearScale(yDomain,[plot.bottom,plot.top]);
|
|
90
|
+
const radius=spec&&Number.isFinite(spec.radius)&&spec.radius>0?spec.radius:DEFAULT_RADIUS;
|
|
91
|
+
const pixels=bound.points.map((p)=>({px:xScale.of(p.x),py:yScale.of(p.y)}));
|
|
92
|
+
const bins=binHex(pixels,radius);
|
|
93
|
+
if(!bins.length)return{empty:true,legend:[]};
|
|
94
|
+
let maxCount=0;
|
|
95
|
+
for(const b of bins)if(b.count>maxCount)maxCount=b.count;
|
|
96
|
+
const countDomain=measureDomain([0,maxCount],{zero:true});
|
|
97
|
+
const ramp=colourRamp(countDomain,false,sch);
|
|
98
|
+
const gridPool=new Pool(groups.grid);
|
|
99
|
+
const axisPool=new Pool(groups.axis);
|
|
100
|
+
const xFmt=formatters(grid,{kind:'linear',step:(xDomain.max-xDomain.min)/5||1});
|
|
101
|
+
const yFmt=formatters(grid,{kind:'linear',step:(yDomain.max-yDomain.min)/5||1});
|
|
102
|
+
for(const t of linearTicks(xDomain,5)){
|
|
103
|
+
const x=xScale.of(t);
|
|
104
|
+
const label=axisPool.next('text',`${NS}__tick`);
|
|
105
|
+
setText(label,xFmt.tick(t));
|
|
106
|
+
attrs(label,{x:round(x),y:round(plot.bottom+fontSize+4),'text-anchor':'middle','font-size':fontSize});
|
|
107
|
+
}
|
|
108
|
+
for(const t of linearTicks(yDomain,5)){
|
|
109
|
+
const y=yScale.of(t);
|
|
110
|
+
attrs(gridPool.next('line',`${NS}__gridline`),{
|
|
111
|
+
x1:round(plot.left),y1:round(y),x2:round(plot.right),y2:round(y),
|
|
112
|
+
stroke:'currentColor','stroke-opacity':0.1,
|
|
113
|
+
});
|
|
114
|
+
const label=axisPool.next('text',`${NS}__tick`);
|
|
115
|
+
setText(label,yFmt.tick(t));
|
|
116
|
+
attrs(label,{x:round(plot.left-4),y:round(y),'text-anchor':'end','font-size':fontSize});
|
|
117
|
+
}
|
|
118
|
+
const third=Math.PI/3;
|
|
119
|
+
const hex=[];
|
|
120
|
+
for(let i=0;i<6;i++)hex.push([Math.sin(i*third)*radius,-Math.cos(i*third)*radius]);
|
|
121
|
+
const marks=new Pool(groups.marks);
|
|
122
|
+
for(const bin of bins){
|
|
123
|
+
const parts=['M'];
|
|
124
|
+
for(let i=0;i<6;i++){
|
|
125
|
+
parts.push(round(bin.x+hex[i][0]),round(bin.y+hex[i][1]));
|
|
126
|
+
if(i<5)parts.push('L');
|
|
127
|
+
}
|
|
128
|
+
parts.push('Z');
|
|
129
|
+
attrs(marks.next('path',`${NS}__hex ${NS}__mark`),{
|
|
130
|
+
d:path(parts),fill:ramp(bin.count),stroke:'none','data-count':bin.count,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
gridPool.finish();
|
|
134
|
+
axisPool.finish();
|
|
135
|
+
marks.finish();
|
|
136
|
+
return{bins:bins.length,maxCount,legend:[]};
|
|
137
|
+
}
|
|
138
|
+
registerChartType('hexbin',{draw:drawHexbin,bind:bindHexbin,labelled:false});
|
|
139
|
+
const __default=drawHexbin;
|
|
140
|
+
});
|
|
141
|
+
var __entry=__req("packages/modules/chart-hexbin/index.js");
|
|
142
|
+
if(typeof module==='object'&&module.exports){module.exports=__entry;}
|
|
143
|
+
else if(typeof define==='function'&&define.amd){define(function(){return __entry;});}
|
|
144
|
+
else{
|
|
145
|
+
var __t=root["LatticeGrid"]||(root["LatticeGrid"]={});
|
|
146
|
+
for(var __k in __entry){if(__k!=='default')__t[__k]=__entry[__k];}
|
|
147
|
+
}
|
|
148
|
+
})(typeof globalThis!=='undefined'?globalThis:this);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.63.0, chart-hexmap module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
@@ -46,6 +46,22 @@ if(Number.isFinite(lon)&&Number.isFinite(lat))points.push({lon,lat});
|
|
|
46
46
|
}
|
|
47
47
|
return{points,empty:points.length===0};
|
|
48
48
|
}
|
|
49
|
+
function packProjection(opts){
|
|
50
|
+
const{spec,plot,helpers}=opts;
|
|
51
|
+
if(!spec||!spec.shapes)return null;
|
|
52
|
+
const{
|
|
53
|
+
resolvePack,packRegions,fitted,resolveProjection,
|
|
54
|
+
}=helpers;
|
|
55
|
+
const resolved=resolvePack(spec.shapes,spec.layer);
|
|
56
|
+
if(!resolved)return null;
|
|
57
|
+
const regions=packRegions(resolved.topology);
|
|
58
|
+
const project=resolveProjection(
|
|
59
|
+
spec.projection||resolved.pack.projection,
|
|
60
|
+
{...(resolved.pack.projectionOptions||{}),...(spec.projectionOptions||{})},
|
|
61
|
+
);
|
|
62
|
+
const fit=fitted({project,rings:regions.flatMap((r)=>r.rings),plot});
|
|
63
|
+
return{to:fit.to,regions};
|
|
64
|
+
}
|
|
49
65
|
function binHex(pts,r){
|
|
50
66
|
const dx=r*2*Math.sin(Math.PI/3);
|
|
51
67
|
const dy=r*1.5;
|
|
@@ -77,25 +93,43 @@ plot,bound,scheme,groups,spec,helpers,
|
|
|
77
93
|
}=ctx;
|
|
78
94
|
const{
|
|
79
95
|
extent,measureDomain,linearScale,colourRamp,Pool,attrs,path,round,resolveScheme,
|
|
96
|
+
projectedPath,
|
|
80
97
|
}=helpers;
|
|
81
98
|
const NS=helpers.NS;
|
|
82
99
|
const sch=scheme||resolveScheme();
|
|
83
100
|
const{points}=bound;
|
|
101
|
+
const marks=new Pool(groups.marks);
|
|
102
|
+
const fit=packProjection({spec,plot,helpers});
|
|
103
|
+
let project;
|
|
104
|
+
if(fit){
|
|
105
|
+
for(const region of fit.regions){
|
|
106
|
+
const d=region.rings.map((ring)=>projectedPath(ring,fit.to)).filter(Boolean).join(' ');
|
|
107
|
+
if(!d)continue;
|
|
108
|
+
attrs(marks.next('path',`${NS}__region`),{
|
|
109
|
+
d,fill:'var(--lattice-chart-empty, #eceff1)',class:`${NS}__region`,
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
project=fit.to;
|
|
113
|
+
}else{
|
|
84
114
|
const lonD=extent(points.map((p)=>p.lon))||{min:0,max:1};
|
|
85
115
|
const latD=extent(points.map((p)=>p.lat))||{min:0,max:1};
|
|
86
116
|
const xScale=linearScale(lonD,[plot.left,plot.right]);
|
|
87
117
|
const yScale=linearScale(latD,[plot.bottom,plot.top]);
|
|
118
|
+
project=(lon,lat)=>[xScale.of(lon),yScale.of(lat)];
|
|
119
|
+
}
|
|
88
120
|
const radius=spec&&Number.isFinite(spec.radius)&&spec.radius>0?spec.radius:DEFAULT_RADIUS;
|
|
89
|
-
const pixels=points.map((p)=>
|
|
121
|
+
const pixels=points.map((p)=>{
|
|
122
|
+
const[x,y]=project(p.lon,p.lat);
|
|
123
|
+
return{px:x,py:y};
|
|
124
|
+
});
|
|
90
125
|
const bins=binHex(pixels,radius);
|
|
91
|
-
if(!bins.length)return{empty:true,legend:[]};
|
|
126
|
+
if(!bins.length)return{empty:true,legend:[],packed:!!fit};
|
|
92
127
|
let maxCount=0;
|
|
93
128
|
for(const b of bins)if(b.count>maxCount)maxCount=b.count;
|
|
94
129
|
const ramp=colourRamp(measureDomain([0,maxCount],{zero:true}),false,sch);
|
|
95
130
|
const third=Math.PI/3;
|
|
96
131
|
const hex=[];
|
|
97
132
|
for(let i=0;i<6;i++)hex.push([Math.sin(i*third)*radius,-Math.cos(i*third)*radius]);
|
|
98
|
-
const marks=new Pool(groups.marks);
|
|
99
133
|
for(const bin of bins){
|
|
100
134
|
const parts=['M'];
|
|
101
135
|
for(let i=0;i<6;i++){
|
|
@@ -104,11 +138,17 @@ if(i<5)parts.push('L');
|
|
|
104
138
|
}
|
|
105
139
|
parts.push('Z');
|
|
106
140
|
attrs(marks.next('path',`${NS}__hexmap-cell ${NS}__mark`),{
|
|
107
|
-
d:path(parts),
|
|
141
|
+
d:path(parts),
|
|
142
|
+
fill:ramp(bin.count),
|
|
143
|
+
stroke:'none',
|
|
144
|
+
'data-count':bin.count,
|
|
145
|
+
class:`${NS}__hexmap-cell ${NS}__mark`,
|
|
108
146
|
});
|
|
109
147
|
}
|
|
110
148
|
marks.finish();
|
|
111
|
-
return{
|
|
149
|
+
return{
|
|
150
|
+
bins:bins.length,maxCount,legend:[],packed:!!fit,
|
|
151
|
+
};
|
|
112
152
|
}
|
|
113
153
|
registerChartType('hexmap',{draw:drawHexMap,bind:bindHexMap,freeform:true,labelled:false});
|
|
114
154
|
const __default=drawHexMap;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Lattice Grid 1.63.0, chart-hexmap 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-hexmap/index.js",function(__exports,__req){
|
|
31
|
+
'use strict';
|
|
32
|
+
Object.defineProperty(__exports,"bindHexMap",{enumerable:true,get:function(){return bindHexMap;}});
|
|
33
|
+
Object.defineProperty(__exports,"drawHexMap",{enumerable:true,get:function(){return drawHexMap;}});
|
|
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 DEFAULT_RADIUS=12;
|
|
38
|
+
function bindHexMap(grid,spec){
|
|
39
|
+
const points=[];
|
|
40
|
+
const n=grid.rows.count();
|
|
41
|
+
for(let i=0;i<n;i++){
|
|
42
|
+
const row=grid.rows.get(i);
|
|
43
|
+
if(!row||row.group)continue;
|
|
44
|
+
const lon=Number(grid.rows.value(row.key,spec.lon));
|
|
45
|
+
const lat=Number(grid.rows.value(row.key,spec.lat));
|
|
46
|
+
if(Number.isFinite(lon)&&Number.isFinite(lat))points.push({lon,lat});
|
|
47
|
+
}
|
|
48
|
+
return{points,empty:points.length===0};
|
|
49
|
+
}
|
|
50
|
+
function packProjection(opts){
|
|
51
|
+
const{spec,plot,helpers}=opts;
|
|
52
|
+
if(!spec||!spec.shapes)return null;
|
|
53
|
+
const{
|
|
54
|
+
resolvePack,packRegions,fitted,resolveProjection,
|
|
55
|
+
}=helpers;
|
|
56
|
+
const resolved=resolvePack(spec.shapes,spec.layer);
|
|
57
|
+
if(!resolved)return null;
|
|
58
|
+
const regions=packRegions(resolved.topology);
|
|
59
|
+
const project=resolveProjection(
|
|
60
|
+
spec.projection||resolved.pack.projection,
|
|
61
|
+
{...(resolved.pack.projectionOptions||{}),...(spec.projectionOptions||{})},
|
|
62
|
+
);
|
|
63
|
+
const fit=fitted({project,rings:regions.flatMap((r)=>r.rings),plot});
|
|
64
|
+
return{to:fit.to,regions};
|
|
65
|
+
}
|
|
66
|
+
function binHex(pts,r){
|
|
67
|
+
const dx=r*2*Math.sin(Math.PI/3);
|
|
68
|
+
const dy=r*1.5;
|
|
69
|
+
const bins=new Map();
|
|
70
|
+
for(const{px,py}of pts){
|
|
71
|
+
const y=py/dy;
|
|
72
|
+
let pj=Math.round(y);
|
|
73
|
+
const x=px/dx-(pj&1)/2;
|
|
74
|
+
let pi=Math.round(x);
|
|
75
|
+
const py1=y-pj;
|
|
76
|
+
if(Math.abs(py1)*3>1){
|
|
77
|
+
const px1=x-pi;
|
|
78
|
+
const pi2=pi+(x<pi?-1:1)/2;
|
|
79
|
+
const pj2=pj+(y<pj?-1:1);
|
|
80
|
+
const px2=x-pi2;
|
|
81
|
+
const py2=y-pj2;
|
|
82
|
+
if(px1*px1+py1*py1>px2*px2+py2*py2){pi=pi2+((pj&1)?1:-1)/2;pj=pj2;}
|
|
83
|
+
}
|
|
84
|
+
const k=`${pi}:${pj}`;
|
|
85
|
+
let bin=bins.get(k);
|
|
86
|
+
if(!bin){bin={x:(pi+(pj&1)/2)*dx,y:pj*dy,count:0};bins.set(k,bin);}
|
|
87
|
+
bin.count+=1;
|
|
88
|
+
}
|
|
89
|
+
return[...bins.values()];
|
|
90
|
+
}
|
|
91
|
+
function drawHexMap(ctx){
|
|
92
|
+
const{
|
|
93
|
+
plot,bound,scheme,groups,spec,helpers,
|
|
94
|
+
}=ctx;
|
|
95
|
+
const{
|
|
96
|
+
extent,measureDomain,linearScale,colourRamp,Pool,attrs,path,round,resolveScheme,
|
|
97
|
+
projectedPath,
|
|
98
|
+
}=helpers;
|
|
99
|
+
const NS=helpers.NS;
|
|
100
|
+
const sch=scheme||resolveScheme();
|
|
101
|
+
const{points}=bound;
|
|
102
|
+
const marks=new Pool(groups.marks);
|
|
103
|
+
const fit=packProjection({spec,plot,helpers});
|
|
104
|
+
let project;
|
|
105
|
+
if(fit){
|
|
106
|
+
for(const region of fit.regions){
|
|
107
|
+
const d=region.rings.map((ring)=>projectedPath(ring,fit.to)).filter(Boolean).join(' ');
|
|
108
|
+
if(!d)continue;
|
|
109
|
+
attrs(marks.next('path',`${NS}__region`),{
|
|
110
|
+
d,fill:'var(--lattice-chart-empty, #eceff1)',class:`${NS}__region`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
project=fit.to;
|
|
114
|
+
}else{
|
|
115
|
+
const lonD=extent(points.map((p)=>p.lon))||{min:0,max:1};
|
|
116
|
+
const latD=extent(points.map((p)=>p.lat))||{min:0,max:1};
|
|
117
|
+
const xScale=linearScale(lonD,[plot.left,plot.right]);
|
|
118
|
+
const yScale=linearScale(latD,[plot.bottom,plot.top]);
|
|
119
|
+
project=(lon,lat)=>[xScale.of(lon),yScale.of(lat)];
|
|
120
|
+
}
|
|
121
|
+
const radius=spec&&Number.isFinite(spec.radius)&&spec.radius>0?spec.radius:DEFAULT_RADIUS;
|
|
122
|
+
const pixels=points.map((p)=>{
|
|
123
|
+
const[x,y]=project(p.lon,p.lat);
|
|
124
|
+
return{px:x,py:y};
|
|
125
|
+
});
|
|
126
|
+
const bins=binHex(pixels,radius);
|
|
127
|
+
if(!bins.length)return{empty:true,legend:[],packed:!!fit};
|
|
128
|
+
let maxCount=0;
|
|
129
|
+
for(const b of bins)if(b.count>maxCount)maxCount=b.count;
|
|
130
|
+
const ramp=colourRamp(measureDomain([0,maxCount],{zero:true}),false,sch);
|
|
131
|
+
const third=Math.PI/3;
|
|
132
|
+
const hex=[];
|
|
133
|
+
for(let i=0;i<6;i++)hex.push([Math.sin(i*third)*radius,-Math.cos(i*third)*radius]);
|
|
134
|
+
for(const bin of bins){
|
|
135
|
+
const parts=['M'];
|
|
136
|
+
for(let i=0;i<6;i++){
|
|
137
|
+
parts.push(round(bin.x+hex[i][0]),round(bin.y+hex[i][1]));
|
|
138
|
+
if(i<5)parts.push('L');
|
|
139
|
+
}
|
|
140
|
+
parts.push('Z');
|
|
141
|
+
attrs(marks.next('path',`${NS}__hexmap-cell ${NS}__mark`),{
|
|
142
|
+
d:path(parts),
|
|
143
|
+
fill:ramp(bin.count),
|
|
144
|
+
stroke:'none',
|
|
145
|
+
'data-count':bin.count,
|
|
146
|
+
class:`${NS}__hexmap-cell ${NS}__mark`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
marks.finish();
|
|
150
|
+
return{
|
|
151
|
+
bins:bins.length,maxCount,legend:[],packed:!!fit,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
registerChartType('hexmap',{draw:drawHexMap,bind:bindHexMap,freeform:true,labelled:false});
|
|
155
|
+
const __default=drawHexMap;
|
|
156
|
+
});
|
|
157
|
+
var __entry=__req("packages/modules/chart-hexmap/index.js");
|
|
158
|
+
if(typeof module==='object'&&module.exports){module.exports=__entry;}
|
|
159
|
+
else if(typeof define==='function'&&define.amd){define(function(){return __entry;});}
|
|
160
|
+
else{
|
|
161
|
+
var __t=root["LatticeGrid"]||(root["LatticeGrid"]={});
|
|
162
|
+
for(var __k in __entry){if(__k!=='default')__t[__k]=__entry[__k];}
|
|
163
|
+
}
|
|
164
|
+
})(typeof globalThis!=='undefined'?globalThis:this);
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Lattice Grid 1.63.0, chart-hexmap 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-hexmap/index.js",function(__exports,__req){
|
|
31
|
+
'use strict';
|
|
32
|
+
Object.defineProperty(__exports,"bindHexMap",{enumerable:true,get:function(){return bindHexMap;}});
|
|
33
|
+
Object.defineProperty(__exports,"drawHexMap",{enumerable:true,get:function(){return drawHexMap;}});
|
|
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 DEFAULT_RADIUS=12;
|
|
38
|
+
function bindHexMap(grid,spec){
|
|
39
|
+
const points=[];
|
|
40
|
+
const n=grid.rows.count();
|
|
41
|
+
for(let i=0;i<n;i++){
|
|
42
|
+
const row=grid.rows.get(i);
|
|
43
|
+
if(!row||row.group)continue;
|
|
44
|
+
const lon=Number(grid.rows.value(row.key,spec.lon));
|
|
45
|
+
const lat=Number(grid.rows.value(row.key,spec.lat));
|
|
46
|
+
if(Number.isFinite(lon)&&Number.isFinite(lat))points.push({lon,lat});
|
|
47
|
+
}
|
|
48
|
+
return{points,empty:points.length===0};
|
|
49
|
+
}
|
|
50
|
+
function packProjection(opts){
|
|
51
|
+
const{spec,plot,helpers}=opts;
|
|
52
|
+
if(!spec||!spec.shapes)return null;
|
|
53
|
+
const{
|
|
54
|
+
resolvePack,packRegions,fitted,resolveProjection,
|
|
55
|
+
}=helpers;
|
|
56
|
+
const resolved=resolvePack(spec.shapes,spec.layer);
|
|
57
|
+
if(!resolved)return null;
|
|
58
|
+
const regions=packRegions(resolved.topology);
|
|
59
|
+
const project=resolveProjection(
|
|
60
|
+
spec.projection||resolved.pack.projection,
|
|
61
|
+
{...(resolved.pack.projectionOptions||{}),...(spec.projectionOptions||{})},
|
|
62
|
+
);
|
|
63
|
+
const fit=fitted({project,rings:regions.flatMap((r)=>r.rings),plot});
|
|
64
|
+
return{to:fit.to,regions};
|
|
65
|
+
}
|
|
66
|
+
function binHex(pts,r){
|
|
67
|
+
const dx=r*2*Math.sin(Math.PI/3);
|
|
68
|
+
const dy=r*1.5;
|
|
69
|
+
const bins=new Map();
|
|
70
|
+
for(const{px,py}of pts){
|
|
71
|
+
const y=py/dy;
|
|
72
|
+
let pj=Math.round(y);
|
|
73
|
+
const x=px/dx-(pj&1)/2;
|
|
74
|
+
let pi=Math.round(x);
|
|
75
|
+
const py1=y-pj;
|
|
76
|
+
if(Math.abs(py1)*3>1){
|
|
77
|
+
const px1=x-pi;
|
|
78
|
+
const pi2=pi+(x<pi?-1:1)/2;
|
|
79
|
+
const pj2=pj+(y<pj?-1:1);
|
|
80
|
+
const px2=x-pi2;
|
|
81
|
+
const py2=y-pj2;
|
|
82
|
+
if(px1*px1+py1*py1>px2*px2+py2*py2){pi=pi2+((pj&1)?1:-1)/2;pj=pj2;}
|
|
83
|
+
}
|
|
84
|
+
const k=`${pi}:${pj}`;
|
|
85
|
+
let bin=bins.get(k);
|
|
86
|
+
if(!bin){bin={x:(pi+(pj&1)/2)*dx,y:pj*dy,count:0};bins.set(k,bin);}
|
|
87
|
+
bin.count+=1;
|
|
88
|
+
}
|
|
89
|
+
return[...bins.values()];
|
|
90
|
+
}
|
|
91
|
+
function drawHexMap(ctx){
|
|
92
|
+
const{
|
|
93
|
+
plot,bound,scheme,groups,spec,helpers,
|
|
94
|
+
}=ctx;
|
|
95
|
+
const{
|
|
96
|
+
extent,measureDomain,linearScale,colourRamp,Pool,attrs,path,round,resolveScheme,
|
|
97
|
+
projectedPath,
|
|
98
|
+
}=helpers;
|
|
99
|
+
const NS=helpers.NS;
|
|
100
|
+
const sch=scheme||resolveScheme();
|
|
101
|
+
const{points}=bound;
|
|
102
|
+
const marks=new Pool(groups.marks);
|
|
103
|
+
const fit=packProjection({spec,plot,helpers});
|
|
104
|
+
let project;
|
|
105
|
+
if(fit){
|
|
106
|
+
for(const region of fit.regions){
|
|
107
|
+
const d=region.rings.map((ring)=>projectedPath(ring,fit.to)).filter(Boolean).join(' ');
|
|
108
|
+
if(!d)continue;
|
|
109
|
+
attrs(marks.next('path',`${NS}__region`),{
|
|
110
|
+
d,fill:'var(--lattice-chart-empty, #eceff1)',class:`${NS}__region`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
project=fit.to;
|
|
114
|
+
}else{
|
|
115
|
+
const lonD=extent(points.map((p)=>p.lon))||{min:0,max:1};
|
|
116
|
+
const latD=extent(points.map((p)=>p.lat))||{min:0,max:1};
|
|
117
|
+
const xScale=linearScale(lonD,[plot.left,plot.right]);
|
|
118
|
+
const yScale=linearScale(latD,[plot.bottom,plot.top]);
|
|
119
|
+
project=(lon,lat)=>[xScale.of(lon),yScale.of(lat)];
|
|
120
|
+
}
|
|
121
|
+
const radius=spec&&Number.isFinite(spec.radius)&&spec.radius>0?spec.radius:DEFAULT_RADIUS;
|
|
122
|
+
const pixels=points.map((p)=>{
|
|
123
|
+
const[x,y]=project(p.lon,p.lat);
|
|
124
|
+
return{px:x,py:y};
|
|
125
|
+
});
|
|
126
|
+
const bins=binHex(pixels,radius);
|
|
127
|
+
if(!bins.length)return{empty:true,legend:[],packed:!!fit};
|
|
128
|
+
let maxCount=0;
|
|
129
|
+
for(const b of bins)if(b.count>maxCount)maxCount=b.count;
|
|
130
|
+
const ramp=colourRamp(measureDomain([0,maxCount],{zero:true}),false,sch);
|
|
131
|
+
const third=Math.PI/3;
|
|
132
|
+
const hex=[];
|
|
133
|
+
for(let i=0;i<6;i++)hex.push([Math.sin(i*third)*radius,-Math.cos(i*third)*radius]);
|
|
134
|
+
for(const bin of bins){
|
|
135
|
+
const parts=['M'];
|
|
136
|
+
for(let i=0;i<6;i++){
|
|
137
|
+
parts.push(round(bin.x+hex[i][0]),round(bin.y+hex[i][1]));
|
|
138
|
+
if(i<5)parts.push('L');
|
|
139
|
+
}
|
|
140
|
+
parts.push('Z');
|
|
141
|
+
attrs(marks.next('path',`${NS}__hexmap-cell ${NS}__mark`),{
|
|
142
|
+
d:path(parts),
|
|
143
|
+
fill:ramp(bin.count),
|
|
144
|
+
stroke:'none',
|
|
145
|
+
'data-count':bin.count,
|
|
146
|
+
class:`${NS}__hexmap-cell ${NS}__mark`,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
marks.finish();
|
|
150
|
+
return{
|
|
151
|
+
bins:bins.length,maxCount,legend:[],packed:!!fit,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
registerChartType('hexmap',{draw:drawHexMap,bind:bindHexMap,freeform:true,labelled:false});
|
|
155
|
+
const __default=drawHexMap;
|
|
156
|
+
});
|
|
157
|
+
var __entry=__req("packages/modules/chart-hexmap/index.js");
|
|
158
|
+
if(typeof module==='object'&&module.exports){module.exports=__entry;}
|
|
159
|
+
else if(typeof define==='function'&&define.amd){define(function(){return __entry;});}
|
|
160
|
+
else{
|
|
161
|
+
var __t=root["LatticeGrid"]||(root["LatticeGrid"]={});
|
|
162
|
+
for(var __k in __entry){if(__k!=='default')__t[__k]=__entry[__k];}
|
|
163
|
+
}
|
|
164
|
+
})(typeof globalThis!=='undefined'?globalThis:this);
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Lattice Grid 1.63.0, chart-icicle 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-icicle/index.js",function(__exports,__req){
|
|
31
|
+
'use strict';
|
|
32
|
+
Object.defineProperty(__exports,"drawIcicle",{enumerable:true,get:function(){return drawIcicle;}});
|
|
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
|
+
function depthOf(node){
|
|
37
|
+
if(!node.children||!node.children.length)return 0;
|
|
38
|
+
let max=0;
|
|
39
|
+
for(const child of node.children)max=Math.max(max,depthOf(child));
|
|
40
|
+
return max+1;
|
|
41
|
+
}
|
|
42
|
+
function drawIcicle(ctx){
|
|
43
|
+
const{
|
|
44
|
+
plot,bound,scheme,fontSize,groups,helpers,
|
|
45
|
+
}=ctx;
|
|
46
|
+
const{
|
|
47
|
+
Pool,attrs,round,setText,resolveScheme,NS,
|
|
48
|
+
}=helpers;
|
|
49
|
+
const sch=scheme||resolveScheme();
|
|
50
|
+
const root=bound.root;
|
|
51
|
+
if(!root||!root.children||!root.children.length)return{empty:true,legend:[]};
|
|
52
|
+
const levels=Math.max(1,depthOf(root));
|
|
53
|
+
const rowH=(plot.bottom-plot.top)/levels;
|
|
54
|
+
const marks=new Pool(groups.marks);
|
|
55
|
+
const overlay=new Pool(groups.overlay);
|
|
56
|
+
let drawn=0;
|
|
57
|
+
const layout=(node,x0,x1,depth,topIndex)=>{
|
|
58
|
+
const children=node.children||[];
|
|
59
|
+
const total=children.reduce((t,c)=>t+(c.total||0),0)||1;
|
|
60
|
+
let cursor=x0;
|
|
61
|
+
children.forEach((child,i)=>{
|
|
62
|
+
const w=((child.total||0)/total)*(x1-x0);
|
|
63
|
+
const left=cursor;
|
|
64
|
+
const right=cursor+w;
|
|
65
|
+
cursor=right;
|
|
66
|
+
const colourIndex=depth===1?i:topIndex;
|
|
67
|
+
const y=plot.top+(depth-1)*rowH;
|
|
68
|
+
attrs(marks.next('rect',`${NS}__icicle-cell ${NS}__mark`),{
|
|
69
|
+
x:round(left),y:round(y),width:round(Math.max(0,right-left-1)),height:round(Math.max(0,rowH-1)),
|
|
70
|
+
fill:sch.series(colourIndex),'fill-opacity':0.85,stroke:'currentColor','stroke-opacity':0.15,
|
|
71
|
+
'data-depth':depth,
|
|
72
|
+
});
|
|
73
|
+
drawn+=1;
|
|
74
|
+
if(w>fontSize*3){
|
|
75
|
+
const label=overlay.next('text',`${NS}__icicle-label`);
|
|
76
|
+
setText(label,String(child.label));
|
|
77
|
+
attrs(label,{x:round(left+3),y:round(y+fontSize),'font-size':fontSize});
|
|
78
|
+
}
|
|
79
|
+
if(child.children&&child.children.length)layout(child,left,right,depth+1,colourIndex);
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
layout(root,plot.left,plot.right,1,0);
|
|
83
|
+
marks.finish();
|
|
84
|
+
overlay.finish();
|
|
85
|
+
return{cells:drawn,levels,legend:[]};
|
|
86
|
+
}
|
|
87
|
+
registerChartType('icicle',{draw:drawIcicle,hierarchical:true,freeform:true,labelled:false});
|
|
88
|
+
const __default=drawIcicle;
|
|
89
|
+
});
|
|
90
|
+
var __entry=__req("packages/modules/chart-icicle/index.js");
|
|
91
|
+
if(typeof module==='object'&&module.exports){module.exports=__entry;}
|
|
92
|
+
else if(typeof define==='function'&&define.amd){define(function(){return __entry;});}
|
|
93
|
+
else{
|
|
94
|
+
var __t=root["LatticeGrid"]||(root["LatticeGrid"]={});
|
|
95
|
+
for(var __k in __entry){if(__k!=='default')__t[__k]=__entry[__k];}
|
|
96
|
+
}
|
|
97
|
+
})(typeof globalThis!=='undefined'?globalThis:this);
|