@gramlot/gramlot 0.3.32 → 0.3.34

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 (129) hide show
  1. package/dist/components/audio/__init__.py +1 -1
  2. package/dist/components/audio/assets/collection.js +2 -2
  3. package/dist/components/audio/assets/index.js +1 -1
  4. package/dist/components/charts/__init__.py +2 -2
  5. package/dist/components/charts/assets/collection.js +24 -43
  6. package/dist/components/charts/assets/index.js +1 -1
  7. package/dist/components/charts/assets/modules/chunk-USZCUBTC.js +1 -0
  8. package/dist/components/charts/assets/modules/echarts-gl.min-N6L67H2M.js +4282 -0
  9. package/dist/components/charts/assets/modules/echarts.esm.min-VHLRZDVQ.js +61 -0
  10. package/dist/components/charts/assets/modules/{plotly.min-4LB7HE7P.js → plotly.min-SSDU2DOH.js} +1 -1
  11. package/dist/components/charts/assets/modules/{uPlot.esm-5JJNHHRF.js → uPlot.esm-Q2UYUQHJ.js} +1 -1
  12. package/dist/components/charts/assets/modules/{uPlot.min-N3E3FA74.js → uPlot.min-XXHNQFXH.js} +1 -1
  13. package/dist/components/charts/assets/modules/{vega.module-2QCOVQ3A.js → vega.module-Y5CWNSZO.js} +1 -1
  14. package/dist/components/charts/grammar.json +15482 -232
  15. package/dist/components/chat/__init__.py +1 -1
  16. package/dist/components/chat/assets/collection.js +3 -3
  17. package/dist/components/chat/assets/index.js +1 -1
  18. package/dist/components/drawing/__init__.py +1 -1
  19. package/dist/components/drawing/assets/collection.js +3 -24
  20. package/dist/components/drawing/assets/index.js +1 -1
  21. package/dist/components/editors/__init__.py +2 -2
  22. package/dist/components/editors/assets/collection.js +2 -47
  23. package/dist/components/editors/assets/index.js +1 -1
  24. package/dist/components/editors/assets/modules/{jodit-engine-MTSA4GZ3.js → jodit-engine-CXRSFV47.js} +6 -6
  25. package/dist/components/grid/__init__.py +2 -2
  26. package/dist/components/grid/assets/collection.js +6 -28
  27. package/dist/components/grid/assets/index.js +1 -1
  28. package/dist/components/grid/assets/modules/{browser-LVJHKBBV.js → browser-Y2BRNI3P.js} +1 -1
  29. package/dist/components/grid/assets/modules/chunk-BLMUM44K.js +1 -0
  30. package/dist/components/grouplets/__init__.py +1 -1
  31. package/dist/components/grouplets/assets/collection.js +3 -3
  32. package/dist/components/grouplets/assets/index.js +1 -1
  33. package/dist/components/inputs/__init__.py +1 -1
  34. package/dist/components/inputs/assets/collection.js +8 -65
  35. package/dist/components/inputs/assets/index.js +1 -1
  36. package/dist/components/layout/__init__.py +1 -1
  37. package/dist/components/layout/assets/collection.js +9 -30
  38. package/dist/components/layout/assets/index.js +1 -1
  39. package/dist/components/selection_trial/__init__.py +1 -1
  40. package/dist/components/selection_trial/assets/collection.js +3 -3
  41. package/dist/components/selection_trial/assets/index.js +1 -1
  42. package/dist/components/tree/__init__.py +1 -1
  43. package/dist/components/tree/assets/collection.js +6 -27
  44. package/dist/components/tree/assets/index.js +1 -1
  45. package/dist/components/typst/__init__.py +1 -1
  46. package/dist/components/typst/assets/collection.js +3 -3
  47. package/dist/components/typst/assets/index.js +1 -1
  48. package/dist/components/uploads/__init__.py +1 -1
  49. package/dist/components/uploads/assets/collection.js +3 -30
  50. package/dist/components/uploads/assets/index.js +1 -1
  51. package/dist/components/vizabi/__init__.py +1 -1
  52. package/dist/components/vizabi/assets/collection.js +3 -21
  53. package/dist/components/vizabi/assets/index.js +1 -1
  54. package/dist/gramlot.js +1599 -59
  55. package/dist/gramlot.min.js +49 -48
  56. package/dist/libraries.json +126 -0
  57. package/dist/runtime-notices.json +4 -0
  58. package/dist/standard-collections.js +1 -1
  59. package/package.json +2 -2
  60. package/src/components/chart-boxplot-options.js +22 -0
  61. package/src/components/chart-candlestick-options.js +27 -0
  62. package/src/components/chart-controls.js +28 -6
  63. package/src/components/chart-domains.js +1 -1
  64. package/src/components/chart-engines/echarts.js +28 -4
  65. package/src/components/chart-engines/plotly.js +3 -2
  66. package/src/components/chart-engines/uplot.js +5 -3
  67. package/src/components/chart-engines/vega.js +2 -1
  68. package/src/components/chart-fields.js +11 -1
  69. package/src/components/chart-funnel-options.js +19 -0
  70. package/src/components/chart-gauge-options.js +98 -0
  71. package/src/components/chart-gauge.js +109 -0
  72. package/src/components/chart-heatmap-options.js +29 -0
  73. package/src/components/chart-notice.js +126 -0
  74. package/src/components/chart-pane.js +7 -1
  75. package/src/components/chart-parallel-options.js +24 -0
  76. package/src/components/chart-radar-options.js +29 -0
  77. package/src/components/chart-renderer.js +3 -9
  78. package/src/components/chart-sankey-options.js +43 -0
  79. package/src/components/chart-sunburst-options.js +12 -0
  80. package/src/components/chart-syntax.js +82 -0
  81. package/src/components/chart-time.js +2 -1
  82. package/src/components/chart-treemap-options.js +16 -0
  83. package/src/components/chart-type-data.js +62 -0
  84. package/src/components/chart-types/area.js +6 -1
  85. package/src/components/chart-types/bar.js +6 -1
  86. package/src/components/chart-types/bar3D.js +7 -1
  87. package/src/components/chart-types/boxplot.js +11 -0
  88. package/src/components/chart-types/candlestick.js +10 -0
  89. package/src/components/chart-types/donut.js +6 -1
  90. package/src/components/chart-types/funnel.js +7 -0
  91. package/src/components/chart-types/heatmap.js +8 -0
  92. package/src/components/chart-types/horizontalBar.js +6 -1
  93. package/src/components/chart-types/index.js +21 -1
  94. package/src/components/chart-types/line.js +6 -1
  95. package/src/components/chart-types/line3D.js +7 -1
  96. package/src/components/chart-types/lines3D.js +7 -1
  97. package/src/components/chart-types/map.js +7 -1
  98. package/src/components/chart-types/map3D.js +6 -1
  99. package/src/components/chart-types/mapBar3D.js +6 -1
  100. package/src/components/chart-types/parallel.js +7 -0
  101. package/src/components/chart-types/pie.js +6 -1
  102. package/src/components/chart-types/polygons3D.js +7 -1
  103. package/src/components/chart-types/radar.js +7 -0
  104. package/src/components/chart-types/sankey.js +8 -0
  105. package/src/components/chart-types/scatter.js +6 -1
  106. package/src/components/chart-types/scatter3D.js +7 -1
  107. package/src/components/chart-types/stackedArea.js +6 -1
  108. package/src/components/chart-types/stackedBar.js +6 -1
  109. package/src/components/chart-types/sunburst.js +7 -0
  110. package/src/components/chart-types/surface.js +7 -1
  111. package/src/components/chart-types/treemap.js +7 -0
  112. package/src/components/charts.js +60 -13
  113. package/src/components/code-mirror.js +2 -1
  114. package/src/components/grid-tools.js +2 -1
  115. package/src/components/html-editor.js +2 -1
  116. package/src/components/markdown-editor.js +2 -1
  117. package/src/components/registry.js +9 -5
  118. package/src/components/typst-preview.js +2 -1
  119. package/src/index.d.ts +16 -0
  120. package/src/index.js +5 -0
  121. package/src/libraries.js +83 -0
  122. package/src/page-store-connection.js +15 -5
  123. package/src/server/gramlot-server.d.ts +8 -0
  124. package/src/server/gramlot-server.js +40 -4
  125. package/src/shared-modules.js +79 -0
  126. package/dist/components/charts/assets/modules/chunk-2CCTLZE7.js +0 -76
  127. package/dist/components/charts/assets/modules/chunk-RMRBEYTI.js +0 -1
  128. package/dist/components/charts/assets/modules/echarts-gl-CXVTZA6G.js +0 -4409
  129. package/dist/components/grid/assets/modules/chunk-RMRBEYTI.js +0 -1
