@yuneta/gobj-ui 7.26.39 → 7.26.41
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 +37 -2
- package/dist/gobj-ui.cjs.js +135 -75
- package/dist/gobj-ui.es.js +135 -75
- package/package.json +1 -1
- package/src/c_yui_form.js +80 -68
- package/src/c_yui_uplot.js +8 -58
- package/src/form_table_edits_ask.wiring.test.js +398 -0
- package/src/form_table_rearm.wiring.test.js +9 -7
- package/src/uplot_ink.test.js +105 -0
- package/src/yui_tabulator_i18n.js +21 -1
- package/src/yui_tabulator_i18n.test.js +39 -0
- package/src/yui_text.js +10 -0
- package/src/yui_text.test.js +13 -0
- package/src/yui_uplot_ink.js +94 -0
package/README.md
CHANGED
|
@@ -3394,6 +3394,22 @@ the middle, and **a toolbar left with a single group is centred**. An unknown
|
|
|
3394
3394
|
name is reported, not silently dropped: a typo would otherwise remove the save
|
|
3395
3395
|
button with no trace of why.
|
|
3396
3396
|
|
|
3397
|
+
### Charts — the ink of the axes, on both schemes
|
|
3398
|
+
|
|
3399
|
+
uPlot is built for a white page: its axis labels are black, its grid 7% black.
|
|
3400
|
+
`C_YUI_UPLOT` gives its axes the ink of the theme -- both of them: uPlot always
|
|
3401
|
+
draws an X and a Y axis, and until 7.26.40 the Y axis kept uPlot's black, which
|
|
3402
|
+
no one could read on the dark scheme. A uPlot built by the app itself takes the
|
|
3403
|
+
same axes from `yui_uplot_axes()`, and redraws on a change of the theme
|
|
3404
|
+
(`yui_watch_theme(gobj)` sends `EV_THEME`; its action calls `chart.redraw()`):
|
|
3405
|
+
|
|
3406
|
+
```js
|
|
3407
|
+
import {yui_uplot_axes} from "@yuneta/gobj-ui/src/yui_uplot_ink.js";
|
|
3408
|
+
|
|
3409
|
+
new uPlot({width: 600, height: 300, series: [{}, {label: "temperature"}],
|
|
3410
|
+
axes: yui_uplot_axes([{}])}, data, $el);
|
|
3411
|
+
```
|
|
3412
|
+
|
|
3397
3413
|
### `C_YUI_FORM` — what closing it asks about
|
|
3398
3414
|
|
|
3399
3415
|
`changes` says the form is not what is stored: the reader changed it, or the
|
|
@@ -3406,6 +3422,15 @@ true. A record that lacks a defaulted field opens changed and closes without
|
|
|
3406
3422
|
a question; until 7.26.39 it asked on every close, about nothing the reader
|
|
3407
3423
|
would lose.
|
|
3408
3424
|
|
|
3425
|
+
What the reader does to a TABLE of the form -- edits a cell, adds a row,
|
|
3426
|
+
deletes one, in a nested table too -- is `edited` like anything typed, whatever
|
|
3427
|
+
the record the form opened with. Each table hears it from the moment it is
|
|
3428
|
+
built (a nested one is built by its row, whenever the row is drawn); the rows
|
|
3429
|
+
the form loads itself say nothing. In 7.26.39 and 7.26.40 a form that opened
|
|
3430
|
+
changed did not hear its tables at all, so closing it lost a table edit without
|
|
3431
|
+
a question. And the titles of those tables change language with the shell's
|
|
3432
|
+
`EV_LANGUAGE_CHANGED` (7.26.41+), like the rest of the form.
|
|
3433
|
+
|
|
3409
3434
|
```js
|
|
3410
3435
|
const kw = {abort_close: false};
|
|
3411
3436
|
gobj_send_event(form, "EV_WINDOW_TO_CLOSE", kw, gobj);
|
|
@@ -3901,14 +3926,24 @@ loading/error notices) and it never went through i18n. Use:
|
|
|
3901
3926
|
```js
|
|
3902
3927
|
new Tabulator($el, {...settings, ...yui_tabulator_lang(t)}); // at build
|
|
3903
3928
|
yui_tabulator_relocalize(table, t); // on the event
|
|
3929
|
+
yui_tabulator_relocalize(table, t, {device_id: t("device id")}); // and the titles
|
|
3904
3930
|
```
|
|
3905
3931
|
|
|
3906
3932
|
Every key falls back to the English string Tabulator used to render
|
|
3907
3933
|
(`defaultValue`), so an app that defines none of them sees no change. Two traps
|
|
3908
3934
|
the implementation already handles: `setLocale()` with the locale name already
|
|
3909
3935
|
in force is a **no-op** (hence a fresh name per switch), and re-applying a locale
|
|
3910
|
-
makes Tabulator
|
|
3911
|
-
**
|
|
3936
|
+
makes Tabulator run every title formatter again on the EXISTING header cell, and
|
|
3937
|
+
**append** what one returns when it is a Node. `text_title_formatter` empties
|
|
3938
|
+
the cell first (7.26.41; until then each change of language added one more copy
|
|
3939
|
+
of every title, *"Id dispositivoId dispositivo"*); a title formatter of your own
|
|
3940
|
+
that returns a Node must do the same (`cell.getElement().textContent = ""`).
|
|
3941
|
+
|
|
3942
|
+
The column TITLES change language through the locale too: hand them, already
|
|
3943
|
+
translated, by field (the third argument). Tabulator binds each title to its
|
|
3944
|
+
locale, so they are drawn again and no column is rebuilt -- `updateDefinition()`
|
|
3945
|
+
re-renders every row, and a row formatter that builds something in its row (a
|
|
3946
|
+
nested table) builds it again, empty.
|
|
3912
3947
|
|
|
3913
3948
|
**A missing key is invisible:** i18next answers an unknown key **with the key
|
|
3914
3949
|
itself**, so it renders (lower-case English) and simply never changes language.
|
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -505,8 +505,16 @@ function text_node(value) {
|
|
|
505
505
|
* Tabulator puts a STRING title in with innerHTML, so a title taken
|
|
506
506
|
* from a schema (`header`, which the schema editor writes) is markup
|
|
507
507
|
* unless the column carries a formatter that returns a Node.
|
|
508
|
+
*
|
|
509
|
+
* And it APPENDS that Node to the title's holder, which it never
|
|
510
|
+
* empties -- while it runs the formatter again on every setLocale()
|
|
511
|
+
* (yui_tabulator_relocalize()). Until 7.26.40 each change of language
|
|
512
|
+
* added one more copy of every title ("Id dispositivoId dispositivo").
|
|
513
|
+
* The holder (the mock cell's element) is emptied first.
|
|
508
514
|
************************************************************/
|
|
509
515
|
function text_title_formatter(cell) {
|
|
516
|
+
const $holder = typeof cell.getElement === "function" ? cell.getElement() : null;
|
|
517
|
+
if ($holder) $holder.textContent = "";
|
|
510
518
|
return text_node(cell.getValue());
|
|
511
519
|
}
|
|
512
520
|
/************************************************************
|
|
@@ -7106,6 +7114,12 @@ function register_c_yui_wizard() {
|
|
|
7106
7114
|
* new Tabulator($el, {..., ...yui_tabulator_lang(t)});
|
|
7107
7115
|
* yui_tabulator_relocalize(table, t); // on a language change
|
|
7108
7116
|
*
|
|
7117
|
+
* A view whose COLUMN TITLES change language hands them too, in the
|
|
7118
|
+
* new language, by field -- Tabulator binds each column's title to its
|
|
7119
|
+
* locale, so they change with it and no column is rebuilt:
|
|
7120
|
+
*
|
|
7121
|
+
* yui_tabulator_relocalize(table, t, {device_id: t("device id")});
|
|
7122
|
+
*
|
|
7109
7123
|
* Every key carries an English `defaultValue`, so an app that does not
|
|
7110
7124
|
* define it renders exactly what Tabulator rendered before — the
|
|
7111
7125
|
* keys are an OPPORTUNITY to translate, never a requirement.
|
|
@@ -7264,11 +7278,23 @@ function yui_tabulator_name_editor(column_def, name_of) {
|
|
|
7264
7278
|
return Object.assign({}, params, { elementAttributes: attrs });
|
|
7265
7279
|
};
|
|
7266
7280
|
}
|
|
7267
|
-
|
|
7281
|
+
/***************************************************************
|
|
7282
|
+
* yui_tabulator_relocalize() -- see "Put an EXISTING table in the
|
|
7283
|
+
* current language" above.
|
|
7284
|
+
*
|
|
7285
|
+
* `titles`, optional: {field: title}, the titles of the columns in
|
|
7286
|
+
* the new language, already translated. They go in the locale
|
|
7287
|
+
* (`columns`), where Tabulator binds each column's title: setLocale()
|
|
7288
|
+
* draws them again without rebuilding a column -- updateDefinition()
|
|
7289
|
+
* re-renders every row, and a row whose formatter builds something (a
|
|
7290
|
+
* nested table) builds it anew. A field left out keeps its title.
|
|
7291
|
+
***************************************************************/
|
|
7292
|
+
function yui_tabulator_relocalize(table, t, titles) {
|
|
7268
7293
|
if (!table) return;
|
|
7269
7294
|
try {
|
|
7270
7295
|
let name = next_lang_name();
|
|
7271
7296
|
let strings = tabulator_strings(t);
|
|
7297
|
+
if (titles && typeof titles === "object") strings.columns = Object.assign({}, titles);
|
|
7272
7298
|
table.options.langs = table.options.langs || {};
|
|
7273
7299
|
table.options.langs[name] = strings;
|
|
7274
7300
|
let localize = table.modules && table.modules.localize;
|
|
@@ -9487,7 +9513,7 @@ var attrs_table$17 = [
|
|
|
9487
9513
|
(0, _yuneta_gobj_js.SDATA_END)()
|
|
9488
9514
|
];
|
|
9489
9515
|
var PRIVATE_DATA$17 = {
|
|
9490
|
-
|
|
9516
|
+
loading_rows: 0,
|
|
9491
9517
|
tables: null,
|
|
9492
9518
|
table_seq: 0,
|
|
9493
9519
|
json_names_posted: false,
|
|
@@ -9543,18 +9569,12 @@ function mt_stop$17(gobj) {
|
|
|
9543
9569
|
* Local Methods
|
|
9544
9570
|
***************************/
|
|
9545
9571
|
/************************************************************
|
|
9546
|
-
*
|
|
9547
|
-
|
|
9548
|
-
function isEventSet(table, event) {
|
|
9549
|
-
let eventListeners = table.externalEvents.events;
|
|
9550
|
-
return eventListeners && eventListeners[event] && eventListeners[event].length > 0;
|
|
9551
|
-
}
|
|
9552
|
-
/************************************************************
|
|
9553
|
-
*
|
|
9572
|
+
* `changes` and the save/undo buttons. What the tables say is
|
|
9573
|
+
* not switched here: they always say it (create_tabulator).
|
|
9554
9574
|
************************************************************/
|
|
9555
9575
|
function set_changed_stated(gobj, changed) {
|
|
9556
9576
|
let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
|
|
9557
|
-
|
|
9577
|
+
$container.querySelector("form");
|
|
9558
9578
|
const enable = ($btn, on, color) => {
|
|
9559
9579
|
if (!$btn) return;
|
|
9560
9580
|
if (on) $btn.removeAttribute("disabled");
|
|
@@ -9569,35 +9589,11 @@ function set_changed_stated(gobj, changed) {
|
|
|
9569
9589
|
(0, _yuneta_gobj_js.gobj_write_bool_attr)(gobj, "changes", true);
|
|
9570
9590
|
enable($button_save, true, "MediumSeaGreen");
|
|
9571
9591
|
enable($button_undo, true, "Magenta");
|
|
9572
|
-
$form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
|
|
9573
|
-
if ($table.tabulator && isEventSet($table.tabulator, "dataChanged")) $table.tabulator.off("dataChanged");
|
|
9574
|
-
$table.querySelectorAll(".yui-tabulator-table-nested").forEach(($table_nested) => {
|
|
9575
|
-
if ($table_nested.tabulator && isEventSet($table_nested.tabulator, "dataChanged")) $table_nested.tabulator.off("dataChanged");
|
|
9576
|
-
});
|
|
9577
|
-
});
|
|
9578
9592
|
} else {
|
|
9579
9593
|
(0, _yuneta_gobj_js.gobj_write_bool_attr)(gobj, "changes", false);
|
|
9580
9594
|
(0, _yuneta_gobj_js.gobj_write_bool_attr)(gobj, "edited", false);
|
|
9581
9595
|
enable($button_save, false, OFF_COLOR);
|
|
9582
9596
|
enable($button_undo, false, OFF_COLOR);
|
|
9583
|
-
if (gobj.priv.rearm_timer) clearTimeout(gobj.priv.rearm_timer);
|
|
9584
|
-
gobj.priv.rearm_timer = setTimeout(function() {
|
|
9585
|
-
gobj.priv.rearm_timer = null;
|
|
9586
|
-
if ((0, _yuneta_gobj_js.gobj_is_destroying)(gobj)) return;
|
|
9587
|
-
const rearm = (tabulator) => {
|
|
9588
|
-
if (!tabulator) return;
|
|
9589
|
-
if (isEventSet(tabulator, "dataChanged")) tabulator.off("dataChanged");
|
|
9590
|
-
tabulator.on("dataChanged", function(data) {
|
|
9591
|
-
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
9592
|
-
});
|
|
9593
|
-
};
|
|
9594
|
-
$form.querySelectorAll(".yui-tabulator-table").forEach(($table) => {
|
|
9595
|
-
rearm($table.tabulator);
|
|
9596
|
-
$table.querySelectorAll(".yui-tabulator-table-nested").forEach(($table_nested) => {
|
|
9597
|
-
rearm($table_nested.tabulator);
|
|
9598
|
-
});
|
|
9599
|
-
});
|
|
9600
|
-
}, 200);
|
|
9601
9597
|
}
|
|
9602
9598
|
}
|
|
9603
9599
|
/************************************************************
|
|
@@ -9834,10 +9830,6 @@ function build_ui$15(gobj) {
|
|
|
9834
9830
|
* Destroy UI
|
|
9835
9831
|
************************************************************/
|
|
9836
9832
|
function destroy_ui$10(gobj) {
|
|
9837
|
-
if (gobj.priv && gobj.priv.rearm_timer) {
|
|
9838
|
-
clearTimeout(gobj.priv.rearm_timer);
|
|
9839
|
-
gobj.priv.rearm_timer = null;
|
|
9840
|
-
}
|
|
9841
9833
|
let $container = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "$container");
|
|
9842
9834
|
if ($container) {
|
|
9843
9835
|
destroy_widgets(gobj, $container);
|
|
@@ -11231,6 +11223,10 @@ function create_tabulator$1(gobj, $extend, name, template) {
|
|
|
11231
11223
|
hozAlign: "center"
|
|
11232
11224
|
};
|
|
11233
11225
|
let tabulator = new tabulator_tables.TabulatorFull($extend, tabulator_settings);
|
|
11226
|
+
tabulator.on("dataChanged", function() {
|
|
11227
|
+
if (gobj.priv.loading_rows > 0) return;
|
|
11228
|
+
(0, _yuneta_gobj_js.gobj_send_event)(gobj, "EV_RECORD_CHANGED", {}, gobj);
|
|
11229
|
+
});
|
|
11234
11230
|
tabulator.on("renderComplete", function() {
|
|
11235
11231
|
yui_tabulator_name_row_selects(tabulator, i18next.t);
|
|
11236
11232
|
});
|
|
@@ -11248,6 +11244,24 @@ function create_tabulator$1(gobj, $extend, name, template) {
|
|
|
11248
11244
|
return tabulator;
|
|
11249
11245
|
}
|
|
11250
11246
|
/******************************************************************
|
|
11247
|
+
* The title of a table's column: the schema's header, or the
|
|
11248
|
+
* field's name, translated.
|
|
11249
|
+
******************************************************************/
|
|
11250
|
+
function column_title(field_desc) {
|
|
11251
|
+
return (0, i18next.t)(field_desc.header || field_desc.name);
|
|
11252
|
+
}
|
|
11253
|
+
/******************************************************************
|
|
11254
|
+
* {field: title} of a table's template, in the current language.
|
|
11255
|
+
******************************************************************/
|
|
11256
|
+
function table_column_titles(template) {
|
|
11257
|
+
let titles = {};
|
|
11258
|
+
Object.entries(template || {}).forEach(([key, value]) => {
|
|
11259
|
+
const field_desc = (0, _yuneta_gobj_js.template_get_field_desc)(key, value);
|
|
11260
|
+
titles[field_desc.name] = column_title(field_desc);
|
|
11261
|
+
});
|
|
11262
|
+
return titles;
|
|
11263
|
+
}
|
|
11264
|
+
/******************************************************************
|
|
11251
11265
|
* Convert a template's items in tabulator columns
|
|
11252
11266
|
******************************************************************/
|
|
11253
11267
|
function template2columns(gobj, columns, template, sub_elements) {
|
|
@@ -11260,7 +11274,7 @@ function template2columns(gobj, columns, template, sub_elements) {
|
|
|
11260
11274
|
let validator = [];
|
|
11261
11275
|
let column = {
|
|
11262
11276
|
field: field_desc.name,
|
|
11263
|
-
title: (
|
|
11277
|
+
title: column_title(field_desc),
|
|
11264
11278
|
titleFormatter: text_title_formatter,
|
|
11265
11279
|
editable: get_editable_state,
|
|
11266
11280
|
editor: false,
|
|
@@ -12115,7 +12129,14 @@ function ac_add_table_row(gobj, event, kw, src) {
|
|
|
12115
12129
|
}
|
|
12116
12130
|
let record = kw.record;
|
|
12117
12131
|
let loading = kw.loading;
|
|
12118
|
-
|
|
12132
|
+
let added;
|
|
12133
|
+
if (loading) gobj.priv.loading_rows++;
|
|
12134
|
+
try {
|
|
12135
|
+
added = tabulator.addRow(record);
|
|
12136
|
+
} finally {
|
|
12137
|
+
if (loading) gobj.priv.loading_rows--;
|
|
12138
|
+
}
|
|
12139
|
+
added.then(function(row) {
|
|
12119
12140
|
if (loading) {
|
|
12120
12141
|
let template = $table.template;
|
|
12121
12142
|
Object.entries(template).forEach(([key, template_value]) => {
|
|
@@ -12222,6 +12243,10 @@ function ac_language_changed$10(gobj, event, kw, src) {
|
|
|
12222
12243
|
let editor = $editor.jsoneditor;
|
|
12223
12244
|
if (editor && typeof editor.updateProps === "function") editor.updateProps({ onRenderMenu: json_editor_render_menu(gobj) });
|
|
12224
12245
|
}
|
|
12246
|
+
for (let $table of $container.querySelectorAll(".yui-tabulator-table, .yui-tabulator-table-nested")) {
|
|
12247
|
+
let tabulator = $table.tabulator;
|
|
12248
|
+
if (tabulator && tabulator.initialized && $table.template) yui_tabulator_relocalize(tabulator, i18next.t, table_column_titles($table.template));
|
|
12249
|
+
}
|
|
12225
12250
|
return 0;
|
|
12226
12251
|
}
|
|
12227
12252
|
/***************************
|
|
@@ -13396,41 +13421,58 @@ function register_c_yui_map() {
|
|
|
13396
13421
|
return create_gclass$16(GCLASS_NAME$16);
|
|
13397
13422
|
}
|
|
13398
13423
|
//#endregion
|
|
13399
|
-
//#region src/
|
|
13424
|
+
//#region src/yui_uplot_ink.js
|
|
13400
13425
|
/***********************************************************************
|
|
13401
|
-
*
|
|
13426
|
+
* yui_uplot_ink.js
|
|
13402
13427
|
*
|
|
13403
|
-
*
|
|
13428
|
+
* The ink of a uPlot chart, on both schemes, and its palette.
|
|
13404
13429
|
*
|
|
13405
|
-
*
|
|
13430
|
+
* uPlot is built for a white page: its axis labels are `#000`
|
|
13431
|
+
* and its grid `rgba(0,0,0,0.07)`, which on the dark scheme are
|
|
13432
|
+
* 1.16:1 and 1.04 -- an axis nobody can read and a grid that is
|
|
13433
|
+
* not there. The inks here are handed to uPlot as FUNCTIONS: it
|
|
13434
|
+
* calls them when it draws, so the value can never be stale --
|
|
13435
|
+
* what goes stale is the canvas, and a change of the theme has to
|
|
13436
|
+
* ask for a redraw (yui_watch_theme() turns it into an event).
|
|
13437
|
+
*
|
|
13438
|
+
* uPlot ALWAYS draws a Y axis: its setDefaults() makes axes[1]
|
|
13439
|
+
* whether it was given or not, with its own black. So the axes are
|
|
13440
|
+
* padded to two before they are inked. C_YUI_UPLOT's default is
|
|
13441
|
+
* `[{}]`, the X axis alone, and until 7.26.40 every chart of the
|
|
13442
|
+
* library had a Y axis whose values could not be read in the dark.
|
|
13443
|
+
*
|
|
13444
|
+
* C_YUI_UPLOT uses it, and so can an app that builds a uPlot of its
|
|
13445
|
+
* own:
|
|
13446
|
+
*
|
|
13447
|
+
* import {yui_uplot_axes} from "@yuneta/gobj-ui/src/yui_uplot_ink.js";
|
|
13448
|
+
*
|
|
13449
|
+
* const chart = new uPlot({
|
|
13450
|
+
* width: 600, height: 300,
|
|
13451
|
+
* series: [{}, {label: "temperature"}],
|
|
13452
|
+
* axes: yui_uplot_axes([{}]), // X and Y, with the ink of the theme
|
|
13453
|
+
* }, data, $el);
|
|
13454
|
+
*
|
|
13455
|
+
* The palette is six colours that clear 3:1 on BOTH grounds
|
|
13456
|
+
* (worst 3.39 on white, 3.71 on near-black), ordered so the first
|
|
13457
|
+
* two are the pair that survives colour blindness -- blue and
|
|
13458
|
+
* orange, never red and green as the opening pair.
|
|
13459
|
+
*
|
|
13460
|
+
* Copyright (c) 2026, ArtGins.
|
|
13406
13461
|
* All Rights Reserved.
|
|
13407
13462
|
***********************************************************************/
|
|
13408
|
-
|
|
13409
|
-
* The ink of
|
|
13410
|
-
|
|
13411
|
-
|
|
13412
|
-
* and its grid `rgba(0,0,0,0.07)`, which on the dark scheme are
|
|
13413
|
-
* 1.16:1 and 1.04 -- an axis nobody can read and a grid that is
|
|
13414
|
-
* not there. And the series were CSS colour names: `blue` is
|
|
13415
|
-
* 2.11:1 on the dark ground, `orange` 1.97 on the light one, so
|
|
13416
|
-
* whichever scheme you were in, one of the lines was a rumour.
|
|
13417
|
-
*
|
|
13418
|
-
* These are given to uPlot as FUNCTIONS: it calls them when it
|
|
13419
|
-
* draws, so the value can never be stale -- what goes stale is
|
|
13420
|
-
* the canvas, and that is what EV_THEME redraws.
|
|
13421
|
-
*
|
|
13422
|
-
* The palette is six colours that clear 3:1 on BOTH grounds
|
|
13423
|
-
* (worst 3.39 on white, 3.71 on near-black), ordered so the
|
|
13424
|
-
* first two are the pair that survives colour blindness -- blue
|
|
13425
|
-
* and orange, never red and green as the opening pair.
|
|
13426
|
-
***************************************************************/
|
|
13427
|
-
function axis_ink() {
|
|
13463
|
+
/************************************************************
|
|
13464
|
+
* The ink of the labels of an axis.
|
|
13465
|
+
************************************************************/
|
|
13466
|
+
function yui_uplot_axis_ink() {
|
|
13428
13467
|
return yui_is_dark() ? "#c7cdd8" : "#2e333d";
|
|
13429
13468
|
}
|
|
13430
|
-
|
|
13469
|
+
/************************************************************
|
|
13470
|
+
* The ink of the grid and of the ticks.
|
|
13471
|
+
************************************************************/
|
|
13472
|
+
function yui_uplot_grid_ink() {
|
|
13431
13473
|
return yui_is_dark() ? "rgba(199,205,216,0.16)" : "rgba(46,51,61,0.12)";
|
|
13432
13474
|
}
|
|
13433
|
-
var
|
|
13475
|
+
var YUI_UPLOT_PALETTE = [
|
|
13434
13476
|
{
|
|
13435
13477
|
stroke: "#2f6fd0",
|
|
13436
13478
|
fill: "rgba(47,111,208,0.10)"
|
|
@@ -13456,15 +13498,33 @@ var CHART_PALETTE = [
|
|
|
13456
13498
|
fill: "rgba(209,52,75,0.10)"
|
|
13457
13499
|
}
|
|
13458
13500
|
];
|
|
13459
|
-
|
|
13460
|
-
|
|
13501
|
+
/************************************************************
|
|
13502
|
+
* The axes the host asked for -- at least the X and the Y,
|
|
13503
|
+
* the two uPlot always draws -- with the ink it did not ask
|
|
13504
|
+
* about. A stroke, a grid or a ticks the host gave is kept.
|
|
13505
|
+
* Answers new objects: the host's are not touched.
|
|
13506
|
+
************************************************************/
|
|
13507
|
+
function yui_uplot_axes(axes) {
|
|
13508
|
+
let list = Array.isArray(axes) ? axes.slice() : [axes || {}];
|
|
13509
|
+
while (list.length < 2) list.push({});
|
|
13510
|
+
return list.map((ax) => {
|
|
13461
13511
|
let a = Object.assign({}, ax || {});
|
|
13462
|
-
if (a.stroke === void 0) a.stroke =
|
|
13463
|
-
a.grid = Object.assign({ stroke:
|
|
13464
|
-
a.ticks = Object.assign({ stroke:
|
|
13512
|
+
if (a.stroke === void 0) a.stroke = yui_uplot_axis_ink;
|
|
13513
|
+
a.grid = Object.assign({ stroke: yui_uplot_grid_ink }, a.grid || {});
|
|
13514
|
+
a.ticks = Object.assign({ stroke: yui_uplot_grid_ink }, a.ticks || {});
|
|
13465
13515
|
return a;
|
|
13466
13516
|
});
|
|
13467
13517
|
}
|
|
13518
|
+
//#endregion
|
|
13519
|
+
//#region src/c_yui_uplot.js
|
|
13520
|
+
/***********************************************************************
|
|
13521
|
+
* c_yui_uplot.js
|
|
13522
|
+
*
|
|
13523
|
+
* Graphics, Charts with uPlot
|
|
13524
|
+
*
|
|
13525
|
+
* Copyright (c) 2025-2026, ArtGins.
|
|
13526
|
+
* All Rights Reserved.
|
|
13527
|
+
***********************************************************************/
|
|
13468
13528
|
/***************************************************************
|
|
13469
13529
|
* Constants
|
|
13470
13530
|
***************************************************************/
|
|
@@ -13482,7 +13542,7 @@ var attrs_table$15 = [
|
|
|
13482
13542
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_JSON, "axes", 0, [{}], "Chart axes"),
|
|
13483
13543
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_JSON, "scales", 0, {}, "Chart scales"),
|
|
13484
13544
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_JSON, "data", 0, [[]], "Chart data"),
|
|
13485
|
-
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_JSON, "colors", 0,
|
|
13545
|
+
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_JSON, "colors", 0, YUI_UPLOT_PALETTE, "Series colours, in order. The default palette clears 3:1 on both schemes and opens with the colour-blind-safe pair (blue, orange)"),
|
|
13486
13546
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_POINTER, "$container", 0, null, "HTML container for the chart"),
|
|
13487
13547
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_BOOLEAN, "own_container", 0, false, "If true, container is gobj-managed"),
|
|
13488
13548
|
(0, _yuneta_gobj_js.SDATA)(_yuneta_gobj_js.data_type_t.DTP_POINTER, "uplot", 0, null, "uPlot instance"),
|
|
@@ -13549,7 +13609,7 @@ function build_ui$14(gobj) {
|
|
|
13549
13609
|
width: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "width"),
|
|
13550
13610
|
height: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "height"),
|
|
13551
13611
|
series: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "series"),
|
|
13552
|
-
axes:
|
|
13612
|
+
axes: yui_uplot_axes((0, _yuneta_gobj_js.gobj_read_attr)(gobj, "axes")),
|
|
13553
13613
|
scales: (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "scales")
|
|
13554
13614
|
};
|
|
13555
13615
|
let uplot$2 = new uplot.default(uPlot_options, (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "data"), $container);
|
|
@@ -13650,7 +13710,7 @@ function ac_add_serie(gobj, event, kw, src) {
|
|
|
13650
13710
|
}
|
|
13651
13711
|
}
|
|
13652
13712
|
let colors = (0, _yuneta_gobj_js.gobj_read_attr)(gobj, "colors");
|
|
13653
|
-
if (!Array.isArray(colors) || !colors.length) colors =
|
|
13713
|
+
if (!Array.isArray(colors) || !colors.length) colors = YUI_UPLOT_PALETTE;
|
|
13654
13714
|
let color = colors[Math.max(0, idx - 1) % colors.length];
|
|
13655
13715
|
if (kw.stroke === void 0) kw.stroke = color.stroke;
|
|
13656
13716
|
if (kw.fill === void 0) kw.fill = color.fill;
|