@toclocoinc/lattice-grid 1.9.0 → 1.10.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 +6 -5
- package/docs/API.html +202 -5
- package/docs/api-detail.html +1 -1
- package/lattice-grid.d.ts +255 -4
- package/lattice-grid.esm.min.js +789 -116
- package/lattice-grid.min.cjs +784 -116
- package/lattice-grid.min.css +1 -1
- package/lattice-grid.min.js +784 -116
- package/modules/charts.esm.min.js +91 -30
- package/modules/devtools.esm.min.js +1 -1
- package/modules/dhtmlx-compat.esm.min.js +784 -116
- package/modules/htmx.esm.min.js +490 -51
- package/modules/htmx.min.cjs +490 -51
- package/modules/htmx.min.js +490 -51
- package/modules/react.esm.min.js +1 -1
- package/modules/svelte.esm.min.js +1 -1
- package/modules/vue.esm.min.js +1 -1
- package/modules/webcomponent.esm.min.js +784 -116
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.10.0 — charts module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
@@ -2027,11 +2027,12 @@ function reduce(bucket,fn){
|
|
|
2027
2027
|
const kernel=AGGREGATIONS[fn]||AGGREGATIONS[DEFAULT_AGGREGATION];
|
|
2028
2028
|
return kernel(bucket.values,bucket.rows);
|
|
2029
2029
|
}
|
|
2030
|
+
const NUMERIC_TYPES=Object.freeze(['number','currency','percent']);
|
|
2030
2031
|
function scaleKindFor(column,values){
|
|
2031
2032
|
const type=column&&typeof column.type==='string'?column.type:'';
|
|
2032
2033
|
if(type==='date'||type==='datetime')return'time';
|
|
2033
2034
|
if(values.length&&values.every((v)=>v instanceof Date))return'time';
|
|
2034
|
-
if(type
|
|
2035
|
+
if(NUMERIC_TYPES.includes(type)){
|
|
2035
2036
|
const distinct=new Set(values.map(key));
|
|
2036
2037
|
return distinct.size>12?'linear':'category';
|
|
2037
2038
|
}
|
|
@@ -2040,7 +2041,9 @@ return'category';
|
|
|
2040
2041
|
function bindSeries(grid,spec){
|
|
2041
2042
|
const measure=measureOf(spec.y);
|
|
2042
2043
|
const dimensionId=spec.x||null;
|
|
2043
|
-
const seriesId=spec.series
|
|
2044
|
+
const seriesId=spec.series
|
|
2045
|
+
||(typeof spec.multiples==='string'?spec.multiples:null)
|
|
2046
|
+
||null;
|
|
2044
2047
|
const columns=grid.columns;
|
|
2045
2048
|
const dimensionColumn=dimensionId?columns.get(dimensionId):undefined;
|
|
2046
2049
|
const measureColumn=measure.col?columns.get(measure.col):undefined;
|
|
@@ -2091,9 +2094,16 @@ if(extra!==null)point.sizes=(point.sizes||0)+extra;
|
|
|
2091
2094
|
}
|
|
2092
2095
|
}
|
|
2093
2096
|
const ordered=[...categories.values()].sort((a,b)=>a.order-b.order);
|
|
2094
|
-
const
|
|
2097
|
+
const taken=typeof spec.limit==='number'&&spec.limit>0
|
|
2095
2098
|
?ordered.slice(0,spec.limit)
|
|
2096
2099
|
:ordered;
|
|
2100
|
+
const kind=scaleKindFor(dimensionColumn,seenValues);
|
|
2101
|
+
const numeric=NUMERIC_TYPES.includes(
|
|
2102
|
+
dimensionColumn&&typeof dimensionColumn.type==='string'?dimensionColumn.type:'',
|
|
2103
|
+
);
|
|
2104
|
+
const limited=kind==='category'&&numeric
|
|
2105
|
+
?[...taken].sort((a,b)=>(toNumber(a.value)??0)-(toNumber(b.value)??0))
|
|
2106
|
+
:taken;
|
|
2097
2107
|
const out=[...series.entries()].map(([sKey,bucket],index)=>({
|
|
2098
2108
|
key:sKey,
|
|
2099
2109
|
label:bucket.label,
|
|
@@ -2116,7 +2126,7 @@ return{
|
|
|
2116
2126
|
series:out,
|
|
2117
2127
|
categories:limited.map((c)=>c.value),
|
|
2118
2128
|
labels:limited.map((c)=>c.label),
|
|
2119
|
-
kind
|
|
2129
|
+
kind,
|
|
2120
2130
|
measure:{...measure,title:measureColumn?.title||measure.col||''},
|
|
2121
2131
|
dimension:{col:dimensionId,title:dimensionColumn?.title||dimensionId||''},
|
|
2122
2132
|
empty:out.length===0||limited.length===0,
|
|
@@ -4022,6 +4032,7 @@ __def("packages/modules/charts/geo.js",function(__exports,__req){
|
|
|
4022
4032
|
'use strict';
|
|
4023
4033
|
Object.defineProperty(__exports,"CONTINENTS",{enumerable:true,get:function(){return CONTINENTS;}});
|
|
4024
4034
|
Object.defineProperty(__exports,"CONTINENT_NAMES",{enumerable:true,get:function(){return CONTINENT_NAMES;}});
|
|
4035
|
+
Object.defineProperty(__exports,"OUTLINES",{enumerable:true,get:function(){return OUTLINES;}});
|
|
4025
4036
|
Object.defineProperty(__exports,"COUNTRY_CONTINENT",{enumerable:true,get:function(){return COUNTRY_CONTINENT;}});
|
|
4026
4037
|
Object.defineProperty(__exports,"ALPHA3",{enumerable:true,get:function(){return ALPHA3;}});
|
|
4027
4038
|
Object.defineProperty(__exports,"NUMERIC",{enumerable:true,get:function(){return NUMERIC;}});
|
|
@@ -4058,22 +4069,60 @@ OC:'Oceania',
|
|
|
4058
4069
|
SA:'South America',
|
|
4059
4070
|
});
|
|
4060
4071
|
const OUTLINES=Object.freeze({
|
|
4061
|
-
NA:[
|
|
4062
|
-
[-
|
|
4063
|
-
|
|
4064
|
-
[-
|
|
4065
|
-
|
|
4066
|
-
[
|
|
4067
|
-
|
|
4068
|
-
[
|
|
4069
|
-
[-
|
|
4070
|
-
|
|
4071
|
-
|
|
4072
|
-
[
|
|
4073
|
-
|
|
4074
|
-
[
|
|
4075
|
-
|
|
4076
|
-
[
|
|
4072
|
+
NA:[
|
|
4073
|
+
[[-168,66],[-156,71],[-130,70],[-115,69],[-100,69],[-85,70],[-75,73],
|
|
4074
|
+
[-64,66],[-78,62],[-79,55],[-65,60],[-56,52],[-60,45],[-67,45],
|
|
4075
|
+
[-70,42],[-74,40],[-76,37],[-81,32],[-80,27],[-81,25],[-84,30],
|
|
4076
|
+
[-90,29],[-94,29],[-97,26],[-97,21],[-91,19],[-88,21],[-87,16],
|
|
4077
|
+
[-83,9],[-79,9],[-85,13],[-92,16],[-96,16],[-105,20],[-110,24],
|
|
4078
|
+
[-114,28],[-117,32],[-122,37],[-124,42],[-124,48],[-130,55],
|
|
4079
|
+
[-140,60],[-150,59],[-160,55],[-165,60],[-168,66]],
|
|
4080
|
+
[[-43,60],[-32,64],[-22,70],[-20,74],[-25,78],[-33,83],[-45,83],
|
|
4081
|
+
[-58,82],[-62,76],[-56,70],[-55,66],[-52,61],[-43,60]],
|
|
4082
|
+
],
|
|
4083
|
+
SA:[[[-81,12],[-72,12],[-62,11],[-52,5],[-50,0],[-44,-2],[-35,-6],
|
|
4084
|
+
[-38,-13],[-39,-18],[-48,-25],[-53,-34],[-57,-38],[-62,-40],[-65,-45],
|
|
4085
|
+
[-68,-52],[-75,-53],[-73,-45],[-73,-37],[-71,-30],[-70,-23],[-71,-18],
|
|
4086
|
+
[-76,-14],[-81,-6],[-80,-2],[-78,1],[-77,8],[-81,12]]],
|
|
4087
|
+
EU:[
|
|
4088
|
+
[[-10,36],[-9,44],[-2,43],[-4,48],[-1,49],[4,52],[7,53],[8,57],
|
|
4089
|
+
[10,58],[5,58],[5,62],[11,64],[15,69],[21,70],[28,71],[32,70],
|
|
4090
|
+
[40,67],[44,68],[50,69],[60,70],[60,60],[58,52],[50,46],[40,44],
|
|
4091
|
+
[36,45],[30,46],[28,41],[26,40],[23,38],[18,40],[13,38],[15,37],
|
|
4092
|
+
[12,44],[8,44],[3,42],[-2,37],[-10,36]],
|
|
4093
|
+
[[-5,50],[1,51],[2,53],[-1,55],[-3,58],[-5,58],[-6,55],[-5,50]],
|
|
4094
|
+
[[-10,52],[-6,52],[-6,55],[-10,55],[-10,52]],
|
|
4095
|
+
],
|
|
4096
|
+
AF:[[[-17,21],[-16,15],[-17,12],[-13,8],[-8,5],[-3,5],[3,6],[8,4],
|
|
4097
|
+
[9,2],[10,-2],[12,-6],[12,-12],[14,-18],[15,-23],[18,-29],[23,-34],
|
|
4098
|
+
[27,-34],[32,-29],[33,-26],[35,-22],[40,-16],[41,-10],[40,-3],[43,0],
|
|
4099
|
+
[51,4],[51,11],[45,12],[43,12],[39,15],[37,21],[34,28],[32,31],
|
|
4100
|
+
[25,32],[20,31],[15,32],[10,37],[3,36],[-2,35],[-6,36],[-10,30],
|
|
4101
|
+
[-13,27],[-17,21]]],
|
|
4102
|
+
AS:[
|
|
4103
|
+
[[26,40],[35,36],[36,31],[43,30],[48,30],[50,27],[56,25],[57,22],
|
|
4104
|
+
[60,25],[62,25],[67,24],[70,21],[73,16],[77,8],[80,6],[80,13],
|
|
4105
|
+
[84,19],[87,21],[92,21],[95,16],[98,10],[104,1],[104,10],[107,11],
|
|
4106
|
+
[109,17],[117,23],[122,30],[122,37],[126,34],[129,35],[130,43],
|
|
4107
|
+
[135,45],[142,45],[143,53],[140,58],[155,59],[162,60],[170,66],
|
|
4108
|
+
[180,68],[170,71],[150,73],[130,74],[110,76],[90,76],[75,73],
|
|
4109
|
+
[70,70],[60,70],[60,60],[58,52],[50,46],[40,44],[36,45],[30,46],
|
|
4110
|
+
[28,41],[26,40]],
|
|
4111
|
+
[[130,31],[132,32],[135,33],[137,34],[140,35],[141,38],[141,41],
|
|
4112
|
+
[142,42],[145,43],[145,45],[141,45],[140,42],[139,40],[137,37],
|
|
4113
|
+
[135,35],[133,34],[131,33],[130,31]],
|
|
4114
|
+
],
|
|
4115
|
+
OC:[
|
|
4116
|
+
[[113,-22],[114,-26],[115,-34],[119,-34],[126,-32],[132,-32],[137,-35],
|
|
4117
|
+
[141,-38],[147,-38],[150,-37],[153,-30],[153,-25],[146,-19],[142,-11],
|
|
4118
|
+
[136,-12],[130,-12],[126,-14],[122,-18],[113,-22]],
|
|
4119
|
+
[[145,-41],[148,-41],[148,-43],[145,-43],[145,-41]],
|
|
4120
|
+
[[173,-35],[178,-38],[174,-41],[172,-43],[167,-46],[170,-44],[173,-35]],
|
|
4121
|
+
],
|
|
4122
|
+
AN:[[[-180,-78],[-150,-76],[-120,-74],[-100,-73],[-80,-72],[-60,-63],
|
|
4123
|
+
[-45,-60],[-58,-64],[-70,-70],[-60,-76],[-30,-77],[0,-70],[20,-70],
|
|
4124
|
+
[40,-68],[60,-67],[80,-66],[100,-66],[120,-66],[140,-66],[160,-78],
|
|
4125
|
+
[170,-84],[180,-85],[-180,-85],[-180,-78]]],
|
|
4077
4126
|
});
|
|
4078
4127
|
const COUNTRY_CONTINENT=Object.freeze({
|
|
4079
4128
|
AD:'EU',AE:'AS',AF:'AS',AG:'NA',AI:'NA',AL:'EU',AM:'AS',AO:'AF',AQ:'AN',
|
|
@@ -4169,21 +4218,30 @@ if(CONTINENTS.includes(code)&&!(code in COUNTRY_CONTINENT))return code;
|
|
|
4169
4218
|
if(CONTINENTS.includes(code))return code;
|
|
4170
4219
|
return COUNTRY_CONTINENT[code]||null;
|
|
4171
4220
|
}
|
|
4172
|
-
function projection(plot){
|
|
4173
|
-
const
|
|
4221
|
+
function projection(plot,opts={}){
|
|
4222
|
+
const south=opts.antarctic?-90:-58;
|
|
4223
|
+
const north=84;
|
|
4224
|
+
const span=north-south;
|
|
4225
|
+
const scale=Math.min(plot.width/360,plot.height/span);
|
|
4174
4226
|
const width=360*scale;
|
|
4175
|
-
const height=
|
|
4227
|
+
const height=span*scale;
|
|
4176
4228
|
const left=plot.left+(plot.width-width)/2;
|
|
4177
4229
|
const top=plot.top+(plot.height-height)/2;
|
|
4178
|
-
return(lon,lat)=>[left+(lon+180)*scale,top+(
|
|
4230
|
+
return(lon,lat)=>[left+(lon+180)*scale,top+(north-lat)*scale];
|
|
4179
4231
|
}
|
|
4180
4232
|
function ringPath(ring,project){
|
|
4233
|
+
const rings=Array.isArray(ring)&&Array.isArray(ring[0])&&Array.isArray(ring[0][0])
|
|
4234
|
+
?ring
|
|
4235
|
+
:[ring];
|
|
4181
4236
|
const parts=[];
|
|
4182
|
-
for(
|
|
4183
|
-
|
|
4237
|
+
for(const one of rings){
|
|
4238
|
+
if(!Array.isArray(one)||!one.length)continue;
|
|
4239
|
+
for(let i=0;i<one.length;i++){
|
|
4240
|
+
const[x,y]=project(one[i][0],one[i][1]);
|
|
4184
4241
|
parts.push(i?'L':'M',round(x),round(y));
|
|
4185
4242
|
}
|
|
4186
|
-
|
|
4243
|
+
parts.push('Z');
|
|
4244
|
+
}
|
|
4187
4245
|
return path(parts);
|
|
4188
4246
|
}
|
|
4189
4247
|
function shapesToPaths(opts){
|
|
@@ -4226,7 +4284,6 @@ new Pool(ctx.groups.labels).finish();
|
|
|
4226
4284
|
const supplied=shapesToPaths({
|
|
4227
4285
|
shapes:ctx.shapes,plot,codeProperty:ctx.codeProperty,
|
|
4228
4286
|
});
|
|
4229
|
-
const project=projection(plot);
|
|
4230
4287
|
const useCountries=supplied.size>0;
|
|
4231
4288
|
const totals=new Map();
|
|
4232
4289
|
const unmatched=[];
|
|
@@ -4247,13 +4304,17 @@ entry.labels.push(bound.labels[i]);
|
|
|
4247
4304
|
totals.set(target,entry);
|
|
4248
4305
|
}
|
|
4249
4306
|
}
|
|
4307
|
+
const antarctic=totals.has('AN');
|
|
4308
|
+
const project=projection(plot,{antarctic});
|
|
4250
4309
|
const domain=measureDomain([...totals.values()].map((e)=>e.value),{
|
|
4251
4310
|
zero:!ctx.diverging,nice:false,
|
|
4252
4311
|
});
|
|
4253
4312
|
const ramp=colourRamp(domain,!!ctx.diverging,scheme);
|
|
4254
4313
|
const pool=new Pool(ctx.groups.marks);
|
|
4255
4314
|
const regions=[];
|
|
4256
|
-
const codes=useCountries
|
|
4315
|
+
const codes=useCountries
|
|
4316
|
+
?[...supplied.keys()]
|
|
4317
|
+
:CONTINENTS.filter((code)=>code!=='AN'||antarctic);
|
|
4257
4318
|
for(const code of codes){
|
|
4258
4319
|
const d=useCountries?supplied.get(code):ringPath(OUTLINES[code],project);
|
|
4259
4320
|
const entry=totals.get(code);
|