@gramlot/gramlot 0.4.0 → 0.5.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/assets/icons/align-center.svg +4 -0
- package/assets/icons/align-justify.svg +4 -0
- package/assets/icons/align-left.svg +4 -0
- package/assets/icons/align-right.svg +4 -0
- package/assets/icons/bold.svg +4 -0
- package/assets/icons/eraser.svg +4 -0
- package/assets/icons/horizontal-rule.svg +4 -0
- package/assets/icons/image.svg +4 -0
- package/assets/icons/indent.svg +4 -0
- package/assets/icons/italic.svg +4 -0
- package/assets/icons/list-bulleted.svg +4 -0
- package/assets/icons/list-numbered.svg +4 -0
- package/assets/icons/outdent.svg +4 -0
- package/assets/icons/paragraph.svg +4 -0
- package/assets/icons/select-all.svg +4 -0
- package/assets/icons/strikethrough.svg +4 -0
- package/assets/icons/underline.svg +4 -0
- package/dist/components/charts/__init__.py +1 -1
- package/dist/components/charts/assets/index.js +1 -1
- package/dist/components/charts/grammar.json +2032 -72
- package/dist/components/editors/__init__.py +1 -1
- package/dist/components/editors/assets/collection.js +1 -1
- package/dist/components/editors/assets/index.js +1 -1
- package/dist/components/editors/assets/libraries/codemirror.js +30 -30
- package/dist/components/editors/assets/libraries/jodit.js +452 -448
- package/dist/components/editors/commands.json +113 -1
- package/dist/components/editors/grammar.json +6 -4
- package/dist/components/grid/__init__.py +1 -1
- package/dist/components/grid/assets/index.js +1 -1
- package/dist/components/grid/grammar.json +61 -0
- package/dist/components/inputs/__init__.py +1 -1
- package/dist/components/inputs/assets/index.js +1 -1
- package/dist/components/inputs/grammar.json +35 -0
- package/dist/components/layout/__init__.py +1 -1
- package/dist/components/layout/assets/collection.js +1 -0
- package/dist/components/layout/assets/index.js +1 -1
- package/dist/components/layout/grammar.json +364 -0
- package/dist/components/tree/__init__.py +1 -1
- package/dist/components/tree/assets/index.js +1 -1
- package/dist/components/tree/grammar.json +35 -0
- package/dist/gramlot.js +1165 -420
- package/dist/gramlot.min.js +125 -100
- package/dist/libraries.json +5 -4
- package/dist/standard-collections.js +1 -1
- package/dist/standard-grammar.js +1 -1
- package/package.json +4 -2
- package/src/binding/providers.js +2 -1
- package/src/binding/remote.js +41 -6
- package/src/binding/runtime.js +24 -0
- package/src/builder/gramlot-builder.js +52 -18
- package/src/builder/source.js +66 -12
- package/src/chat.d.ts +1 -0
- package/src/chat.js +13 -1
- package/src/components/chart-bar3d-options.js +0 -1
- package/src/components/chart-boxplot-options.js +1 -1
- package/src/components/chart-candlestick-options.js +1 -1
- package/src/components/chart-engines/echarts-options.js +6 -5
- package/src/components/chart-engines/echarts.js +27 -10
- package/src/components/chart-engines/plotly-map.js +1 -1
- package/src/components/chart-engines/plotly.js +21 -14
- package/src/components/chart-engines/uplot.js +17 -11
- package/src/components/chart-engines/vega.js +17 -11
- package/src/components/chart-funnel-options.js +1 -1
- package/src/components/chart-geographic-options.js +1 -1
- package/src/components/chart-heatmap-options.js +1 -1
- package/src/components/chart-map-bar3d-options.js +2 -2
- package/src/components/chart-map-options.js +2 -2
- package/src/components/chart-parallel-options.js +1 -1
- package/src/components/chart-radar-options.js +1 -1
- package/src/components/chart-renderer.js +6 -1
- package/src/components/chart-sankey-options.js +1 -1
- package/src/components/chart-spatial-options.js +1 -1
- package/src/components/chart-sunburst-options.js +13 -1
- package/src/components/chart-theme.js +14 -0
- package/src/components/chart-treemap-options.js +1 -1
- package/src/components/chart-type-data.js +24 -4
- package/src/components/charts.js +7 -6
- package/src/components/check-box-tree.js +1 -1
- package/src/components/choice-editor.js +3 -3
- package/src/components/code-mirror-engine.js +2 -1
- package/src/components/code-mirror.js +1 -1
- package/src/components/editor-commands.js +69 -0
- package/src/components/editors.js +5 -3
- package/src/components/form-tray-pane.js +18 -0
- package/src/components/graphical-ranges.js +16 -3
- package/src/components/grid-check-sets.js +39 -3
- package/src/components/grid-header-interaction.js +3 -3
- package/src/components/grid-styles.js +19 -3
- package/src/components/grid.js +42 -9
- package/src/components/html-editor-commands.js +61 -0
- package/src/components/html-editor.js +18 -3
- package/src/components/inputs.js +1 -0
- package/src/components/jodit-engine.js +107 -6
- package/src/components/layout.js +3 -2
- package/src/components/menus.js +6 -1
- package/src/components/selected-container.js +16 -3
- package/src/components/tab-bar.js +20 -2
- package/src/components/tray-base.js +528 -0
- package/src/components/tray-pane.js +41 -518
- package/src/components/tree.js +44 -1
- package/src/components/typed-editor.js +5 -2
- package/src/editing-session.js +2 -1
- package/src/ide-runtime.js +3 -1
- package/src/index-page-runtime.js +11 -3
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/libraries.js +4 -4
- package/src/object-extract.d.ts +7 -0
- package/src/object-extract.js +31 -0
- package/src/renderer/attributes.js +1 -1
- package/src/renderer/gramlot-renderer.d.ts +2 -2
- package/src/server/chat.d.ts +3 -1
- package/src/server/chat.js +17 -6
- package/src/server/gramlot-server.js +5 -1
- package/src/server/index-page.js +27 -8
- package/src/server/toolbar-icon-name.d.ts +17 -0
- package/src/view/labelbox.js +6 -1
- package/src/visual-editor.d.ts +1 -0
- package/src/visual-editor.js +4 -3
- package/themes/gramlot-base/theme.css +7 -0
- package/themes/gramlot-index/icons/align-center.svg +4 -0
- package/themes/gramlot-index/icons/align-justify.svg +4 -0
- package/themes/gramlot-index/icons/align-left.svg +4 -0
- package/themes/gramlot-index/icons/align-right.svg +4 -0
- package/themes/gramlot-index/icons/bold.svg +4 -0
- package/themes/gramlot-index/icons/eraser.svg +4 -0
- package/themes/gramlot-index/icons/horizontal-rule.svg +4 -0
- package/themes/gramlot-index/icons/image.svg +4 -0
- package/themes/gramlot-index/icons/indent.svg +4 -0
- package/themes/gramlot-index/icons/italic.svg +4 -0
- package/themes/gramlot-index/icons/list-bulleted.svg +4 -0
- package/themes/gramlot-index/icons/list-numbered.svg +4 -0
- package/themes/gramlot-index/icons/outdent.svg +4 -0
- package/themes/gramlot-index/icons/paragraph.svg +4 -0
- package/themes/gramlot-index/icons/select-all.svg +4 -0
- package/themes/gramlot-index/icons/strikethrough.svg +4 -0
- package/themes/gramlot-index/icons/underline.svg +4 -0
- package/themes/gramlot-index/icons.json +17 -0
- package/themes/gramlot-index/theme.css +3 -0
- package/tools/gramlot-tools-inspector.js +11 -3
- package/src/builder/chart-icon.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gramlot/gramlot",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Declarative HTML/SVG interfaces with live data binding, authored in JavaScript or Python.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@codemirror/lang-rust": "^6.0.2",
|
|
28
28
|
"@codemirror/lang-sql": "^6.10.0",
|
|
29
29
|
"@codemirror/lang-xml": "^6.1.0",
|
|
30
|
+
"@codemirror/lang-yaml": "^6.1.3",
|
|
30
31
|
"@codemirror/language": "^6.13.1",
|
|
31
32
|
"@codemirror/lint": "^6.9.8",
|
|
32
33
|
"@codemirror/search": "^6.7.2",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"@genrojs/bag": ">=0.12.0",
|
|
36
37
|
"@genrojs/builders": ">=0.7.0",
|
|
37
38
|
"@genrojs/toolbox": ">=0.19.0",
|
|
38
|
-
"@genrojs/tytx": ">=0.16.
|
|
39
|
+
"@genrojs/tytx": ">=0.16.4",
|
|
39
40
|
"@lezer/highlight": "^1.2.5",
|
|
40
41
|
"@myriaddreamin/typst-ts-renderer": "0.7.0",
|
|
41
42
|
"@myriaddreamin/typst-ts-web-compiler": "0.7.0",
|
|
@@ -61,6 +62,7 @@
|
|
|
61
62
|
"write-excel-file": "4.1.1"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
65
|
+
"@gramlot/builder": "file:../tools/gramlot-builder",
|
|
64
66
|
"c8": "10.1.3",
|
|
65
67
|
"esbuild": "0.28.2",
|
|
66
68
|
"jsdom": "27.0.1",
|
package/src/binding/providers.js
CHANGED
|
@@ -157,7 +157,7 @@ export class Provider {
|
|
|
157
157
|
|
|
158
158
|
/**
|
|
159
159
|
* The one pipeline of every trigger, `{kind: 'data'|'init'|'built'|'start'|'timing', change}` or
|
|
160
|
-
* `{kind: 'click', event, counter}
|
|
160
|
+
* `{kind: 'click', event, counter}`, or `{kind: 'fireNode', change: null, runKwargs}` (`Source node.fireNode`, merged over the arguments):
|
|
161
161
|
* arguments, `_if`, body, and for a formula the write of the result at `result_path`. `_if` and
|
|
162
162
|
* `_else` are inline (Q11.1): a false `_if` stops, or `_else` replaces the body (D5); an empty `_if`
|
|
163
163
|
* is absent and an empty `_else` or body is none, as legacy. A body is
|
|
@@ -175,6 +175,7 @@ export class Provider {
|
|
|
175
175
|
const rpc = this.kind === 'rpc';
|
|
176
176
|
const remote = this.kind === 'remote';
|
|
177
177
|
const kwargs = this.readArguments(trigger);
|
|
178
|
+
if (trigger.runKwargs) Object.assign(kwargs, trigger.runKwargs);
|
|
178
179
|
if (trigger.askResult) {
|
|
179
180
|
Object.assign(kwargs, trigger.askResult);
|
|
180
181
|
kwargs._askResult = trigger.askResult;
|
package/src/binding/remote.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {invokeHook} from './hooks.js';
|
|
2
2
|
import {toTytx} from '@genrojs/tytx';
|
|
3
3
|
import {TriggerTimers} from './providers.js';
|
|
4
|
+
import {objectExtract} from '../object-extract.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The `remote` attribute of a Source node (GC-095 §105): the content of the element is the fragment of a
|
|
@@ -12,9 +13,12 @@ import {TriggerTimers} from './providers.js';
|
|
|
12
13
|
* The control attributes: `_cachedRemote` (no call when name and parameters equal those of the request in
|
|
13
14
|
* flight, or of the fragment mounted last when none is in flight), `_if` (inline, false → no call, and `_else`
|
|
14
15
|
* runs when present; a readiness condition that never cancels a request), `_onCalling` (inline, before the
|
|
15
|
-
* call; `false` makes no call), `_onRemote` (inline, after the fragment is mounted), `
|
|
16
|
+
* call; `false` makes no call), `_onRemote` (inline, after the fragment is mounted), `_waitingMessage` (a layer
|
|
17
|
+
* with a message over the element while the request runs), `_delay` (ms of debounce
|
|
16
18
|
* of a Data change), `_timing` (seconds between two calls) and `_userChanges` (only the changes of level
|
|
17
|
-
* `node` call). The inline code has the parameters as locals and `this` = the node.
|
|
19
|
+
* `node` call). The inline code has the parameters as locals and `this` = the node. The parameter
|
|
20
|
+
* `sendInheritedAttributes` sends `node.getInheritedAttributes()` as `_inheritedAttributes`: the server
|
|
21
|
+
* builds the fragment on a root that carries them.
|
|
18
22
|
*/
|
|
19
23
|
export class RemoteBinding {
|
|
20
24
|
#binding;
|
|
@@ -74,9 +78,10 @@ export class RemoteBinding {
|
|
|
74
78
|
const node = this.node;
|
|
75
79
|
const [, attrs] = node.rootBuilder.runtimeValues(node);
|
|
76
80
|
const name = attrs.remote;
|
|
77
|
-
const params = {};
|
|
78
|
-
|
|
79
|
-
|
|
81
|
+
const params = objectExtract(attrs, 'remote_*', {pop: false});
|
|
82
|
+
// As legacy: the server builds the fragment on a root that carries the inherited attributes.
|
|
83
|
+
if (objectExtract(params, 'sendInheritedAttributes').sendInheritedAttributes) {
|
|
84
|
+
params._inheritedAttributes = node.getInheritedAttributes();
|
|
80
85
|
}
|
|
81
86
|
const condition = node.getAttr('_if');
|
|
82
87
|
if (condition && !this.#inline('_if', condition, `return (${condition})`, params)) {
|
|
@@ -90,7 +95,9 @@ export class RemoteBinding {
|
|
|
90
95
|
if (attrs._cachedRemote && this.#cached(name, text)) return;
|
|
91
96
|
const onCalling = node.getAttr('_onCalling');
|
|
92
97
|
if (!node.requests.calling(onCalling ? () => this.#inline('_onCalling', onCalling, onCalling, params) : null)) return;
|
|
93
|
-
|
|
98
|
+
const hide = this.#showWaiting(attrs._waitingMessage);
|
|
99
|
+
try { mounted = await this.binding.runtime.gramlot.src.remoteSource(node, name, params); }
|
|
100
|
+
finally { hide(); }
|
|
94
101
|
} catch (error) {
|
|
95
102
|
throw new Error(`${node.nodeTag} '${node.label}': remote '${name}' failed: ${error.message}`, {cause: error});
|
|
96
103
|
}
|
|
@@ -114,6 +121,34 @@ export class RemoteBinding {
|
|
|
114
121
|
return name === this.#lastName && text === this.#lastParams;
|
|
115
122
|
}
|
|
116
123
|
|
|
124
|
+
/**
|
|
125
|
+
* `_waitingMessage`, as legacy (`gnrdomsource.js:1820`): while the request runs, a layer with the message
|
|
126
|
+
* (`'Loading content'` for `true`) covers the element of the node, which is marked `aria-busy`. A static
|
|
127
|
+
* element is positioned for the time of the layer. Returns the function that removes the layer.
|
|
128
|
+
*/
|
|
129
|
+
#showWaiting(message) {
|
|
130
|
+
// An element is missing only before the node's first build, when no request starts.
|
|
131
|
+
const element = message ? this.binding.runtime.gramlot.dom.getDomNode(this.node) : null;
|
|
132
|
+
if (!element) return () => {};
|
|
133
|
+
const document = element.ownerDocument;
|
|
134
|
+
const layer = document.createElement('div');
|
|
135
|
+
layer.className = 'gramlot-waiting-layer';
|
|
136
|
+
layer.setAttribute('role', 'status');
|
|
137
|
+
const text = document.createElement('div');
|
|
138
|
+
text.className = 'gramlot-waiting-message';
|
|
139
|
+
text.textContent = message === true ? 'Loading content' : String(message);
|
|
140
|
+
layer.append(text);
|
|
141
|
+
const positioned = document.defaultView.getComputedStyle(element).position === 'static';
|
|
142
|
+
if (positioned) element.classList.add('gramlot-waiting-host');
|
|
143
|
+
element.setAttribute('aria-busy', 'true');
|
|
144
|
+
element.append(layer);
|
|
145
|
+
return () => {
|
|
146
|
+
layer.remove();
|
|
147
|
+
element.removeAttribute('aria-busy');
|
|
148
|
+
if (positioned) element.classList.remove('gramlot-waiting-host');
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
117
152
|
/** The current value of a control attribute: a pointer is read from Data. */
|
|
118
153
|
#control(name) {
|
|
119
154
|
const [, attrs] = this.node.rootBuilder.runtimeValues(this.node);
|
package/src/binding/runtime.js
CHANGED
|
@@ -69,6 +69,7 @@ export class BindingRuntime {
|
|
|
69
69
|
#dataRootTrees = new Set();
|
|
70
70
|
// One collection store per absolute Data path and rowMode, never per Bag identity.
|
|
71
71
|
#collectionStores = new Map();
|
|
72
|
+
#pendingFires = new Map();
|
|
72
73
|
|
|
73
74
|
constructor(gramlot, {subscriptions}) {
|
|
74
75
|
this.#gramlot = gramlot;
|
|
@@ -231,6 +232,28 @@ export class BindingRuntime {
|
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
|
|
235
|
+
/**
|
|
236
|
+
* The fire scheduled by `FIRE_AFTER` for the absolute Data `path`, one per path in the page (legacy
|
|
237
|
+
* `pendingCallAfter`, `genro.js:1216`): a new call cancels the pending one. `binding`, when given,
|
|
238
|
+
* owns the timer, so the close of its node cancels it. Returns the cancellation of this call.
|
|
239
|
+
*/
|
|
240
|
+
fireAfter(path, delay, binding, run) {
|
|
241
|
+
this.#pendingFires.get(path)?.();
|
|
242
|
+
let release = null;
|
|
243
|
+
const cancel = () => {
|
|
244
|
+
clearTimeout(timer);
|
|
245
|
+
release?.();
|
|
246
|
+
if (this.#pendingFires.get(path) === cancel) this.#pendingFires.delete(path);
|
|
247
|
+
};
|
|
248
|
+
const timer = setTimeout(() => {
|
|
249
|
+
cancel();
|
|
250
|
+
run();
|
|
251
|
+
}, delay);
|
|
252
|
+
release = binding?.track(cancel) ?? null;
|
|
253
|
+
this.#pendingFires.set(path, cancel);
|
|
254
|
+
return cancel;
|
|
255
|
+
}
|
|
256
|
+
|
|
234
257
|
/** The open NodeBinding of `node`, or null. */
|
|
235
258
|
bindingFor(node) {
|
|
236
259
|
return this.#bindings.get(node) ?? null;
|
|
@@ -405,6 +428,7 @@ export class BindingRuntime {
|
|
|
405
428
|
this.root.unsubscribe(this.#subscription, {any: true});
|
|
406
429
|
this.nodeIds.clear();
|
|
407
430
|
this.#dependents.clear();
|
|
431
|
+
for (const cancel of [...this.#pendingFires.values()]) cancel();
|
|
408
432
|
this.#collectionStores.clear();
|
|
409
433
|
const errors = [];
|
|
410
434
|
for (const [node, binding] of [...this.#bindings.entries()].reverse()) {
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
7
|
import {codeMirrorWithOptions} from '../components/editor-options.js';
|
|
8
|
+
import {htmlEditorToolbar} from '../components/html-editor-commands.js';
|
|
8
9
|
import {VisualEditor} from '../server/visual-editor.js';
|
|
9
10
|
import buttons from '../components/buttons.js';
|
|
10
11
|
import {ComponentCollection} from '../components/registry.js';
|
|
12
|
+
import {objectExtract} from '../object-extract.js';
|
|
11
13
|
import {Bag} from '@genrojs/bag';
|
|
12
14
|
import {HtmlBuilder, META_ATTRS, SourceBagNode, sourceTarget} from '@genrojs/builders';
|
|
13
15
|
import {toTytx} from '@genrojs/tytx';
|
|
@@ -45,6 +47,8 @@ const EXPORT_FORMATS = {csv:'CSV', json:'JSON', tytx:'TYTX', xml:'XML', xlsx:'Ex
|
|
|
45
47
|
// frameGrid composes these grid attributes itself; its own parameters reach the grid too.
|
|
46
48
|
const FRAME_GRID_COMPOSED = new Set(['node_label', 'frameTarget', 'nodeId']);
|
|
47
49
|
const FRAME_GRID_PARAMETERS = new Set(['storepath', 'rowMode', 'structpath']);
|
|
50
|
+
// An editor frame composes these canvas attributes itself.
|
|
51
|
+
const EDITOR_FRAME_COMPOSED = new Set(['node_label', 'frameTarget']);
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* An element whose `_meta.keywordPattern` is set accepts, besides its declared attributes, only the
|
|
@@ -104,7 +108,7 @@ function excludedAttribute(attrs) {
|
|
|
104
108
|
/** Gramlot vocabulary and inert authoring on the shared builder grammar. */
|
|
105
109
|
export class GramlotBuilder extends HtmlBuilder {
|
|
106
110
|
static _name = 'gramlot';
|
|
107
|
-
static containers = ['frameGrid', 'codeMirrorWithOptions', 'VisualEditor'];
|
|
111
|
+
static containers = ['frameGrid', 'codeMirrorWithOptions', 'VisualEditor', 'htmlEditor'];
|
|
108
112
|
static _sourceClass = GramlotBuilderBag;
|
|
109
113
|
// Composed on the inherited HtmlBuilder grammar; its data-elements replace Builder's.
|
|
110
114
|
static { this.defineGrammar(BINDING); }
|
|
@@ -119,6 +123,29 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
119
123
|
return new VisualEditor(parent, options);
|
|
120
124
|
}
|
|
121
125
|
|
|
126
|
+
/** A framePane with the htmlEditorCanvas in its center and, unless `toolbar` is false, the htmlEditor toolbar in top.bar. */
|
|
127
|
+
htmlEditor(parent, {toolbar = true, ...attrs} = {}) {
|
|
128
|
+
if (typeof toolbar !== 'boolean') throw new TypeError('htmlEditor toolbar requires a boolean');
|
|
129
|
+
return this.editorFrame(parent, 'htmlEditor', 'htmlEditorCanvas', toolbar ? htmlEditorToolbar : null, attrs);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Compose an editor frame: a framePane, the canvas as frame target in its center (node `canvas`) and
|
|
134
|
+
* the standard toolbar in top.bar. Canvas parameters go to the canvas; `canvas_`/`frame_` force any attribute.
|
|
135
|
+
*/
|
|
136
|
+
editorFrame(parent, owner, canvasTag, toolbar, attrs) {
|
|
137
|
+
for (const tag of ['framePane', canvasTag]) {
|
|
138
|
+
if (!this.schemaTag(tag)) throw new TypeError(`${owner} requires the ${tag} collection`);
|
|
139
|
+
}
|
|
140
|
+
const [frameAttrs, routed] = this.frameRoute(attrs, {owner, tag:canvasTag, prefix:'canvas_', composed:EDITOR_FRAME_COMPOSED});
|
|
141
|
+
const canvasAttrs = {...routed, node_label:'canvas', frameTarget:true, height:'100%', box_height:'100%'};
|
|
142
|
+
this.validateNodeValues(canvasTag, null, canvasAttrs);
|
|
143
|
+
const frame = parent.framePane({height:'400px', ...frameAttrs});
|
|
144
|
+
frame.center[canvasTag](canvasAttrs);
|
|
145
|
+
if (toolbar) toolbar(frame.top.menu({presentation:'bar', node_label:'bar', aria_label:'Editor toolbar', labelPosition:'tooltip'}));
|
|
146
|
+
return frame;
|
|
147
|
+
}
|
|
148
|
+
|
|
122
149
|
/** Compose real Source nodes; frame/grid/menu retain their existing runtime owners. */
|
|
123
150
|
frameGrid(parent, {storepath, rowMode, structpath, searchOn = false, searchHelp = false, chart = false,
|
|
124
151
|
export: exportRows = false, printRows = false, advancedTools = false, addrow = false, addrow_defaults = null, addrow_label = null,
|
|
@@ -126,10 +153,7 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
126
153
|
for (const tag of ['framePane', 'grid']) {
|
|
127
154
|
if (!this.schemaTag(tag)) throw new TypeError(`frameGrid requires the ${tag} collection`);
|
|
128
155
|
}
|
|
129
|
-
const chartOptions =
|
|
130
|
-
for (const key of Object.keys(attrs)) if (key.startsWith('chart_')) {
|
|
131
|
-
chartOptions[key.slice(6)] = attrs[key]; delete attrs[key];
|
|
132
|
-
}
|
|
156
|
+
const chartOptions = objectExtract(attrs, 'chart_*');
|
|
133
157
|
const [frameAttrs, routed] = this.frameGridRoute(attrs);
|
|
134
158
|
const twice = Object.keys(routed).find(name => ['storepath', 'rowMode'].includes(name) || name === 'structpath' && structpath != null);
|
|
135
159
|
if (twice !== undefined) throw new TypeError(`frameGrid: '${twice}' is given twice`);
|
|
@@ -197,25 +221,35 @@ export class GramlotBuilder extends HtmlBuilder {
|
|
|
197
221
|
|
|
198
222
|
/** Split frameGrid keywords: unprefixed grid parameters go to the grid, `grid_`/`frame_` force any attribute. */
|
|
199
223
|
frameGridRoute(attrs) {
|
|
200
|
-
|
|
224
|
+
return this.frameRoute(attrs, {owner:'frameGrid', tag:'grid', prefix:'grid_', composed:FRAME_GRID_COMPOSED, parameters:FRAME_GRID_PARAMETERS});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Split the keywords of a frame composite between the frame and its central `tag`. Unprefixed parameters
|
|
229
|
+
* of `tag` go to it; `prefix` and `frame_` force any attribute. `composed` names are set by the composite;
|
|
230
|
+
* `parameters` are its own keywords.
|
|
231
|
+
*/
|
|
232
|
+
frameRoute(attrs, {owner, tag, prefix, composed, parameters = new Set()}) {
|
|
233
|
+
const declared = name => new Set(this.schema[name].attributes.parameters.filter(parameter => !parameter.kind.startsWith('var_')).map(parameter => parameter.name));
|
|
201
234
|
const source = new Set([...FRAMEWORK_ATTRIBUTES, ...META_ATTRS]);
|
|
202
|
-
const
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
235
|
+
const childNames = declared(tag), frameNames = declared('framePane');
|
|
236
|
+
// A declared parameter family (grid selected_<field>); most elements declare none.
|
|
237
|
+
const family = this.schema[tag]._meta.parameterPattern, pattern = family ? new RegExp(family) : null;
|
|
238
|
+
// A name the frame also accepts stays on the frame unless forced with the prefix.
|
|
239
|
+
const routed = name => (childNames.has(name) || Boolean(pattern?.test(name))) && !frameNames.has(name) && !source.has(name)
|
|
240
|
+
&& !composed.has(name) && !parameters.has(name);
|
|
241
|
+
const frame = {}, child = {};
|
|
208
242
|
for (const [key, value] of Object.entries(attrs)) {
|
|
209
243
|
let name, target;
|
|
210
|
-
if (key.startsWith(
|
|
211
|
-
name = key.slice(
|
|
212
|
-
if (
|
|
244
|
+
if (key.startsWith(prefix)) {
|
|
245
|
+
name = key.slice(prefix.length); target = child;
|
|
246
|
+
if (composed.has(name)) throw new TypeError(`${owner}: '${key}' is composed by ${owner}`);
|
|
213
247
|
} else if (key.startsWith('frame_')) { name = key.slice('frame_'.length); target = frame; }
|
|
214
|
-
else { name = key; target = routed(key) ?
|
|
215
|
-
if (Object.hasOwn(target, name)) throw new TypeError(
|
|
248
|
+
else { name = key; target = routed(key) ? child : frame; }
|
|
249
|
+
if (Object.hasOwn(target, name)) throw new TypeError(`${owner}: '${name}' is given twice`);
|
|
216
250
|
target[name] = value;
|
|
217
251
|
}
|
|
218
|
-
return [frame,
|
|
252
|
+
return [frame, child];
|
|
219
253
|
}
|
|
220
254
|
|
|
221
255
|
/** Tag prefixes of the parent dialects, from the `_name` of the classes above GramlotBuilder. */
|
package/src/builder/source.js
CHANGED
|
@@ -14,7 +14,8 @@ const CODE_ATTRIBUTES = {
|
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
// The control attributes of `remote`, written on the node as they are; every other parameter becomes `remote_<k>`.
|
|
17
|
-
const REMOTE_CONTROLS = ['_cachedRemote', '_if', '_else', '_onRemote', '_onCalling', '
|
|
17
|
+
const REMOTE_CONTROLS = ['_cachedRemote', '_if', '_else', '_onRemote', '_onCalling', '_waitingMessage', '_delay', '_timing',
|
|
18
|
+
'_userChanges'];
|
|
18
19
|
// The inline code attributes of any node whose `remote` is a string.
|
|
19
20
|
const REMOTE_CODE_ATTRIBUTES = ['_if', '_else', '_onRemote', '_onCalling'];
|
|
20
21
|
|
|
@@ -309,6 +310,7 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
309
310
|
// The texts of the inline code received with the Source, by the name InlineCompiler uses; null before activation.
|
|
310
311
|
#activatedCode = null;
|
|
311
312
|
#requests = null;
|
|
313
|
+
#watches = new Map();
|
|
312
314
|
|
|
313
315
|
/** The requests of this node (NodeRequests): the request in flight and the waiting call of remote, dataRpc and dataRemote. */
|
|
314
316
|
get requests() {
|
|
@@ -381,7 +383,8 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
381
383
|
/**
|
|
382
384
|
* Declare the content of this element as the fragment `name` of a `@source` method: writes
|
|
383
385
|
* `remote = name` and one `remote_<k> = v` per entry of `params` on this node; the control attributes
|
|
384
|
-
* `_cachedRemote`, `_if`, `_else`, `_onRemote`, `_onCalling`, `_delay`, `_timing` and
|
|
386
|
+
* `_cachedRemote`, `_if`, `_else`, `_onRemote`, `_onCalling`, `_waitingMessage`, `_delay`, `_timing` and
|
|
387
|
+
* `_userChanges` are
|
|
385
388
|
* written as they are. Returns this node. `name` is a method name, matched by the name syntax of the
|
|
386
389
|
* page builder (`nameSyntax` of `rootBuilder`), or a `^`/`=` pointer to it; any other name, or another
|
|
387
390
|
* `_` parameter, is a TypeError.
|
|
@@ -525,21 +528,72 @@ export class GramlotBuilderBagNode extends SourceBagNode {
|
|
|
525
528
|
/**
|
|
526
529
|
* FIRE after `delay` ms. A null path (Q7) is an error at the call, not inside the timer. The timer
|
|
527
530
|
* is tracked on the node's NodeBinding when the node has one, so the close of the node cancels it;
|
|
528
|
-
* the returned function cancels it as well.
|
|
531
|
+
* the returned function cancels it as well. As legacy `fireAfter` (`genro.js:1216`), a call
|
|
532
|
+
* cancels the fire still pending for the same absolute path, whichever node scheduled it: the
|
|
533
|
+
* registry is the page's BindingRuntime. A node without a page runtime has no registry.
|
|
529
534
|
*/
|
|
530
535
|
FIRE_AFTER(path, value = true, delay = 10) {
|
|
531
536
|
this.#requireWritablePath(path);
|
|
532
|
-
const
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
+
const runtime = this.rootBuilder?.binding ?? null;
|
|
538
|
+
const binding = runtime?.bindingFor(this) ?? null;
|
|
539
|
+
if (runtime) return runtime.fireAfter(this.absDatapath(path), delay, binding, () => this.FIRE(path, value));
|
|
540
|
+
const timer = setTimeout(() => this.FIRE(path, value), delay);
|
|
541
|
+
return () => clearTimeout(timer);
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Legacy `watch` (`gnrdomsource.js:1937`): poll `conditionCb` every `delay` ms (default 200). When it is
|
|
546
|
+
* already true, `action` runs at once; otherwise the first poll that finds it true stops the watch, then
|
|
547
|
+
* runs `action`. A second `watch` with the same `watchId` replaces the first. `action` may be null: a
|
|
548
|
+
* `conditionCb` that works and returns false then runs until `unwatch`. The watches of a node stop when
|
|
549
|
+
* the node closes (the timer is tracked on its NodeBinding, as `FIRE_AFTER`).
|
|
550
|
+
*/
|
|
551
|
+
watch(watchId, conditionCb, action = null, delay = 200) {
|
|
552
|
+
delay = delay || 200;
|
|
553
|
+
this.unwatch(watchId);
|
|
554
|
+
if (conditionCb()) {
|
|
555
|
+
action?.();
|
|
556
|
+
return;
|
|
557
|
+
}
|
|
558
|
+
const binding = this.#openBinding();
|
|
559
|
+
const timer = setInterval(() => {
|
|
560
|
+
if (!conditionCb()) return;
|
|
561
|
+
this.unwatch(watchId);
|
|
562
|
+
action?.();
|
|
537
563
|
}, delay);
|
|
538
|
-
release = binding?.track(() =>
|
|
539
|
-
|
|
540
|
-
|
|
564
|
+
const release = binding?.track(() => clearInterval(timer)) ?? null;
|
|
565
|
+
this.#watches.set(watchId, () => {
|
|
566
|
+
clearInterval(timer);
|
|
541
567
|
release?.();
|
|
542
|
-
};
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** Legacy `unwatch` (`gnrdomsource.js:1930`): stop the watch `watchId` of this node; an unknown id does nothing. */
|
|
572
|
+
unwatch(watchId) {
|
|
573
|
+
const stop = this.#watches.get(watchId);
|
|
574
|
+
if (!stop) return;
|
|
575
|
+
this.#watches.delete(watchId);
|
|
576
|
+
stop();
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* Legacy `fireNode` (`gnrdomsource.js:179`): run now the provider of this node (`dataFormula`,
|
|
581
|
+
* `dataController`, `dataRpc`, `dataRemote`) with `runKwargs` merged over its arguments, trigger kind
|
|
582
|
+
* `fireNode`. Returns what `invoke` returns (the promise of a `dataRpc`). A node without a provider is
|
|
583
|
+
* an error; a node without an open NodeBinding runs nothing, as a closed provider.
|
|
584
|
+
*/
|
|
585
|
+
fireNode(runKwargs = {}) {
|
|
586
|
+
const binding = this.#openBinding();
|
|
587
|
+
if (binding === null) return undefined;
|
|
588
|
+
const [provider] = binding.providers;
|
|
589
|
+
if (!provider) throw new Error(`fireNode: '${this.label}' has no provider`);
|
|
590
|
+
return provider.invoke({kind: 'fireNode', change: null, runKwargs});
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
/** The open NodeBinding of this node; null for a node outside a Source or without one. */
|
|
594
|
+
#openBinding() {
|
|
595
|
+
if (this.parentBag === null) return null;
|
|
596
|
+
return this.rootBuilder?.binding?.bindingFor(this) ?? null;
|
|
543
597
|
}
|
|
544
598
|
|
|
545
599
|
/**
|
package/src/chat.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type {SourceBagNode} from '@genrojs/builders';
|
|
|
3
3
|
import type {Bag} from '@genrojs/bag';
|
|
4
4
|
export function chatRender(page: Gramlot, node: SourceBagNode, params: {messages: Bag}): void;
|
|
5
5
|
export function chatSend(page: Gramlot, node: SourceBagNode): void;
|
|
6
|
+
export function chatDraftKey(page: Gramlot, node: SourceBagNode, event: KeyboardEvent): void;
|
|
6
7
|
export function chatReset(page: Gramlot, node: SourceBagNode): void;
|
|
7
8
|
export function chatCompleted(page: Gramlot, node: SourceBagNode, params: {response: Bag | null}): void;
|
|
8
9
|
|
package/src/chat.js
CHANGED
|
@@ -87,13 +87,25 @@ function send(node, action, text=null) {
|
|
|
87
87
|
if(action === 'send') for(const file of node.getRelativeData('.attachments').getNodes()) {
|
|
88
88
|
attachments.setItem(file.label,new Bag({ref:file.staticValue.getItem('ref')}));
|
|
89
89
|
}
|
|
90
|
-
node.
|
|
90
|
+
const model=node.getRelativeData('.model') ?? null;
|
|
91
|
+
node.SET('.conversation.request',new Bag({id,action,text,attachments,model}));
|
|
91
92
|
}
|
|
92
93
|
export function chatSend(page,node) {
|
|
93
94
|
const text=node.getRelativeData('.draft');
|
|
94
95
|
if(typeof text !== 'string' || (!text.trim() && !node.getRelativeData('.attachments').length)) return;
|
|
95
96
|
send(node,'send',text);
|
|
96
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Composer keydown: Enter without modifiers runs the page Logic `chatSend`, so the send button
|
|
100
|
+
* conditions apply (a refused send inserts no newline); Shift+Enter and the other keys keep their
|
|
101
|
+
* default. Enter during an IME composition confirms the composition and never sends.
|
|
102
|
+
*/
|
|
103
|
+
export function chatDraftKey(page,node,event) {
|
|
104
|
+
if(event.key!=='Enter' || event.isComposing || event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) return;
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
const {group,method}=page.src.logicRegistry.resolve('chatSend',node);
|
|
107
|
+
method.call(group,node);
|
|
108
|
+
}
|
|
97
109
|
export function chatReset(page,node) {send(node,'reset');}
|
|
98
110
|
export function chatCompleted(page,node,{response}) {
|
|
99
111
|
if(response === null) return;
|
|
@@ -7,7 +7,6 @@ export function chartBar3DOptions(view, first, second, fields, settings, domains
|
|
|
7
7
|
const count=fields.length, span=0.72, step=count ? span/count : 0;
|
|
8
8
|
const boxWidth=100,boxDepth=80;
|
|
9
9
|
return {
|
|
10
|
-
backgroundColor:'#ffffff',
|
|
11
10
|
legend:{show:true,type:'scroll',left:12,right:12,bottom:10,height:24,data:fields},
|
|
12
11
|
tooltip:{renderMode:'richText',formatter:params=>{
|
|
13
12
|
const [x,y,value]=params.value;
|
|
@@ -14,7 +14,7 @@ export function chartBoxplotOptions({view,category,fields,seriesOptions}) {
|
|
|
14
14
|
names.push(name);
|
|
15
15
|
data.push(values);
|
|
16
16
|
}
|
|
17
|
-
return {
|
|
17
|
+
return {tooltip:{trigger:'item'},
|
|
18
18
|
grid:{left:60,right:30,top:30,bottom:50},
|
|
19
19
|
xAxis:{type:'category',data:names,name:category,boundaryGap:true},
|
|
20
20
|
yAxis:{type:'value',scale:true},
|
|
@@ -18,7 +18,7 @@ export function chartCandlestickOptions({view,category,fields,seriesOptions}) {
|
|
|
18
18
|
const itemStyle={};
|
|
19
19
|
if(up){itemStyle.color=up;itemStyle.borderColor=up;}
|
|
20
20
|
if(down){itemStyle.color0=down;itemStyle.borderColor0=down;}
|
|
21
|
-
return {
|
|
21
|
+
return {tooltip:{trigger:'axis',axisPointer:{type:'cross'}},
|
|
22
22
|
grid:{left:60,right:30,top:30,bottom:70},
|
|
23
23
|
xAxis:{type:'category',data:names,name:category,boundaryGap:true},
|
|
24
24
|
yAxis:{type:'value',scale:true},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {chartPalette,chartLabel} from '../chart-domains.js';
|
|
2
2
|
import {chartData} from '../chart-data.js';
|
|
3
|
+
import {chartCaption} from '../chart-type-data.js';
|
|
3
4
|
|
|
4
5
|
/** Shared 2D layout; each type declares its presentation capabilities. */
|
|
5
|
-
export function cartesianOptions({view,category,fields,settings,domains}, {seriesType,radial=false,horizontal=false,stacked=false,scatter=false,area=false,donut=false}) {
|
|
6
|
+
export function cartesianOptions({view,category,fields,settings,seriesOptions,domains}, {seriesType,radial=false,horizontal=false,stacked=false,scatter=false,area=false,donut=false}) {
|
|
6
7
|
const {source,kind} = chartData(view,category,fields,domains?.dimension);
|
|
7
8
|
if (stacked && new Set(settings.map(option => option.axis)).size > 1) throw new TypeError('Stacked series need the same scale. Assign all selected measures to the same axis.');
|
|
8
9
|
if (scatter && !['value','time'].includes(kind)) throw new TypeError('Scatter needs a numeric or date dimension. Choose another column.');
|
|
@@ -10,14 +11,14 @@ export function cartesianOptions({view,category,fields,settings,domains}, {serie
|
|
|
10
11
|
const numericAxes = ['left','right'].map((side,index) => ({type:'value',
|
|
11
12
|
position:horizontal ? ['bottom','top'][index] : side,
|
|
12
13
|
show:settings.some(options => options.axis === side),
|
|
13
|
-
name:fields.filter((field,i) => settings[i].axis === side).join(', '),
|
|
14
|
+
name:fields.filter((field,i) => settings[i].axis === side).map(field => chartCaption(seriesOptions,field)).join(', '),
|
|
14
15
|
...(domains?{min:domains.axes[side][0],max:domains.axes[side][1]}:{}),splitLine:{show:index === 0}}));
|
|
15
|
-
const option = {
|
|
16
|
+
const option = {useUTC:true,legend:{show:true},
|
|
16
17
|
tooltip:{trigger:radial || scatter ? 'item' : 'axis'},
|
|
17
18
|
grid:{left:80,right:75,top:65,bottom:65}};
|
|
18
19
|
if (radial) {
|
|
19
20
|
option.legend = {show:true,type:'scroll',orient:'horizontal',left:12,right:12,bottom:10,height:24};
|
|
20
|
-
option.series = fields.map(field => ({id:field,name:field,type:'pie',top:12,bottom:64,left:12,right:12,
|
|
21
|
+
option.series = fields.map(field => ({id:field,name:chartCaption(seriesOptions,field),type:'pie',top:12,bottom:64,left:12,right:12,
|
|
21
22
|
label:{alignTo:'edge',edgeDistance:10,overflow:'truncate'},labelLayout:{hideOverlap:true},
|
|
22
23
|
radius:donut ? ['35%','65%'] : '65%',
|
|
23
24
|
data:source.map(row => ({name:kind === 'time' ? new Date(row[0]).toISOString().slice(0,10) : String(row[0]),value:row[1],...(domains?{itemStyle:{color:chartPalette[domains.labels.indexOf(chartLabel(row[0],kind))%chartPalette.length]}}:{})}))}));
|
|
@@ -37,7 +38,7 @@ export function cartesianOptions({view,category,fields,settings,domains}, {serie
|
|
|
37
38
|
}
|
|
38
39
|
option.xAxis = horizontal ? numericAxes : dimension;
|
|
39
40
|
option.yAxis = horizontal ? dimension : numericAxes;
|
|
40
|
-
option.series = fields.map((field,index) => ({id:field,name:field,
|
|
41
|
+
option.series = fields.map((field,index) => ({id:field,name:chartCaption(seriesOptions,field),
|
|
41
42
|
type:seriesType,
|
|
42
43
|
...(seriesType==='line' ? {showSymbol:source.length===1} : {}),
|
|
43
44
|
...(horizontal ? {xAxisIndex:settings[index].axis === 'right' ? 1 : 0} : {yAxisIndex:settings[index].axis === 'right' ? 1 : 0}),
|
|
@@ -29,13 +29,9 @@ export class EChartsAdapter {
|
|
|
29
29
|
await loadLibrary('echartsGl',document,()=>import('echarts-gl/dist/echarts-gl.min.js'));
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
#chart; #type; #element; #options; #renderer;
|
|
32
|
+
#chart; #type; #element; #options; #renderer; #theme;
|
|
33
33
|
#mapName=`chart_${randomId()}`; #mapData;
|
|
34
|
-
constructor(element,options={}) {
|
|
35
|
-
this.#element=element;this.#options=options;
|
|
36
|
-
this.#renderer=options.renderer ?? 'canvas';
|
|
37
|
-
this.#chart=echarts.init(element,null,options);this.#bindSelection();
|
|
38
|
-
}
|
|
34
|
+
constructor(element,options={}) { this.#element=element;this.#options=options; }
|
|
39
35
|
#bindSelection() {
|
|
40
36
|
this.#chart.on('click',event=>{
|
|
41
37
|
if(this.#type==='mapBar3D' && event.seriesType==='bar3D')this.#options.onTerritorySelect?.(event.name);
|
|
@@ -43,12 +39,18 @@ export class EChartsAdapter {
|
|
|
43
39
|
});
|
|
44
40
|
}
|
|
45
41
|
validate(context) { return this[`render_${context.type.id}`](context); }
|
|
42
|
+
/** ECharts takes the theme only at init: a new renderer or new theme colours create the chart again. */
|
|
46
43
|
update(context,option) {
|
|
47
44
|
this.#type=context.type.id;
|
|
48
45
|
const renderer=context.type.threeD?'canvas':(this.#options.renderer ?? 'canvas');
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
const theme=JSON.stringify(context.theme);
|
|
47
|
+
if(!this.#chart || renderer!==this.#renderer || theme!==this.#theme) {
|
|
48
|
+
this.#chart?.dispose();
|
|
49
|
+
this.#chart=echarts.init(this.#element,echartsTheme(context.theme),{...this.#options,renderer});
|
|
50
|
+
this.#renderer=renderer;this.#theme=theme;this.#bindSelection();
|
|
51
51
|
}
|
|
52
|
+
if(!context.legend)option.legend={show:false};
|
|
53
|
+
if(!context.axes)hideAxes(option,context.legend);
|
|
52
54
|
this.#chart.setOption(option,{notMerge:true});
|
|
53
55
|
}
|
|
54
56
|
render_bar(context) { return cartesianOptions(context,{seriesType:'bar'}); }
|
|
@@ -101,6 +103,21 @@ export class EChartsAdapter {
|
|
|
101
103
|
render_treemap(context) { return chartTreemapOptions(context); }
|
|
102
104
|
render_sunburst(context) { return chartSunburstOptions(context); }
|
|
103
105
|
svg() { return this.#chart.renderToSVGString(); }
|
|
104
|
-
resize() { this.#chart
|
|
105
|
-
dispose() { this.#chart
|
|
106
|
+
resize() { this.#chart?.resize(); }
|
|
107
|
+
dispose() { this.#chart?.dispose();if(this.#mapData)echarts.registerMap(this.#mapName,{type:'FeatureCollection',features:[]}); }
|
|
108
|
+
}
|
|
109
|
+
/** Hide the X and Y axes: no name, tick labels, ticks or split lines. The grid takes the whole area, less the bottom space of a legend. */
|
|
110
|
+
function hideAxes(option,legend) {
|
|
111
|
+
if(!option.xAxis && !option.yAxis)return;
|
|
112
|
+
for(const key of ['xAxis','yAxis']) {
|
|
113
|
+
if(option[key])option[key]=[option[key]].flat().map(axis=>({...axis,show:false}));
|
|
114
|
+
}
|
|
115
|
+
option.grid={...option.grid,left:0,right:0,top:0,...(legend?{}:{bottom:0})};
|
|
116
|
+
}
|
|
117
|
+
/** ECharts theme from the chart colours: background, text of the chart, title, legend and visual map, axes and split lines. */
|
|
118
|
+
function echartsTheme({background,text,axis,grid}) {
|
|
119
|
+
const axisTheme={axisLine:{lineStyle:{color:axis}},axisTick:{lineStyle:{color:axis}},axisLabel:{color:text},
|
|
120
|
+
nameTextStyle:{color:text},splitLine:{lineStyle:{color:[grid]}}};
|
|
121
|
+
return {backgroundColor:background,textStyle:{color:text},title:{textStyle:{color:text}},legend:{textStyle:{color:text}},visualMap:{textStyle:{color:text}},
|
|
122
|
+
categoryAxis:axisTheme,valueAxis:axisTheme,timeAxis:axisTheme,logAxis:axisTheme};
|
|
106
123
|
}
|
|
@@ -18,7 +18,7 @@ export function plotlyMap({view,category,structure,seriesOptions,domains},layout
|
|
|
18
18
|
layout.title={text:title};layout.showlegend=false;layout.margin={l:10,r:70,t:45,b:20};
|
|
19
19
|
// Own GeoJSON supplies all geometry; no basemap tiles, tokens or network assets.
|
|
20
20
|
layout.geo={visible:false,showframe:false,showcoastlines:false,showland:false,showocean:false,
|
|
21
|
-
showcountries:false,showlakes:false,showrivers:false,fitbounds:'geojson',projection:{type:'mercator'},bgcolor:
|
|
21
|
+
showcountries:false,showlakes:false,showrivers:false,fitbounds:'geojson',projection:{type:'mercator'},bgcolor:layout.paper_bgcolor};
|
|
22
22
|
const colors=signed?['#b73548','#f7f7f7','#2166ac']:chartMapColors;
|
|
23
23
|
const dataTrace={type:'choropleth',geojson:geometry,featureidkey:'properties.name',
|
|
24
24
|
locations:data.map(row=>row.name),z:data.map(row=>row.value),zmin:min,zmax:max,
|