@trismegisto/charts 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -80,7 +80,9 @@ ativo) e `[(showTable)]`.
|
|
|
80
80
|
**`hm-chart` (`HmChartComponent`)** é a saída de emergência para o que os tipados não cobrem: recebe a opção
|
|
81
81
|
completa do motor (`option: HmChartOption`, tipada pelos `Hm*SeriesOption`), `label` e `points` (pontos
|
|
82
82
|
navegáveis pelas setas). Ele cuida de ciclo de vida, tema, idioma, movimento reduzido e alto contraste, mas
|
|
83
|
-
**não** monta resumo nem tabela: prefira sempre um tipado.
|
|
83
|
+
**não** monta resumo nem tabela: prefira sempre um tipado. O motor grava o retorno de um `tooltip.formatter` com
|
|
84
|
+
`innerHTML`: num `formatter` próprio, passe todo texto vindo de dados por `escapeHtml` (`@trismegisto/primitives`),
|
|
85
|
+
como os tipados fazem.
|
|
84
86
|
|
|
85
87
|
## Regras que o app precisa saber
|
|
86
88
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, inject, computed, Injectable, input, model, Directive, ElementRef, signal, afterNextRender, effect, untracked, DestroyRef, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { HermesI18nService } from '@trismegisto/angular/i18n';
|
|
4
|
-
import { mergeCatalog, formatMessage, pluralMessage } from '@trismegisto/primitives';
|
|
4
|
+
import { mergeCatalog, formatMessage, pluralMessage, escapeHtml } from '@trismegisto/primitives';
|
|
5
5
|
|
|
6
6
|
const CHARTS_MESSAGES_EN = {
|
|
7
7
|
meta: { locale: 'en-US' },
|
|
@@ -403,6 +403,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.24", ngImpo
|
|
|
403
403
|
type: Directive
|
|
404
404
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], legend: [{ type: i0.Input, args: [{ isSignal: true, alias: "legend", required: false }] }], tooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "tooltip", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], numberFormat: [{ type: i0.Input, args: [{ isSignal: true, alias: "numberFormat", required: false }] }], showTable: [{ type: i0.Input, args: [{ isSignal: true, alias: "showTable", required: false }] }, { type: i0.Output, args: ["showTableChange"] }] } });
|
|
405
405
|
// ---- peças de opção compartilhadas -------------------------------------------------------------
|
|
406
|
+
/**
|
|
407
|
+
* Tooltip comum. O motor grava a saída de um `formatter` com `innerHTML`: todo gráfico que define o
|
|
408
|
+
* próprio `formatter` devolve `escapeHtml(...)` (`@trismegisto/primitives`) do texto montado com nomes
|
|
409
|
+
* vindos dos dados. O formatter padrão do motor já escapa.
|
|
410
|
+
*/
|
|
406
411
|
function tooltipOption(ctx, trigger) {
|
|
407
412
|
return {
|
|
408
413
|
show: ctx.tooltip,
|
|
@@ -31619,7 +31624,10 @@ function getCachePerECFullUpdate(ecModel) {
|
|
|
31619
31624
|
*/
|
|
31620
31625
|
let wmUniqueIndex = Math.round(Math.random() * 9);
|
|
31621
31626
|
const supportDefineProperty = typeof Object.defineProperty === 'function';
|
|
31622
|
-
|
|
31627
|
+
// Nome próprio de propósito: no bundle achatado do pacote, uma classe de topo chamada `WeakMap` sombreia o global, e o
|
|
31628
|
+
// código rebaixado por quem consome (campos `#privados` viram `new WeakMap()` no pré-bundle do Vite) quebrava com
|
|
31629
|
+
// "WeakMap is not a constructor".
|
|
31630
|
+
class ZrWeakMap {
|
|
31623
31631
|
constructor() {
|
|
31624
31632
|
this._id = '__ec_inner_' + wmUniqueIndex++;
|
|
31625
31633
|
}
|
|
@@ -31864,7 +31872,7 @@ const symbolBuildProxies = {};
|
|
|
31864
31872
|
each$9(symbolCtors, function (Ctor, name) {
|
|
31865
31873
|
symbolBuildProxies[name] = new Ctor();
|
|
31866
31874
|
});
|
|
31867
|
-
const SymbolClz = Path.extend({
|
|
31875
|
+
const SymbolClz$1 = Path.extend({
|
|
31868
31876
|
type: 'symbol',
|
|
31869
31877
|
shape: {
|
|
31870
31878
|
symbolType: '',
|
|
@@ -31933,7 +31941,7 @@ keepAspect) {
|
|
|
31933
31941
|
symbolPath = makePath(symbolType.slice(7), {}, new BoundingRect(x, y, w, h), keepAspect ? 'center' : 'cover');
|
|
31934
31942
|
}
|
|
31935
31943
|
else {
|
|
31936
|
-
symbolPath = new SymbolClz({
|
|
31944
|
+
symbolPath = new SymbolClz$1({
|
|
31937
31945
|
shape: {
|
|
31938
31946
|
symbolType: symbolType,
|
|
31939
31947
|
x: x,
|
|
@@ -31988,7 +31996,7 @@ function normalizeSymbolOffset(symbolOffset, symbolSize) {
|
|
|
31988
31996
|
* specific language governing permissions and limitations
|
|
31989
31997
|
* under the License.
|
|
31990
31998
|
*/
|
|
31991
|
-
const decalMap = new
|
|
31999
|
+
const decalMap = new ZrWeakMap();
|
|
31992
32000
|
const decalCache = new LRU(100);
|
|
31993
32001
|
const decalKeys = [
|
|
31994
32002
|
'symbol', 'symbolSize', 'symbolKeepAspect',
|
|
@@ -46396,7 +46404,8 @@ class LineSeriesModel extends SeriesModel {
|
|
|
46396
46404
|
* specific language governing permissions and limitations
|
|
46397
46405
|
* under the License.
|
|
46398
46406
|
*/
|
|
46399
|
-
|
|
46407
|
+
// `SymbolClz`, não `Symbol`: uma classe de topo com esse nome sombreia o `Symbol` global no bundle achatado.
|
|
46408
|
+
class SymbolClz extends Group$3 {
|
|
46400
46409
|
constructor(data, idx, seriesScope, opts) {
|
|
46401
46410
|
super();
|
|
46402
46411
|
this.updateData(data, idx, seriesScope, opts);
|
|
@@ -46477,8 +46486,8 @@ class Symbol extends Group$3 {
|
|
|
46477
46486
|
this.silent = false;
|
|
46478
46487
|
const symbolType = data.getItemVisual(idx, 'symbol') || 'circle';
|
|
46479
46488
|
const seriesModel = data.hostModel;
|
|
46480
|
-
const symbolSize =
|
|
46481
|
-
const z2 =
|
|
46489
|
+
const symbolSize = SymbolClz.getSymbolSize(data, idx);
|
|
46490
|
+
const z2 = SymbolClz.getSymbolZ2(data, idx);
|
|
46482
46491
|
const isInit = symbolType !== this._symbolType;
|
|
46483
46492
|
const disableAnimation = opts && opts.disableAnimation;
|
|
46484
46493
|
if (isInit) {
|
|
@@ -46740,7 +46749,7 @@ function createEl(SymbolCtor, data, newIdx, seriesScope, symbolUpdateOpt, point,
|
|
|
46740
46749
|
class SymbolDraw {
|
|
46741
46750
|
constructor(SymbolCtor) {
|
|
46742
46751
|
this.group = new Group$3();
|
|
46743
|
-
this._SymbolCtor = SymbolCtor ||
|
|
46752
|
+
this._SymbolCtor = SymbolCtor || SymbolClz;
|
|
46744
46753
|
}
|
|
46745
46754
|
/**
|
|
46746
46755
|
* Update symbols draw by new data
|
|
@@ -47958,7 +47967,7 @@ function canShowAllSymbolForCategory(categoryAxis, data) {
|
|
|
47958
47967
|
const dataLen = data.count();
|
|
47959
47968
|
const step = Math.max(1, Math.round(dataLen / 5));
|
|
47960
47969
|
for (let dataIndex = 0; dataIndex < dataLen; dataIndex += step) {
|
|
47961
|
-
if (
|
|
47970
|
+
if (SymbolClz.getSymbolSize(data, dataIndex
|
|
47962
47971
|
// Only for cartesian, where `isHorizontal` exists.
|
|
47963
47972
|
)[categoryAxis.isHorizontal() ? 1 : 0]
|
|
47964
47973
|
// Empirical number
|
|
@@ -48351,7 +48360,7 @@ class LineView extends ChartView {
|
|
|
48351
48360
|
}
|
|
48352
48361
|
const zlevel = seriesModel.get('zlevel') || 0;
|
|
48353
48362
|
const z = seriesModel.get('z') || 0;
|
|
48354
|
-
symbol = new
|
|
48363
|
+
symbol = new SymbolClz(data, dataIndex);
|
|
48355
48364
|
symbol.x = x;
|
|
48356
48365
|
symbol.y = y;
|
|
48357
48366
|
symbol.setZ(zlevel, z);
|
|
@@ -75824,7 +75833,7 @@ class HmHeatmapChartComponent extends HmChartBase {
|
|
|
75824
75833
|
...tooltipOption(ctx, 'item'),
|
|
75825
75834
|
formatter: (p) => {
|
|
75826
75835
|
const value = p.value;
|
|
75827
|
-
return `${ys[value[1]]} · ${xs[value[0]]}: ${ctx.num(value[2])}
|
|
75836
|
+
return escapeHtml(`${ys[value[1]]} · ${xs[value[0]]}: ${ctx.num(value[2])}`);
|
|
75828
75837
|
},
|
|
75829
75838
|
},
|
|
75830
75839
|
xAxis: { type: 'category', data: [...xs], splitArea: { show: true } },
|
|
@@ -75902,7 +75911,7 @@ class HmCalendarHeatmapComponent extends HmChartBase {
|
|
|
75902
75911
|
...tooltipOption(ctx, 'item'),
|
|
75903
75912
|
formatter: (p) => {
|
|
75904
75913
|
const [day, value] = p.value;
|
|
75905
|
-
return `${fmtDate(day)}: ${ctx.num(value)}
|
|
75914
|
+
return escapeHtml(`${fmtDate(day)}: ${ctx.num(value)}`);
|
|
75906
75915
|
},
|
|
75907
75916
|
},
|
|
75908
75917
|
visualMap: {
|
|
@@ -75988,7 +75997,7 @@ class HmScatterChartComponent extends HmChartBase {
|
|
|
75988
75997
|
formatter: (p) => {
|
|
75989
75998
|
const { seriesIndex, dataIndex } = p;
|
|
75990
75999
|
const s = series[seriesIndex];
|
|
75991
|
-
return describe(s, s.data[dataIndex]);
|
|
76000
|
+
return escapeHtml(describe(s, s.data[dataIndex]));
|
|
75992
76001
|
},
|
|
75993
76002
|
},
|
|
75994
76003
|
legend: legendOption(ctx, hasLegend),
|
|
@@ -76134,7 +76143,7 @@ class HmRadarChartComponent extends HmChartBase {
|
|
|
76134
76143
|
const describe = (s) => `${s.name}: ${indicators.map((ind, i) => `${ind.name} ${ctx.num(s.values[i])}`).join(', ')}`;
|
|
76135
76144
|
return {
|
|
76136
76145
|
option: {
|
|
76137
|
-
tooltip: { ...tooltipOption(ctx, 'item'), formatter: (p) => describe(series[p.dataIndex]) },
|
|
76146
|
+
tooltip: { ...tooltipOption(ctx, 'item'), formatter: (p) => escapeHtml(describe(series[p.dataIndex])) },
|
|
76138
76147
|
legend: legendOption(ctx, series.length > 1),
|
|
76139
76148
|
radar: {
|
|
76140
76149
|
radius: '64%',
|
|
@@ -76313,7 +76322,7 @@ class HmBoxplotChartComponent extends HmChartBase {
|
|
|
76313
76322
|
...tooltipOption(ctx, 'item'),
|
|
76314
76323
|
formatter: (p) => {
|
|
76315
76324
|
const g = groups[p.dataIndex];
|
|
76316
|
-
return describe(g.name, g.s);
|
|
76325
|
+
return escapeHtml(describe(g.name, g.s));
|
|
76317
76326
|
},
|
|
76318
76327
|
},
|
|
76319
76328
|
xAxis: horizontal ? valueAxis : categoryAxis,
|