@@ -0,0 +1,126 @@
1
+ import {ChartSyntaxError} from './chart-syntax.js';
2
+ import {chartTypes} from './chart-types/index.js';
3
+
4
+ // The icon is a styled glyph, not an svg: the svg inside a chart view is always the chart.
5
+ const ICONS = {error:'!', info:'i'};
6
+
7
+ /** Shadow-root styles of the notice; colours follow the `--gramlot-*` theme variables. */
8
+ export const CHART_NOTICE_STYLE = `
9
+ .chart-notice{display:flex;align-items:flex-start;gap:10px;padding:16px 20px;font:13px/1.45 var(--gramlot-font-ui,system-ui,sans-serif);color:var(--gramlot-ink,#243449)}
10
+ .chart-notice[hidden]{display:none}
11
+ .chart-notice-icon{flex:none;display:grid;place-items:center;inline-size:20px;block-size:20px;border-radius:50%;font:700 13px/1 var(--gramlot-font-ui,system-ui,sans-serif);color:var(--gramlot-surface,#fff)}
12
+ .chart-notice[data-kind=error] .chart-notice-icon{background:var(--gramlot-error,#b13d48)}
13
+ .chart-notice[data-kind=info] .chart-notice-icon{background:var(--gramlot-text-secondary,#566579)}
14
+ .chart-notice-text{flex:1;min-inline-size:0;white-space:normal;overflow-wrap:anywhere}
15
+ .chart-notice button{flex:none;font:inherit;padding:2px 10px;border:1px solid var(--gramlot-border-control,#a9b4c2);border-radius:var(--gramlot-radius-sm,4px);background:var(--gramlot-surface,#fff);color:inherit;cursor:pointer}
16
+ .chart-notice-dialog{max-inline-size:min(640px,calc(100vw - 32px));border:1px solid var(--gramlot-border,#d5dce5);border-radius:var(--gramlot-radius,6px);padding:20px 24px;background:var(--gramlot-surface,#fff);color:var(--gramlot-ink,#243449);font:13px/1.5 var(--gramlot-font-ui,system-ui,sans-serif)}
17
+ .chart-notice-dialog h2{margin:0 0 12px;font-size:16px}
18
+ .chart-notice-dialog h3{margin:14px 0 4px;font-size:13px}
19
+ .chart-notice-dialog p{margin:0 0 6px}
20
+ .chart-notice-dialog table{border-collapse:collapse;inline-size:100%}
21
+ .chart-notice-dialog th,.chart-notice-dialog td{border-block-end:1px solid var(--gramlot-border,#d5dce5);padding:4px 6px;text-align:start;vertical-align:top}
22
+ .chart-notice-dialog code{font-family:var(--gramlot-font-code,ui-monospace,monospace)}
23
+ .chart-notice-dialog form{margin-block-start:16px;text-align:end}`;
24
+
25
+ function roleParameter(role, roles) {
26
+ if (role.parameter !== 'valueFields' || role.count === 'many') return role.parameter;
27
+ const fixed = roles.filter(item => item.parameter === 'valueFields');
28
+ return fixed.length === 1 ? 'valueFields' : `valueFields, position ${fixed.indexOf(role) + 1}`;
29
+ }
30
+
31
+ /** The sections that explain a chart type: what it shows and the columns it reads. */
32
+ export function chartTypeSections(type) {
33
+ return [
34
+ {title:`What ${type.label.toLowerCase()} shows`, paragraphs:[type.doc]},
35
+ {title:'Columns it reads', table:[['Column','Parameter','Required','Description'],
36
+ ...type.syntax.map(role => [role.caption, roleParameter(role, type.syntax), role.required ? 'yes' : 'no',
37
+ role.count === 'many' ? `One or more. ${role.doc}` : role.doc])]}
38
+ ];
39
+ }
40
+
41
+ /** The sections that explain a chart error; `type` is null when the chart type itself is unknown. */
42
+ export function chartErrorSections(error, type) {
43
+ if (error instanceof ChartSyntaxError) {
44
+ const {expected, received, fix} = error.diagnosis;
45
+ return [
46
+ {title:'What is wrong', paragraphs:[error.message]},
47
+ {title:'Expected', paragraphs:[expected]},
48
+ {title:'Received', paragraphs:[received]},
49
+ {title:'How to fix it', paragraphs:[fix]},
50
+ ...chartTypeSections(type)
51
+ ];
52
+ }
53
+ if (!type) return [
54
+ {title:'What is wrong', paragraphs:[error.message]},
55
+ {title:'Supported chart types', paragraphs:[chartTypes.map(item => `${item.id} (${item.label})`).join(', ')]}
56
+ ];
57
+ return [{title:'What is wrong', paragraphs:[error.message]}, ...chartTypeSections(type)];
58
+ }
59
+
60
+ /**
61
+ * The notice shown in place of a chart that is not drawn: an icon, one line and "More info",
62
+ * which opens a dialog with the explanation. `error` uses role alert, `info` role status.
63
+ */
64
+ export class ChartNotice {
65
+ #box; #icon; #text; #dialog; #sections = [];
66
+ constructor(doc) {
67
+ this.#box = doc.createElement('div');
68
+ this.#box.className = 'chart-notice'; this.#box.hidden = true;
69
+ this.#icon = doc.createElement('span');
70
+ this.#icon.className = 'chart-notice-icon'; this.#icon.setAttribute('aria-hidden', 'true');
71
+ this.#text = doc.createElement('div'); this.#text.className = 'chart-notice-text'; this.#text.hidden = true;
72
+ this.#text.setAttribute('role', 'alert');
73
+ const more = doc.createElement('button');
74
+ more.type = 'button'; more.textContent = 'More info';
75
+ more.addEventListener('click', () => this.open());
76
+ this.#dialog = doc.createElement('dialog');
77
+ this.#dialog.className = 'chart-notice-dialog';
78
+ this.#box.append(this.#icon, this.#text, more, this.#dialog);
79
+ }
80
+ get element() { return this.#box; }
81
+ get hidden() { return this.#box.hidden; }
82
+ get dialog() { return this.#dialog; }
83
+ get text() { return this.#text; }
84
+
85
+ error(message, title, sections) { this.#show('error', 'alert', message, title, sections); }
86
+ info(message, title, sections) { this.#show('info', 'status', message, title, sections); }
87
+ hide() {
88
+ this.#box.hidden = this.#text.hidden = true; this.#text.textContent = '';
89
+ if (this.#dialog.open) this.#dialog.close();
90
+ }
91
+
92
+ /** Fill and open the dialog with the explanation of the current notice. */
93
+ open() {
94
+ const doc = this.#dialog.ownerDocument;
95
+ const heading = doc.createElement('h2'); heading.textContent = this.#sections.title;
96
+ const parts = [heading];
97
+ for (const section of this.#sections.items) {
98
+ const title = doc.createElement('h3'); title.textContent = section.title; parts.push(title);
99
+ for (const text of section.paragraphs ?? []) { const p = doc.createElement('p'); p.textContent = text; parts.push(p); }
100
+ if (section.table) {
101
+ const table = doc.createElement('table');
102
+ section.table.forEach((cells, index) => {
103
+ const row = table.insertRow();
104
+ for (const value of cells) {
105
+ const cell = doc.createElement(index ? 'td' : 'th'); cell.textContent = value; row.append(cell);
106
+ }
107
+ });
108
+ parts.push(table);
109
+ }
110
+ }
111
+ const form = doc.createElement('form'); form.method = 'dialog';
112
+ const close = doc.createElement('button'); close.textContent = 'Close'; form.append(close);
113
+ parts.push(form);
114
+ this.#dialog.replaceChildren(...parts);
115
+ this.#dialog.showModal();
116
+ }
117
+
118
+ #show(kind, role, message, title, sections) {
119
+ this.#box.dataset.kind = kind;
120
+ this.#text.setAttribute('role', role);
121
+ this.#icon.textContent = ICONS[kind];
122
+ this.#text.textContent = message;
123
+ this.#sections = {title, items:sections};
124
+ this.#box.hidden = this.#text.hidden = false;
125
+ }
126
+ }
@@ -4,6 +4,7 @@ import {Container} from './container.js';
4
4
  import {randomId} from '../random-id.js';
5
5
  import {chartTimeLogic} from './chart-timeline.js';
6
6
  import {chartControls} from './chart-controls.js';
7
+ import {chartTypes,chartFixedMeasures} from './chart-types/index.js';
7
8
 
8
9
  /** One shared Source composition for Python and JavaScript callers. */
9
10
  export const ChartPane = defineComponent({
@@ -39,10 +40,15 @@ export const ChartPane = defineComponent({
39
40
  const defaults={mapLabelMode:'value',mapBarScale:'zero',selectedTerritory:'',timeField:'',timeEmpty:'previous',timeSnapshotLabel:'',timeStep:'auto',timeUnit:'month',timeHasClock:false,timeIndex:0,timeMax:0,timeAtEnd:true,timeValue:null,timeLabel:'',timePlaying:false,timeSpeed:0.8,engine:'echarts',chartType:'bar',captionField:'',secondCaptionField:'',geometryField:'',mapValueField:'',mapLabelField:'',geoJSON:null,drawer:'close'};
40
41
  for(const [key,value] of Object.entries(defaults))if(!configuration.getNode(key))configuration.setItem(key,value);
41
42
  if(!configuration.getNode('seriesOptions'))configuration.setItem('seriesOptions',new Bag());
43
+ if(!configuration.getNode('measureRoles'))configuration.setItem('measureRoles',new Bag());
42
44
  if(!(configuration.getItem('seriesOptions') instanceof Bag))throw new TypeError('seriesOptions must be a Bag');
43
45
  const fragment=new node.builder.source.constructor(null,node.builder);
44
46
  const frame=node.builder.wrapSource(fragment).framePane({node_label:'frame',height:'100%'});
45
- frame.dataFormula({result_path:`${configpath}.valueFields`,formula:"options.getNodes().filter(n => n.getValue().getItem('selected')).map(n => n.label).join(',')",options:`^${configpath}.seriesOptions`,_onBuilt:true});
47
+ // A type with fixed measures reads them from its roles, in reading order; the others from the selected measures.
48
+ const fixed=JSON.stringify(Object.fromEntries(chartTypes.map(type=>[type.id,chartFixedMeasures(type)]).filter(([,names])=>names.length)));
49
+ frame.dataFormula({result_path:`${configpath}.valueFields`,
50
+ formula:`(${fixed}[type] ?? null) ? ${fixed}[type].map(name => roles.getItem(name) || '').filter(Boolean).join(',') : options.getNodes().filter(n => n.getValue().getItem('selected')).map(n => n.label).join(',')`,
51
+ options:`^${configpath}.seriesOptions`,roles:`^${configpath}.measureRoles`,type:`^${configpath}.chartType`,_onBuilt:true});
46
52
  const toolbar=frame.top.contentPane({display:'flex',justify_content:'flex-end',align_items:'center',padding:'2px 6px'});
47
53
  const path=JSON.stringify(`${configpath}.drawer`);
48
54
  toolbar.button({icon:'⚙',aria_label:'Chart settings',title:'Chart settings',action:`this.SET(${path},this.GET(${path}) === 'close' ? true : 'close');`});
@@ -0,0 +1,24 @@
1
+ import {chartPalette} from './chart-domains.js';
2
+ import {chartCell,chartName,chartCaption,chartSeriesNumber} from './chart-type-data.js';
3
+
4
+ /** One vertical axis per measure and one polyline per row; `captionField` names the row. */
5
+ export function chartParallelOptions({view,category,fields,seriesOptions}) {
6
+ const rows=[];
7
+ for(const row of view.getRows()) {
8
+ const values=fields.map(field=>chartCell(view,row,field));
9
+ if(values.every(value=>value===null))continue;
10
+ rows.push({name:chartName(view.value(row,category),category),values});
11
+ }
12
+ const parallelAxis=fields.map((field,dim)=>{
13
+ const axis={dim,name:chartCaption(seriesOptions,field)};
14
+ const min=chartSeriesNumber(seriesOptions,field,'min'),max=chartSeriesNumber(seriesOptions,field,'max');
15
+ if(min!==null)axis.min=min;
16
+ if(max!==null)axis.max=max;
17
+ return axis;
18
+ });
19
+ return {backgroundColor:'#ffffff',tooltip:{trigger:'item'},
20
+ parallel:{left:60,right:60,top:60,bottom:40,parallelAxisDefault:{type:'value',nameLocation:'start',nameGap:20}},
21
+ parallelAxis,
22
+ series:[{type:'parallel',lineStyle:{width:2,opacity:0.7},emphasis:{lineStyle:{width:4,opacity:1}},
23
+ data:rows.map((row,index)=>({name:row.name,value:row.values,lineStyle:{color:chartPalette[index%chartPalette.length]}}))}]};
24
+ }
@@ -0,0 +1,29 @@
1
+ import {chartPalette} from './chart-domains.js';
2
+ import {chartCell,chartName,chartCaption,chartSeriesNumber} from './chart-type-data.js';
3
+
4
+ /**
5
+ * One axis per measure and one polygon per row. The axis maximum is the largest value unless `max` is set in the measure series options.
6
+ * A polygon needs a value on every axis: ECharts plots an empty vertex at the center, which would read as zero,
7
+ * so a row with an empty measure is left out.
8
+ */
9
+ export function chartRadarOptions({view,category,fields,seriesOptions}) {
10
+ const rows=[];
11
+ for(const row of view.getRows()) {
12
+ const values=fields.map(field=>chartCell(view,row,field));
13
+ if(values.some(value=>value===null))continue;
14
+ rows.push({name:chartName(view.value(row,category),category),values});
15
+ }
16
+ const indicator=fields.map((field,index)=>{
17
+ const present=rows.map(row=>row.values[index]).filter(value=>value!==null);
18
+ const min=chartSeriesNumber(seriesOptions,field,'min')??Math.min(0,...present);
19
+ let max=chartSeriesNumber(seriesOptions,field,'max')??(present.length?Math.max(...present):1);
20
+ if(max<=min)max=min+1;
21
+ return {name:chartCaption(seriesOptions,field),min,max};
22
+ });
23
+ return {backgroundColor:'#ffffff',tooltip:{trigger:'item'},
24
+ legend:{show:true,type:'scroll',orient:'horizontal',left:12,right:12,bottom:10,height:24,data:rows.map(row=>row.name)},
25
+ radar:{indicator,center:['50%','48%'],radius:'62%'},
26
+ series:[{type:'radar',areaStyle:{opacity:0.15},
27
+ data:rows.map((row,index)=>({name:row.name,value:row.values,
28
+ itemStyle:{color:chartPalette[index%chartPalette.length]},lineStyle:{color:chartPalette[index%chartPalette.length]}}))}]};
29
+ }
@@ -1,20 +1,14 @@
1
1
  import {Bag} from '@gramlot/gramlot';
2
2
  import {chartType} from './chart-types/index.js';
3
3
  import {requireChartCapability} from './chart-engines/index.js';
4
+ import {checkChartSyntax} from './chart-syntax.js';
4
5
 
5
6
  /** Engine-independent context. Reading it never rewrites either Data Bag. */
6
7
  export function chartContext(view,structure,seriesOptions) {
7
8
  if (!(seriesOptions instanceof Bag)) throw new TypeError('seriesOptions requires a Bag');
8
9
  const type = chartType(structure.getItem('chartType'));
9
10
  const category = structure.getItem('captionField');
10
- const selection = structure.getItem('valueFields');
11
- if (selection !== null && typeof selection !== 'string') throw new TypeError('valueFields requires comma-separated codes or null');
12
- let fields = selection ? selection.split(',') : [];
13
- if (fields.some(field => !field) || new Set(fields).size !== fields.length) throw new TypeError('valueFields requires distinct nonempty fields');
14
- if (typeof category !== 'string' || !category) {
15
- throw new TypeError('Chart requires captionField');
16
- }
17
- if (type.measureLimit !== null) fields = fields.slice(0,type.measureLimit);
11
+ const fields = checkChartSyntax(type, structure);
18
12
  const settings = fields.map(field => {
19
13
  const options = seriesOptions.getItem(field);
20
14
  if (!(options instanceof Bag)) throw new TypeError(`Missing seriesOptions for ${field}`);
@@ -31,7 +25,7 @@ export function chartContext(view,structure,seriesOptions) {
31
25
  export class ChartRenderer {
32
26
  #element; #view; #options; #adapter; #engine; #host; #revision=0;
33
27
  constructor(element,view,options={}) { this.#element=element;this.#view=view;this.#options=options; }
34
- async prepare(engine,type) { await requireChartCapability(engine,type).load(type); }
28
+ async prepare(engine,type) { await requireChartCapability(engine,type).load(type,this.#element.ownerDocument); }
35
29
  invalidate() { this.#revision++; }
36
30
  update(structure,seriesOptions) {
37
31
  const engine=structure.getItem('engine') ?? 'echarts';
@@ -0,0 +1,43 @@
1
+ import {chartCell,chartName,chartCaption} from './chart-type-data.js';
2
+
3
+ /** First cycle in the links as a list of node names ending where it began, or null. */
4
+ export function sankeyCycle(links) {
5
+ const next=new Map();
6
+ for(const {source,target} of links) {
7
+ if(!next.has(source))next.set(source,[]);
8
+ next.get(source).push(target);
9
+ }
10
+ const state=new Map(),path=[];
11
+ const visit=node=>{
12
+ state.set(node,1);path.push(node);
13
+ for(const target of next.get(node)??[]) {
14
+ if(state.get(target)===1)return [...path.slice(path.indexOf(target)),target];
15
+ if(!state.has(target)){const found=visit(target);if(found)return found;}
16
+ }
17
+ path.pop();state.set(node,2);
18
+ return null;
19
+ };
20
+ for(const node of next.keys())if(!state.has(node)){const found=visit(node);if(found)return found;}
21
+ return null;
22
+ }
23
+
24
+ /** Links from `captionField` to `secondCaptionField`; nodes are the distinct names found there. */
25
+ export function chartSankeyOptions({view,category,structure,fields,seriesOptions}) {
26
+ const target=structure.getItem('secondCaptionField');
27
+ const [field]=fields;
28
+ const nodes=new Set(),links=[];
29
+ for(const row of view.getRows()) {
30
+ const source=chartName(view.value(row,category),category),to=chartName(view.value(row,target),target);
31
+ const value=chartCell(view,row,field);
32
+ if(value===null)continue;
33
+ if(value<0)throw new TypeError('Sankey requires nonnegative link values.');
34
+ nodes.add(source);nodes.add(to);
35
+ links.push({source,target:to,value});
36
+ }
37
+ const cycle=sankeyCycle(links);
38
+ if(cycle)throw new TypeError(`Sankey links contain a cycle: ${cycle.join(' → ')}. Remove or reverse one link.`);
39
+ return {backgroundColor:'#ffffff',tooltip:{trigger:'item'},
40
+ series:[{id:field,name:chartCaption(seriesOptions,field),type:'sankey',left:20,right:120,top:20,bottom:20,
41
+ emphasis:{focus:'adjacency'},lineStyle:{color:'gradient',curveness:0.5},
42
+ data:[...nodes].map(name=>({name})),links}]};
43
+ }
@@ -0,0 +1,12 @@
1
+ import {chartPalette} from './chart-domains.js';
2
+ import {chartCaption,chartHierarchy} from './chart-type-data.js';
3
+
4
+ /** Concentric rings from a nested Bag, the top level at the center. */
5
+ export function chartSunburstOptions(context) {
6
+ const data=chartHierarchy(context,'Sunburst',chartPalette);
7
+ const [field]=context.fields;
8
+ return {backgroundColor:'#ffffff',tooltip:{trigger:'item',formatter:'{b}: {c}'},
9
+ series:[{id:field,name:chartCaption(context.seriesOptions,field),type:'sunburst',radius:[0,'92%'],center:['50%','50%'],
10
+ sort:null,nodeClick:'rootToNode',label:{rotate:'radial',minAngle:8},
11
+ itemStyle:{borderColor:'#ffffff',borderWidth:1},data}]};
12
+ }
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The column syntax of a chart type, checked against the chart parameters before any engine reads the data.
3
+ * The syntax lives in the type descriptor (`chart-types/*.js`); this module only reads it.
4
+ */
5
+
6
+ /** A chart configuration that does not match the syntax of its type. `diagnosis` carries the structured reasons. */
7
+ export class ChartSyntaxError extends TypeError {
8
+ constructor(diagnosis) {
9
+ super(diagnosis.message);
10
+ this.name = 'ChartSyntaxError';
11
+ this.diagnosis = diagnosis;
12
+ }
13
+ }
14
+
15
+ function list(names) { return names.join(', '); }
16
+
17
+ function fail(type, role, message, expected, received, fix) {
18
+ throw new ChartSyntaxError({type:type.id, role:role ? role.name : null, message, expected, received, fix});
19
+ }
20
+
21
+ /** Selected measures from `valueFields`: comma-separated, distinct, nonempty codes, or none. */
22
+ function selectedMeasures(type, structure) {
23
+ const selection = structure.getItem('valueFields');
24
+ if (selection !== null && selection !== undefined && typeof selection !== 'string') {
25
+ fail(type, null, 'valueFields requires comma-separated codes or null', 'comma-separated column codes', String(selection),
26
+ 'Pass the measures as one string, for example "open,high,low,close".');
27
+ }
28
+ const fields = selection ? selection.split(',') : [];
29
+ if (fields.some(field => !field) || new Set(fields).size !== fields.length) {
30
+ fail(type, null, 'valueFields requires distinct nonempty fields', 'distinct column codes', selection,
31
+ 'Remove the empty or repeated codes from valueFields.');
32
+ }
33
+ return fields;
34
+ }
35
+
36
+ function checkMeasures(type, roles, fields) {
37
+ const [first] = roles;
38
+ if (first.count === 'many') {
39
+ if (first.required && !fields.length) fail(type, first, `${type.label} needs at least one measure.`,
40
+ 'one or more measures', 'none', 'Choose at least one numeric column as measure.');
41
+ return;
42
+ }
43
+ const names = roles.map(role => role.name);
44
+ const expected = roles.length === 1 ? 'one measure' : `${roles.length} measures in the order ${list(names)}`;
45
+ if (fields.length < roles.length) {
46
+ const missing = roles[fields.length];
47
+ fail(type, missing, `${type.label} needs ${expected}; received ${fields.length}.`, expected, list(fields) || 'none',
48
+ roles.length === 1 ? 'Choose one numeric column as measure.' : `Choose a column for ${list(names.slice(fields.length))}.`);
49
+ }
50
+ if (fields.length > roles.length) {
51
+ fail(type, null, `${type.label} takes ${expected}; received ${fields.length}: ${list(fields)}.`, expected, list(fields),
52
+ `Remove ${list(fields.slice(roles.length))} from the measures.`);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Check the chart parameters against the syntax of `type` and return the selected measures.
58
+ * Missing required columns, measures in excess or missing, repeated codes and a second dimension equal to the first are errors.
59
+ * A parameter the type does not declare is not read, as `valueFields` for the 2D map: a configuration shared by
60
+ * several types (chartPane) keeps the values of the other types.
61
+ */
62
+ export function checkChartSyntax(type, structure) {
63
+ for (const role of type.syntax) {
64
+ if (role.parameter === 'valueFields' || !role.required) continue;
65
+ const value = structure.getItem(role.parameter);
66
+ if (typeof value !== 'string' || !value) {
67
+ fail(type, role, `${type.label} needs ${role.caption} (${role.parameter}).`, `a column for ${role.caption}`, 'none',
68
+ `Choose the column for ${role.caption}: ${role.doc}`);
69
+ }
70
+ }
71
+ const second = type.syntax.find(role => role.parameter === 'secondCaptionField');
72
+ if (second && structure.getItem('secondCaptionField') === structure.getItem('captionField')) {
73
+ const first = type.syntax[0];
74
+ fail(type, second, `${type.label} needs ${second.caption} different from ${first.caption}.`,
75
+ `two different columns`, structure.getItem('captionField'), `Choose another column for ${second.caption}.`);
76
+ }
77
+ const roles = type.syntax.filter(role => role.parameter === 'valueFields');
78
+ if (!roles.length) return [];
79
+ const fields = selectedMeasures(type, structure);
80
+ checkMeasures(type, roles, fields);
81
+ return fields;
82
+ }
@@ -53,7 +53,7 @@ export class ChartTimeView {
53
53
  constructor(view){this.view=view;this.field='';}
54
54
  invalidateDomains(){this.domainKey=null;}
55
55
  domains(context){
56
- if(!this.field)return null;
56
+ if(!this.field||context.type.domains===false)return null;
57
57
  const key=JSON.stringify([this.field,this.step,context.category,context.fields,context.settings,context.type.id,context.structure.getItem('secondCaptionField'),context.structure.getItem('mapValueField'),context.structure.getItem('mapBarScale')]);
58
58
  const geoJSON=context.structure.getItem('geoJSON');
59
59
  if(key!==this.domainKey || geoJSON!==this.domainGeoJSON){
@@ -67,6 +67,7 @@ export class ChartTimeView {
67
67
  if(!['previous','empty'].includes(empty))throw new TypeError('Empty periods require previous or empty');
68
68
  this.field=field;this.date=value;this.step=step;this.empty=empty;
69
69
  }
70
+ get rowMode(){return this.view.rowMode;}
70
71
  value(row,field){return this.view.value(row,field);}
71
72
  getRows(){
72
73
  const rows=this.view.getRows();
@@ -0,0 +1,16 @@
1
+ import {chartPalette} from './chart-domains.js';
2
+ import {chartCaption,chartHierarchy} from './chart-type-data.js';
3
+
4
+ /** Nested rectangles from a nested Bag; the breadcrumb and click drill-down are the ECharts defaults. */
5
+ export function chartTreemapOptions(context) {
6
+ const data=chartHierarchy(context,'Treemap',chartPalette);
7
+ const [field]=context.fields;
8
+ return {backgroundColor:'#ffffff',tooltip:{trigger:'item',formatter:'{b}: {c}'},
9
+ series:[{id:field,name:chartCaption(context.seriesOptions,field),type:'treemap',left:10,right:10,top:10,bottom:30,
10
+ roam:false,nodeClick:'zoomToNode',breadcrumb:{show:true,bottom:4},
11
+ label:{show:true,formatter:'{b}'},
12
+ itemStyle:{borderColor:'#ffffff',borderWidth:1,gapWidth:1},
13
+ levels:[{itemStyle:{borderWidth:0,gapWidth:6},upperLabel:{show:true,height:24,color:'#333333',fontWeight:'bold'}},
14
+ {itemStyle:{borderWidth:0,gapWidth:3},upperLabel:{show:true,height:20,color:'#555555'}},{itemStyle:{gapWidth:1}}],
15
+ data}]};
16
+ }
@@ -0,0 +1,62 @@
1
+ import {Bag} from '@gramlot/gramlot';
2
+
3
+ /** Cell and caption reading shared by the funnel, radar, parallel, heatmap, sankey, candlestick, boxplot, treemap and sunburst builders. */
4
+
5
+ /** A missing measure is no value; any other non-number is an error. Zero stays zero. */
6
+ export function chartCell(view,row,field) {
7
+ const value=view.value(row,field);
8
+ if(value==null)return null;
9
+ if(typeof value!=='number'||!Number.isFinite(value))throw new TypeError(`Measure ${field} requires finite numeric values or empty cells`);
10
+ return value;
11
+ }
12
+ /** Category text: dates as ISO days, everything else as text. */
13
+ export function chartName(value,field) {
14
+ if(value instanceof Date&&Number.isFinite(value.getTime()))return value.toISOString().slice(0,10);
15
+ if(['string','number','boolean'].includes(typeof value)&&!(typeof value==='number'&&!Number.isFinite(value)))return String(value);
16
+ throw new TypeError(`Choose a ${field} column with text, numeric, boolean or date values`);
17
+ }
18
+ /** Measure caption from seriesOptions, falling back to the field code. */
19
+ export function chartCaption(seriesOptions,field) {
20
+ const caption=seriesOptions?.getItem(field)?.getItem('caption');
21
+ return typeof caption==='string'&&caption?caption:field;
22
+ }
23
+ /** Number from the series options of a measure (for example `max`), or null. */
24
+ export function chartSeriesNumber(seriesOptions,field,key) {
25
+ const value=seriesOptions?.getItem(field)?.getItem(key);
26
+ return typeof value==='number'&&Number.isFinite(value)?value:null;
27
+ }
28
+ /** Text from the series options of a measure (for example a color), or null. */
29
+ export function chartSeriesText(seriesOptions,field,key) {
30
+ const value=seriesOptions?.getItem(field)?.getItem(key);
31
+ return typeof value==='string'&&value?value:null;
32
+ }
33
+
34
+ /**
35
+ * Nested Bag read as a tree of `{name,value,children?,itemStyle}` for treemap and sunburst.
36
+ * Needs `rowMode='attributes'`: every node carries the caption and the measure as attributes.
37
+ * The top level is read through the view; deeper levels read the attributes of each BagNode.
38
+ * A node whose value is a Bag is a parent, any other node is a leaf. A parent's value is the sum of its children,
39
+ * so a parent carrying the measure is an error. A null leaf is skipped, a negative leaf is an error,
40
+ * a parent whose leaves are all skipped is skipped. Each top-level node takes one palette color, descendants inherit it.
41
+ */
42
+ export function chartHierarchy({view,category,fields},typeLabel,palette) {
43
+ if(view.rowMode!=='attributes')throw new TypeError(`${typeLabel} needs rowMode='attributes': each node carries the caption and the measure as attributes.`);
44
+ const [field]=fields;
45
+ const attributes={value:(node,key)=>node.getAttr(key)};
46
+ const read=(nodes,reader,color)=>nodes.flatMap(node=>{
47
+ const name=chartName(reader.value(node,category),category);
48
+ const children=node.staticValue;
49
+ if(children instanceof Bag) {
50
+ if(node.getAttr(field)!=null)throw new TypeError(`Node ${name} has children and carries ${field}: the value of a parent is the sum of its children. Remove the attribute from ${name}.`);
51
+ const items=read(children.getNodes(),attributes,color);
52
+ if(!items.length)return [];
53
+ return [{name,value:items.reduce((sum,item)=>sum+item.value,0),children:items,itemStyle:{color}}];
54
+ }
55
+ const value=chartCell(reader,node,field);
56
+ if(value===null)return [];
57
+ if(value<0)throw new TypeError(`Node ${name} has a negative ${field}: areas cannot be negative.`);
58
+ return [{name,value,itemStyle:{color}}];
59
+ });
60
+ const top=view.getRows();
61
+ return top.flatMap((node,index)=>read([node],view,palette[index%palette.length]));
62
+ }
@@ -1,2 +1,7 @@
1
1
  /** Engine-independent area configuration. */
2
- export default {id:'area',label:'Area',controls:['category','measures'],threeD:false,measureLimit:null};
2
+ export default {id:'area',label:'Area',controls:[],threeD:false,
3
+ doc:'Shows how values change along an ordered category, filling the area under each line.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Category',doc:'The horizontal axis, in row order or time order.'},
6
+ {name:'measures',parameter:'valueFields',count:'many',required:true,dtype:'numeric',caption:'Measures',doc:'Each measure is one series, drawn with its own colour.'}
7
+ ]};
@@ -1,2 +1,7 @@
1
1
  /** Engine-independent bars configuration. */
2
- export default {id:'bar',label:'Bars',controls:['category','measures'],threeD:false,measureLimit:null};
2
+ export default {id:'bar',label:'Bars',controls:[],threeD:false,
3
+ doc:'Compares values across categories with vertical bars.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Category',doc:'One bar group per value of this column.'},
6
+ {name:'measures',parameter:'valueFields',count:'many',required:true,dtype:'numeric',caption:'Measures',doc:'Each measure is one series, drawn with its own colour.'}
7
+ ]};
@@ -1,2 +1,8 @@
1
1
  /** Engine-independent 3d bars configuration. */
2
- export default {id:'bar3D',label:'3D bars',controls:['category','secondDimension','measures'],threeD:true,measureLimit:null};
2
+ export default {id:'bar3D',label:'3D bars',controls:[],threeD:true,
3
+ doc:'Shows a value for each pair of two dimensions as 3D columns.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'First dimension',doc:'The first axis of the grid.'},
6
+ {name:'secondCaptionField',parameter:'secondCaptionField',count:1,required:true,dtype:null,caption:'Second dimension',doc:'The second axis of the grid; it must differ from the first.'},
7
+ {name:'measures',parameter:'valueFields',count:'many',required:true,dtype:'numeric',caption:'Measures',doc:'Each measure is one series of heights on the grid of the two dimensions.'}
8
+ ]};
@@ -0,0 +1,11 @@
1
+ /** Engine-independent boxplot configuration: five measures read in the order min, q1, median, q3, max. */
2
+ export default {id:'boxplot',label:'Boxplot',controls:[],threeD:false,domains:false,
3
+ doc:'Shows the spread of each group with five statistics: minimum, quartiles, median and maximum.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Group',doc:'One box per row.'},
6
+ {name:'min',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Minimum',doc:'The lowest value.'},
7
+ {name:'q1',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'First quartile',doc:'The value below which a quarter of the data falls.'},
8
+ {name:'median',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Median',doc:'The middle value.'},
9
+ {name:'q3',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Third quartile',doc:'The value below which three quarters of the data fall.'},
10
+ {name:'max',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Maximum',doc:'The highest value.'}
11
+ ]};
@@ -0,0 +1,10 @@
1
+ /** Engine-independent candlestick configuration: four measures read in the order open, high, low, close. */
2
+ export default {id:'candlestick',label:'Candlestick',controls:[],threeD:false,domains:false,
3
+ doc:'Shows the open, high, low and close of each period, as used for prices.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Period',doc:'One candle per row, in row order.'},
6
+ {name:'open',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Open',doc:'The value at the start of the period.'},
7
+ {name:'high',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'High',doc:'The highest value of the period.'},
8
+ {name:'low',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Low',doc:'The lowest value of the period.'},
9
+ {name:'close',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Close',doc:'The value at the end of the period.'}
10
+ ]};
@@ -1,2 +1,7 @@
1
1
  /** Engine-independent donut configuration. */
2
- export default {id:'donut',label:'Donut',controls:['category','measures'],threeD:false,measureLimit:1};
2
+ export default {id:'donut',label:'Donut',controls:[],threeD:false,
3
+ doc:'Shows the share of each category in a total, as a ring.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Slice',doc:'One slice per row, named by this column.'},
6
+ {name:'measure',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Measure',doc:'The size of each slice; values must not be negative.'}
7
+ ]};
@@ -0,0 +1,7 @@
1
+ /** Engine-independent funnel configuration: stages of one measure. */
2
+ export default {id:'funnel',label:'Funnel',controls:[],threeD:false,domains:false,
3
+ doc:'Shows how a quantity shrinks through ordered stages.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Stage',doc:'One stage per row, in row order.'},
6
+ {name:'measure',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Measure',doc:'The quantity at each stage; values must not be negative.'}
7
+ ]};
@@ -0,0 +1,8 @@
1
+ /** Engine-independent heatmap configuration: two categories and one measure as cell color. */
2
+ export default {id:'heatmap',label:'Heatmap',controls:[],threeD:false,domains:false,
3
+ doc:'Colours each cell of a grid of two categories by one measure.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'X category',doc:'The columns of the grid.'},
6
+ {name:'secondCaptionField',parameter:'secondCaptionField',count:1,required:true,dtype:null,caption:'Y category',doc:'The rows of the grid; it must differ from the X category.'},
7
+ {name:'measure',parameter:'valueFields',count:1,required:true,dtype:'numeric',caption:'Measure',doc:'The colour of each cell; one row per pair of categories.'}
8
+ ]};
@@ -1,2 +1,7 @@
1
1
  /** Engine-independent horizontal bars configuration. */
2
- export default {id:'horizontalBar',label:'Horizontal bars',controls:['category','measures'],threeD:false,measureLimit:null};
2
+ export default {id:'horizontalBar',label:'Horizontal bars',controls:[],threeD:false,
3
+ doc:'Compares values across categories with horizontal bars; suited to long category names.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Category',doc:'One bar group per value of this column, on the vertical axis.'},
6
+ {name:'measures',parameter:'valueFields',count:'many',required:true,dtype:'numeric',caption:'Measures',doc:'Each measure is one series, drawn with its own colour.'}
7
+ ]};
@@ -16,11 +16,31 @@ import mapBar3D from './mapBar3D.js';
16
16
  import map3D from './map3D.js';
17
17
  import lines3D from './lines3D.js';
18
18
  import polygons3D from './polygons3D.js';
19
+ import funnel from './funnel.js';
20
+ import radar from './radar.js';
21
+ import parallel from './parallel.js';
22
+ import heatmap from './heatmap.js';
23
+ import sankey from './sankey.js';
24
+ import candlestick from './candlestick.js';
25
+ import boxplot from './boxplot.js';
26
+ import treemap from './treemap.js';
27
+ import sunburst from './sunburst.js';
19
28
 
20
- export const chartTypes = [bar,line,area,stackedBar,stackedArea,horizontalBar,pie,donut,scatter,bar3D,line3D,scatter3D,surface,map,mapBar3D,map3D,lines3D,polygons3D];
29
+ export const chartTypes = [bar,line,area,stackedBar,stackedArea,horizontalBar,pie,donut,scatter,bar3D,line3D,scatter3D,surface,map,mapBar3D,map3D,lines3D,polygons3D,funnel,radar,parallel,heatmap,sankey,candlestick,boxplot,treemap,sunburst];
21
30
  const types=new Map(chartTypes.map(type=>[type.id,type]));
22
31
  export function chartType(id) {
23
32
  const type=types.get(id);
24
33
  if(!type)throw new TypeError('Choose a supported chart type');
25
34
  return type;
26
35
  }
36
+
37
+ /** The roles of `type` that fill `parameter` of chartView. */
38
+ export function chartRoles(type,parameter) {
39
+ return type.syntax.filter(role=>role.parameter===parameter);
40
+ }
41
+
42
+ /** Names of the fixed measures of `type`, in reading order; empty when the type takes a list of measures. */
43
+ export function chartFixedMeasures(type) {
44
+ const roles=chartRoles(type,'valueFields');
45
+ return roles.every(role=>role.count===1)?roles.map(role=>role.name):[];
46
+ }
@@ -1,2 +1,7 @@
1
1
  /** Engine-independent lines configuration. */
2
- export default {id:'line',label:'Lines',controls:['category','measures'],threeD:false,measureLimit:null};
2
+ export default {id:'line',label:'Lines',controls:[],threeD:false,
3
+ doc:'Shows how values change along an ordered category, such as time.',
4
+ syntax:[
5
+ {name:'captionField',parameter:'captionField',count:1,required:true,dtype:null,caption:'Category',doc:'The horizontal axis, in row order or time order.'},
6
+ {name:'measures',parameter:'valueFields',count:'many',required:true,dtype:'numeric',caption:'Measures',doc:'Each measure is one series, drawn with its own colour.'}
7
+ ]};