@visactor/vchart 1.1.1 → 1.2.0-beta.1
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/build/index.js +183 -61
- package/build/index.min.js +1 -1
- package/cjs/chart/base-chart.d.ts +1 -0
- package/cjs/chart/base-chart.js +17 -12
- package/cjs/chart/base-chart.js.map +1 -1
- package/cjs/chart/interface/chart.d.ts +1 -0
- package/cjs/chart/interface/chart.js.map +1 -1
- package/cjs/chart/sequence/sequence.js +5 -3
- package/cjs/chart/sequence/sequence.js.map +1 -1
- package/cjs/compile/compiler.js +9 -5
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/compile/interface/compiler.d.ts +1 -0
- package/cjs/compile/interface/compiler.js.map +1 -1
- package/cjs/component/axis/cartesian/axis.js +1 -1
- package/cjs/component/axis/cartesian/axis.js.map +1 -1
- package/cjs/component/axis/interface.d.ts +25 -27
- package/cjs/component/axis/interface.js.map +1 -1
- package/cjs/component/axis/polar/axis.js +2 -2
- package/cjs/component/axis/polar/axis.js.map +1 -1
- package/cjs/component/geo/geo-coordinate.js +1 -1
- package/cjs/component/geo/geo-coordinate.js.map +1 -1
- package/cjs/component/geo/projection.js +1 -2
- package/cjs/component/geo/projection.js.map +1 -1
- package/cjs/component/label/label.d.ts +7 -0
- package/cjs/component/label/label.js +4 -0
- package/cjs/component/label/label.js.map +1 -1
- package/cjs/component/marker/base-marker.js +1 -1
- package/cjs/component/marker/base-marker.js.map +1 -1
- package/cjs/component/marker/interface.d.ts +2 -2
- package/cjs/component/marker/interface.js.map +1 -1
- package/cjs/constant/event.d.ts +2 -0
- package/cjs/constant/event.js +2 -1
- package/cjs/constant/event.js.map +1 -1
- package/cjs/core/index.d.ts +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/index.js.map +1 -1
- package/cjs/core/vchart.d.ts +6 -0
- package/cjs/core/vchart.js +66 -23
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/data/initialize.d.ts +2 -1
- package/cjs/data/initialize.js +8 -5
- package/cjs/data/initialize.js.map +1 -1
- package/cjs/event/events/dimension/base.js +5 -3
- package/cjs/event/events/dimension/base.js.map +1 -1
- package/cjs/layout/base-layout.d.ts +3 -0
- package/cjs/layout/base-layout.js +8 -4
- package/cjs/layout/base-layout.js.map +1 -1
- package/cjs/layout/grid-layout/grid-layout.d.ts +3 -1
- package/cjs/layout/grid-layout/grid-layout.js +3 -2
- package/cjs/layout/grid-layout/grid-layout.js.map +1 -1
- package/cjs/layout/interface.d.ts +2 -1
- package/cjs/layout/interface.js.map +1 -1
- package/cjs/model/interface.d.ts +1 -0
- package/cjs/model/interface.js.map +1 -1
- package/cjs/series/base/base-series.js +2 -4
- package/cjs/series/base/base-series.js.map +1 -1
- package/cjs/series/geo/geo.js +3 -3
- package/cjs/series/geo/geo.js.map +1 -1
- package/cjs/series/map/map.js +6 -6
- package/cjs/series/map/map.js.map +1 -1
- package/cjs/series/scatter/scatter.js +7 -4
- package/cjs/series/scatter/scatter.js.map +1 -1
- package/cjs/series/sunburst/sunburst.d.ts +1 -1
- package/cjs/typings/params.d.ts +5 -0
- package/cjs/typings/params.js.map +1 -1
- package/cjs/typings/spec/common.d.ts +1 -0
- package/cjs/typings/spec/common.js.map +1 -1
- package/cjs/typings/visual.js.map +1 -1
- package/cjs/util/debug.d.ts +2 -2
- package/cjs/util/debug.js +4 -3
- package/cjs/util/debug.js.map +1 -1
- package/cjs/util/image.d.ts +2 -1
- package/cjs/util/image.js +10 -6
- package/cjs/util/image.js.map +1 -1
- package/cjs/util/math.js +5 -3
- package/cjs/util/math.js.map +1 -1
- package/esm/chart/base-chart.d.ts +1 -0
- package/esm/chart/base-chart.js +17 -12
- package/esm/chart/base-chart.js.map +1 -1
- package/esm/chart/interface/chart.d.ts +1 -0
- package/esm/chart/interface/chart.js.map +1 -1
- package/esm/chart/sequence/sequence.js +5 -3
- package/esm/chart/sequence/sequence.js.map +1 -1
- package/esm/compile/compiler.js +10 -6
- package/esm/compile/compiler.js.map +1 -1
- package/esm/compile/interface/compiler.d.ts +1 -0
- package/esm/compile/interface/compiler.js.map +1 -1
- package/esm/component/axis/cartesian/axis.js +1 -1
- package/esm/component/axis/cartesian/axis.js.map +1 -1
- package/esm/component/axis/interface.d.ts +25 -27
- package/esm/component/axis/interface.js.map +1 -1
- package/esm/component/axis/polar/axis.js +2 -2
- package/esm/component/axis/polar/axis.js.map +1 -1
- package/esm/component/geo/geo-coordinate.js +1 -1
- package/esm/component/geo/geo-coordinate.js.map +1 -1
- package/esm/component/geo/projection.js +1 -1
- package/esm/component/geo/projection.js.map +1 -1
- package/esm/component/label/label.d.ts +7 -0
- package/esm/component/label/label.js +4 -0
- package/esm/component/label/label.js.map +1 -1
- package/esm/component/marker/base-marker.js +1 -1
- package/esm/component/marker/base-marker.js.map +1 -1
- package/esm/component/marker/interface.d.ts +2 -2
- package/esm/component/marker/interface.js.map +1 -1
- package/esm/constant/event.d.ts +2 -0
- package/esm/constant/event.js +2 -1
- package/esm/constant/event.js.map +1 -1
- package/esm/core/index.d.ts +1 -1
- package/esm/core/index.js +1 -1
- package/esm/core/index.js.map +1 -1
- package/esm/core/vchart.d.ts +6 -0
- package/esm/core/vchart.js +68 -23
- package/esm/core/vchart.js.map +1 -1
- package/esm/data/initialize.d.ts +2 -1
- package/esm/data/initialize.js +9 -4
- package/esm/data/initialize.js.map +1 -1
- package/esm/event/events/dimension/base.js +6 -2
- package/esm/event/events/dimension/base.js.map +1 -1
- package/esm/layout/base-layout.d.ts +3 -0
- package/esm/layout/base-layout.js +8 -4
- package/esm/layout/base-layout.js.map +1 -1
- package/esm/layout/grid-layout/grid-layout.d.ts +3 -1
- package/esm/layout/grid-layout/grid-layout.js +3 -2
- package/esm/layout/grid-layout/grid-layout.js.map +1 -1
- package/esm/layout/interface.d.ts +2 -1
- package/esm/layout/interface.js.map +1 -1
- package/esm/model/interface.d.ts +1 -0
- package/esm/model/interface.js.map +1 -1
- package/esm/series/base/base-series.js +1 -4
- package/esm/series/base/base-series.js.map +1 -1
- package/esm/series/geo/geo.js +3 -3
- package/esm/series/geo/geo.js.map +1 -1
- package/esm/series/map/map.js +6 -6
- package/esm/series/map/map.js.map +1 -1
- package/esm/series/scatter/scatter.js +5 -4
- package/esm/series/scatter/scatter.js.map +1 -1
- package/esm/series/sunburst/sunburst.d.ts +1 -1
- package/esm/typings/params.d.ts +5 -0
- package/esm/typings/params.js.map +1 -1
- package/esm/typings/spec/common.d.ts +1 -0
- package/esm/typings/spec/common.js.map +1 -1
- package/esm/typings/visual.js.map +1 -1
- package/esm/util/debug.d.ts +2 -2
- package/esm/util/debug.js +4 -3
- package/esm/util/debug.js.map +1 -1
- package/esm/util/image.d.ts +2 -1
- package/esm/util/image.js +6 -3
- package/esm/util/image.js.map +1 -1
- package/esm/util/math.js +4 -2
- package/esm/util/math.js.map +1 -1
- package/package.json +9 -19
- package/chart.d.ts +0 -1
- package/chart.js +0 -1
- package/component.d.ts +0 -1
- package/component.js +0 -1
- package/core.d.ts +0 -1
- package/core.js +0 -1
- package/layout.d.ts +0 -1
- package/layout.js +0 -1
- package/mark.d.ts +0 -1
- package/mark.js +0 -1
- package/series.d.ts +0 -1
- package/series.js +0 -1
package/build/index.js
CHANGED
|
@@ -7937,8 +7937,11 @@
|
|
|
7937
7937
|
return Logger.getInstance().warn(`[VChart warn]: ${msg}`);
|
|
7938
7938
|
};
|
|
7939
7939
|
const error$1 = (msg, detail, err) => {
|
|
7940
|
-
|
|
7941
|
-
|
|
7940
|
+
if (isFunction(config.errorHandler)) {
|
|
7941
|
+
config.errorHandler.call(null, msg, detail);
|
|
7942
|
+
return;
|
|
7943
|
+
}
|
|
7944
|
+
throw new Error(msg);
|
|
7942
7945
|
};
|
|
7943
7946
|
const config = {
|
|
7944
7947
|
silent: false,
|
|
@@ -8341,7 +8344,8 @@
|
|
|
8341
8344
|
function min$2(data, field) {
|
|
8342
8345
|
const initialData = field ? +data[0][field] : +data[0];
|
|
8343
8346
|
if (!isValidNumber(initialData)) {
|
|
8344
|
-
|
|
8347
|
+
warn('invalid data');
|
|
8348
|
+
return 0;
|
|
8345
8349
|
}
|
|
8346
8350
|
const min = data.reduce((pre, _cur) => {
|
|
8347
8351
|
const cur = field ? +_cur[field] : +_cur;
|
|
@@ -8355,7 +8359,8 @@
|
|
|
8355
8359
|
function max$2(data, field) {
|
|
8356
8360
|
const initialData = field ? +data[0][field] : +data[0];
|
|
8357
8361
|
if (!isValidNumber(initialData)) {
|
|
8358
|
-
|
|
8362
|
+
warn('invalid data');
|
|
8363
|
+
return 0;
|
|
8359
8364
|
}
|
|
8360
8365
|
const max = data.reduce((pre, _cur) => {
|
|
8361
8366
|
const cur = field ? +_cur[field] : +_cur;
|
|
@@ -51514,6 +51519,8 @@
|
|
|
51514
51519
|
(function (ChartEvent) {
|
|
51515
51520
|
ChartEvent["initialized"] = "initialized";
|
|
51516
51521
|
ChartEvent["rendered"] = "rendered";
|
|
51522
|
+
ChartEvent["renderFinished"] = "renderFinished";
|
|
51523
|
+
ChartEvent["animationFinished"] = "animationFinished";
|
|
51517
51524
|
ChartEvent["regionSeriesDataFilterOver"] = "regionSeriesDataFilterOver";
|
|
51518
51525
|
ChartEvent["afterInitData"] = "afterInitData";
|
|
51519
51526
|
ChartEvent["afterInitEvent"] = "afterInitEvent";
|
|
@@ -53461,10 +53468,10 @@
|
|
|
53461
53468
|
this._chart = this._eventDispatcher.globalInstance.getChart?.();
|
|
53462
53469
|
}
|
|
53463
53470
|
register(eType, handler) {
|
|
53464
|
-
|
|
53471
|
+
(this._chart?.getOption().onError ?? error$1)('Method not implemented.');
|
|
53465
53472
|
}
|
|
53466
53473
|
unregister() {
|
|
53467
|
-
|
|
53474
|
+
(this._chart?.getOption().onError ?? error$1)('Method not implemented.');
|
|
53468
53475
|
}
|
|
53469
53476
|
getTargetDimensionInfo(x, y) {
|
|
53470
53477
|
const cartesianInfo = getCartesianDimensionInfo(this._chart, { x, y }) ?? [];
|
|
@@ -54101,7 +54108,7 @@
|
|
|
54101
54108
|
});
|
|
54102
54109
|
return viewData;
|
|
54103
54110
|
}
|
|
54104
|
-
function dataToDataView(data, dataSet, sourceDataViews = []) {
|
|
54111
|
+
function dataToDataView(data, dataSet, sourceDataViews = [], ctx = {}) {
|
|
54105
54112
|
if (data instanceof DataView) {
|
|
54106
54113
|
return data;
|
|
54107
54114
|
}
|
|
@@ -54120,7 +54127,8 @@
|
|
|
54120
54127
|
if (typeof fromDataId === 'string') {
|
|
54121
54128
|
const fromDataView = sourceDataViews.find(dv => dv.name === fromDataId);
|
|
54122
54129
|
if (!fromDataView) {
|
|
54123
|
-
|
|
54130
|
+
(ctx.onError ?? error$1)(`no data matches fromDataId ${fromDataId}`);
|
|
54131
|
+
return null;
|
|
54124
54132
|
}
|
|
54125
54133
|
dataView.parse([fromDataView], {
|
|
54126
54134
|
type: 'dataview'
|
|
@@ -54132,7 +54140,8 @@
|
|
|
54132
54140
|
else if (typeof fromDataIndex === 'number') {
|
|
54133
54141
|
const fromDataView = sourceDataViews[fromDataIndex];
|
|
54134
54142
|
if (!fromDataView) {
|
|
54135
|
-
|
|
54143
|
+
(ctx.onError ?? error$1)(`no data matches fromDataIndex ${fromDataIndex}`);
|
|
54144
|
+
return null;
|
|
54136
54145
|
}
|
|
54137
54146
|
dataView.parse([fromDataView], {
|
|
54138
54147
|
type: 'dataview'
|
|
@@ -54150,7 +54159,7 @@
|
|
|
54150
54159
|
}
|
|
54151
54160
|
else {
|
|
54152
54161
|
dataView.parse([]);
|
|
54153
|
-
|
|
54162
|
+
warn('values should be array');
|
|
54154
54163
|
}
|
|
54155
54164
|
if (transforms && transforms.length) {
|
|
54156
54165
|
transforms.forEach((transform) => {
|
|
@@ -54287,6 +54296,12 @@
|
|
|
54287
54296
|
if (this._view) {
|
|
54288
54297
|
return;
|
|
54289
54298
|
}
|
|
54299
|
+
const logger = new Logger(this._option.logLevel ?? LoggerLevel.Error);
|
|
54300
|
+
if (this._option.onError) {
|
|
54301
|
+
logger.addErrorHandler((...args) => {
|
|
54302
|
+
this._option.onError(...args);
|
|
54303
|
+
});
|
|
54304
|
+
}
|
|
54290
54305
|
this._view = new View({
|
|
54291
54306
|
width: this._width,
|
|
54292
54307
|
height: this._height,
|
|
@@ -54306,7 +54321,8 @@
|
|
|
54306
54321
|
doLayout: () => {
|
|
54307
54322
|
this._compileChart?.onLayout(this._view);
|
|
54308
54323
|
},
|
|
54309
|
-
|
|
54324
|
+
logger: logger,
|
|
54325
|
+
logLevel: logger.level()
|
|
54310
54326
|
});
|
|
54311
54327
|
this._setCanvasStyle();
|
|
54312
54328
|
const interactive = this._option.interactive;
|
|
@@ -54560,7 +54576,7 @@
|
|
|
54560
54576
|
});
|
|
54561
54577
|
});
|
|
54562
54578
|
}
|
|
54563
|
-
async function getCanvasDataURL(c) {
|
|
54579
|
+
async function getCanvasDataURL(c, ctx) {
|
|
54564
54580
|
if (!c) {
|
|
54565
54581
|
return '';
|
|
54566
54582
|
}
|
|
@@ -54569,8 +54585,8 @@
|
|
|
54569
54585
|
return OffscreenCanvasToDataURL(c);
|
|
54570
54586
|
}
|
|
54571
54587
|
}
|
|
54572
|
-
catch (
|
|
54573
|
-
|
|
54588
|
+
catch (_error) {
|
|
54589
|
+
(ctx?.onError ?? error$1)(`getCanvasDataURL error : ${_error.toString()}`);
|
|
54574
54590
|
}
|
|
54575
54591
|
return c.toDataURL();
|
|
54576
54592
|
}
|
|
@@ -54631,15 +54647,20 @@
|
|
|
54631
54647
|
_autoSize = true;
|
|
54632
54648
|
_option = {
|
|
54633
54649
|
mode: exports.RenderModeEnum['desktop-browser'],
|
|
54634
|
-
animation: true
|
|
54650
|
+
animation: true,
|
|
54651
|
+
onError: (msg) => {
|
|
54652
|
+
throw new Error(msg);
|
|
54653
|
+
}
|
|
54635
54654
|
};
|
|
54636
54655
|
_curSize = { width: 0, height: 0 };
|
|
54637
54656
|
_observer = null;
|
|
54638
54657
|
_currentThemeName;
|
|
54639
54658
|
_currentTheme;
|
|
54659
|
+
_onError;
|
|
54640
54660
|
_context = {};
|
|
54641
54661
|
constructor(spec, options) {
|
|
54642
54662
|
this._option = merge$2(this._option, options);
|
|
54663
|
+
this._onError = this._option.onError;
|
|
54643
54664
|
const { dom, renderCanvas, mode, stage, poptip, ...restOptions } = this._option;
|
|
54644
54665
|
if (dom) {
|
|
54645
54666
|
this._container = isString(dom) ? document?.getElementById(dom) : dom;
|
|
@@ -54651,7 +54672,7 @@
|
|
|
54651
54672
|
this._stage = stage;
|
|
54652
54673
|
}
|
|
54653
54674
|
if (mode !== 'node' && !this._container && !this._canvas && !this._stage) {
|
|
54654
|
-
|
|
54675
|
+
this._option.onError('please specify container or renderCanvas!');
|
|
54655
54676
|
return;
|
|
54656
54677
|
}
|
|
54657
54678
|
this._viewBox = this._option.viewBox;
|
|
@@ -54666,7 +54687,8 @@
|
|
|
54666
54687
|
stage,
|
|
54667
54688
|
pluginList: poptip !== false ? ['poptipForText'] : [],
|
|
54668
54689
|
...restOptions,
|
|
54669
|
-
background: spec.background || this._currentTheme.background || this._option.background
|
|
54690
|
+
background: spec.background || this._currentTheme.background || this._option.background,
|
|
54691
|
+
onError: this._onError
|
|
54670
54692
|
});
|
|
54671
54693
|
this._eventDispatcher = new EventDispatcher(this, this._compiler);
|
|
54672
54694
|
this._event = new Event$1(this._eventDispatcher, mode);
|
|
@@ -54681,6 +54703,7 @@
|
|
|
54681
54703
|
height: spec.height || 0
|
|
54682
54704
|
};
|
|
54683
54705
|
this._bindResizeEvent();
|
|
54706
|
+
this._bindVGrammarViewEvent();
|
|
54684
54707
|
this._event.emit(ChartEvent.initialized, {});
|
|
54685
54708
|
InstanceManager.registerInstance(this);
|
|
54686
54709
|
}
|
|
@@ -54699,13 +54722,15 @@
|
|
|
54699
54722
|
const dataViewArr = [];
|
|
54700
54723
|
for (let i = 0; i < specData.length; i++) {
|
|
54701
54724
|
const curSpecData = specData[i];
|
|
54702
|
-
dataViewArr.push(dataToDataView(curSpecData, this._dataSet, dataViewArr
|
|
54725
|
+
dataViewArr.push(dataToDataView(curSpecData, this._dataSet, dataViewArr, {
|
|
54726
|
+
onError: this._option.onError
|
|
54727
|
+
}));
|
|
54703
54728
|
}
|
|
54704
54729
|
this._spec.data = dataViewArr;
|
|
54705
54730
|
}
|
|
54706
54731
|
_initChart(spec) {
|
|
54707
54732
|
if (!this._compiler) {
|
|
54708
|
-
|
|
54733
|
+
this._option.onError('compiler is not initialized');
|
|
54709
54734
|
return;
|
|
54710
54735
|
}
|
|
54711
54736
|
this._initData();
|
|
@@ -54723,10 +54748,11 @@
|
|
|
54723
54748
|
viewBox: this._viewBox,
|
|
54724
54749
|
animation: this._option.animation,
|
|
54725
54750
|
getTheme: () => this._currentTheme,
|
|
54726
|
-
layout: this._option.layout
|
|
54751
|
+
layout: this._option.layout,
|
|
54752
|
+
onError: this._onError
|
|
54727
54753
|
});
|
|
54728
54754
|
if (!chart) {
|
|
54729
|
-
|
|
54755
|
+
this._option.onError('init chart fail');
|
|
54730
54756
|
return;
|
|
54731
54757
|
}
|
|
54732
54758
|
this._chart = chart;
|
|
@@ -54739,6 +54765,17 @@
|
|
|
54739
54765
|
this._dataSet = null;
|
|
54740
54766
|
}
|
|
54741
54767
|
}
|
|
54768
|
+
_bindVGrammarViewEvent() {
|
|
54769
|
+
if (!this._compiler || this._compiler.isReleased) {
|
|
54770
|
+
return;
|
|
54771
|
+
}
|
|
54772
|
+
this._compiler.getVGrammarView().addEventListener(HOOK_EVENT.ALL_ANIMATION_END, () => {
|
|
54773
|
+
this._event.emit(ChartEvent.animationFinished, {});
|
|
54774
|
+
});
|
|
54775
|
+
this._compiler.getVGrammarView().addEventListener(HOOK_EVENT.AFTER_VRENDER_NEXT_RENDER, () => {
|
|
54776
|
+
this._event.emit(ChartEvent.renderFinished, {});
|
|
54777
|
+
});
|
|
54778
|
+
}
|
|
54742
54779
|
_bindResizeEvent() {
|
|
54743
54780
|
if (this._autoSize) {
|
|
54744
54781
|
if (this._container) {
|
|
@@ -54790,7 +54827,21 @@
|
|
|
54790
54827
|
if (!isValid(result)) {
|
|
54791
54828
|
return this;
|
|
54792
54829
|
}
|
|
54793
|
-
|
|
54830
|
+
this._reCompile(result);
|
|
54831
|
+
await this.renderAsync(morphConfig);
|
|
54832
|
+
return this;
|
|
54833
|
+
}
|
|
54834
|
+
updateCustomConfigAndRerenderSync(modifyConfig, morphConfig) {
|
|
54835
|
+
const result = modifyConfig();
|
|
54836
|
+
if (!isValid(result)) {
|
|
54837
|
+
return this;
|
|
54838
|
+
}
|
|
54839
|
+
this._reCompile(result);
|
|
54840
|
+
this.renderSync(morphConfig);
|
|
54841
|
+
return this;
|
|
54842
|
+
}
|
|
54843
|
+
_reCompile(updateResult) {
|
|
54844
|
+
if (updateResult.reMake) {
|
|
54794
54845
|
this._releaseData();
|
|
54795
54846
|
this._initDataSet();
|
|
54796
54847
|
this._chart.release();
|
|
@@ -54798,13 +54849,11 @@
|
|
|
54798
54849
|
this._compiler?.releaseGrammar();
|
|
54799
54850
|
}
|
|
54800
54851
|
else {
|
|
54801
|
-
if (
|
|
54852
|
+
if (updateResult.reCompile) {
|
|
54802
54853
|
this.getComponents().forEach(c => c.clear());
|
|
54803
54854
|
this._compiler?.compile({ chart: this._chart, vChart: this }, {});
|
|
54804
54855
|
}
|
|
54805
54856
|
}
|
|
54806
|
-
await this.renderAsync(morphConfig);
|
|
54807
|
-
return this;
|
|
54808
54857
|
}
|
|
54809
54858
|
renderSync(morphConfig) {
|
|
54810
54859
|
if (!this._chart) {
|
|
@@ -54964,6 +55013,25 @@
|
|
|
54964
55013
|
}, morphConfig);
|
|
54965
55014
|
return this;
|
|
54966
55015
|
}
|
|
55016
|
+
updateSpecSync(spec, forceMerge = false, morphConfig) {
|
|
55017
|
+
if (!spec) {
|
|
55018
|
+
return this;
|
|
55019
|
+
}
|
|
55020
|
+
if (isString(spec)) {
|
|
55021
|
+
spec = JSON.parse(spec);
|
|
55022
|
+
}
|
|
55023
|
+
if (forceMerge) {
|
|
55024
|
+
spec = merge$2({}, this._spec, spec);
|
|
55025
|
+
}
|
|
55026
|
+
this.updateCustomConfigAndRerenderSync(() => {
|
|
55027
|
+
spec = specTransform(spec);
|
|
55028
|
+
this._spec = spec;
|
|
55029
|
+
this._updateCurrentTheme();
|
|
55030
|
+
this._compiler?.getVGrammarView()?.updateLayoutTag();
|
|
55031
|
+
return this._chart.updateSpec(spec, morphConfig);
|
|
55032
|
+
}, morphConfig);
|
|
55033
|
+
return this;
|
|
55034
|
+
}
|
|
54967
55035
|
async resize(width, height) {
|
|
54968
55036
|
if (!this._chart || !this._compiler) {
|
|
54969
55037
|
return this;
|
|
@@ -55041,6 +55109,18 @@
|
|
|
55041
55109
|
});
|
|
55042
55110
|
return this;
|
|
55043
55111
|
}
|
|
55112
|
+
setCurrentThemeSync(name) {
|
|
55113
|
+
if (!ThemeManager.themeExist(name)) {
|
|
55114
|
+
return this;
|
|
55115
|
+
}
|
|
55116
|
+
this.updateCustomConfigAndRerenderSync(() => {
|
|
55117
|
+
this._currentThemeName = name;
|
|
55118
|
+
this._updateCurrentTheme();
|
|
55119
|
+
this._chart?.setCurrentTheme(this._currentTheme, true);
|
|
55120
|
+
return { change: true, reMake: false };
|
|
55121
|
+
});
|
|
55122
|
+
return this;
|
|
55123
|
+
}
|
|
55044
55124
|
_getTooltipComponent() {
|
|
55045
55125
|
const tooltip = this._chart?.getAllComponents().find(c => c.type === ComponentTypeEnum.tooltip);
|
|
55046
55126
|
return tooltip;
|
|
@@ -55122,15 +55202,17 @@
|
|
|
55122
55202
|
if (this._chart && stage) {
|
|
55123
55203
|
stage.render();
|
|
55124
55204
|
const canvas = this._chart.getCanvas();
|
|
55125
|
-
const url = await getCanvasDataURL(canvas
|
|
55205
|
+
const url = await getCanvasDataURL(canvas, {
|
|
55206
|
+
onError: this._onError
|
|
55207
|
+
});
|
|
55126
55208
|
return url;
|
|
55127
55209
|
}
|
|
55128
|
-
|
|
55210
|
+
this._option.onError(new ReferenceError(`render is not defined`));
|
|
55129
55211
|
return null;
|
|
55130
55212
|
}
|
|
55131
55213
|
async exportImg(name) {
|
|
55132
55214
|
if (!isTrueBrowser(this._option.mode)) {
|
|
55133
|
-
|
|
55215
|
+
this._option.onError(new TypeError(`non-browser environment can not export img`));
|
|
55134
55216
|
return;
|
|
55135
55217
|
}
|
|
55136
55218
|
const dataURL = await this.getDataURL();
|
|
@@ -55138,12 +55220,12 @@
|
|
|
55138
55220
|
URLToImage(name, dataURL);
|
|
55139
55221
|
}
|
|
55140
55222
|
else {
|
|
55141
|
-
|
|
55223
|
+
this._option.onError(new ReferenceError(`render is not defined`));
|
|
55142
55224
|
}
|
|
55143
55225
|
}
|
|
55144
55226
|
getImageBuffer() {
|
|
55145
55227
|
if (this._option.mode !== 'node') {
|
|
55146
|
-
|
|
55228
|
+
this._option.onError(new TypeError('getImageBuffer() now only support node environment.'));
|
|
55147
55229
|
return;
|
|
55148
55230
|
}
|
|
55149
55231
|
const stage = this.getStage();
|
|
@@ -55152,7 +55234,7 @@
|
|
|
55152
55234
|
const buffer = stage.window.getImageBuffer();
|
|
55153
55235
|
return buffer;
|
|
55154
55236
|
}
|
|
55155
|
-
|
|
55237
|
+
this._option.onError(new ReferenceError(`render is not defined`));
|
|
55156
55238
|
return null;
|
|
55157
55239
|
}
|
|
55158
55240
|
setLayout(layout) {
|
|
@@ -56679,6 +56761,10 @@
|
|
|
56679
56761
|
_bottomCurrent = 0;
|
|
56680
56762
|
_chartLayoutRect;
|
|
56681
56763
|
_chartViewBox;
|
|
56764
|
+
_onError;
|
|
56765
|
+
constructor(_spec, ctx) {
|
|
56766
|
+
this._onError = ctx?.onError;
|
|
56767
|
+
}
|
|
56682
56768
|
layoutItems(_chart, items, chartLayoutRect, chartViewBox) {
|
|
56683
56769
|
this._chartLayoutRect = chartLayoutRect;
|
|
56684
56770
|
this._chartViewBox = chartViewBox;
|
|
@@ -56939,7 +57025,7 @@
|
|
|
56939
57025
|
filterRegionsWithID(regions, id) {
|
|
56940
57026
|
const target = regions.find(x => x.id === id);
|
|
56941
57027
|
if (!target) {
|
|
56942
|
-
|
|
57028
|
+
(this._onError ?? error$1)('can not find target region item, invalid id');
|
|
56943
57029
|
}
|
|
56944
57030
|
return target;
|
|
56945
57031
|
}
|
|
@@ -58033,7 +58119,7 @@
|
|
|
58033
58119
|
VChart.useMark([ComponentMark, GroupMark, ImageMark]);
|
|
58034
58120
|
Factory.registerRegion('region', Region);
|
|
58035
58121
|
Factory.registerLayout('base', Layout);
|
|
58036
|
-
const version = "1.
|
|
58122
|
+
const version = "1.2.0-beta.1";
|
|
58037
58123
|
Logger.getInstance(LoggerLevel.Error);
|
|
58038
58124
|
|
|
58039
58125
|
var SeriesMarkNameEnum;
|
|
@@ -58522,6 +58608,9 @@
|
|
|
58522
58608
|
this.transformSpec(s);
|
|
58523
58609
|
this._spec = s;
|
|
58524
58610
|
}
|
|
58611
|
+
getOption() {
|
|
58612
|
+
return this._option;
|
|
58613
|
+
}
|
|
58525
58614
|
_theme;
|
|
58526
58615
|
_regions = [];
|
|
58527
58616
|
_series = [];
|
|
@@ -58589,7 +58678,8 @@
|
|
|
58589
58678
|
getChartLayoutRect: () => this._layoutRect,
|
|
58590
58679
|
getChartViewRect: () => this._viewRect,
|
|
58591
58680
|
getChart: () => this,
|
|
58592
|
-
globalScale: this._globalScale
|
|
58681
|
+
globalScale: this._globalScale,
|
|
58682
|
+
onError: this._option.onError
|
|
58593
58683
|
};
|
|
58594
58684
|
this._stack = new Stack(this);
|
|
58595
58685
|
this._spec = spec;
|
|
@@ -58658,7 +58748,9 @@
|
|
|
58658
58748
|
spec.data = this.getSeriesData(spec.dataId, spec.dataIndex);
|
|
58659
58749
|
}
|
|
58660
58750
|
else {
|
|
58661
|
-
spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data
|
|
58751
|
+
spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data, {
|
|
58752
|
+
onError: this._option.onError
|
|
58753
|
+
});
|
|
58662
58754
|
}
|
|
58663
58755
|
if (this._option.animation === false) {
|
|
58664
58756
|
spec.animation = false;
|
|
@@ -58777,7 +58869,9 @@
|
|
|
58777
58869
|
if (this._spec.zField || (this._spec.series && this._spec.series.some((s) => s.zField))) {
|
|
58778
58870
|
use3dLayout = true;
|
|
58779
58871
|
}
|
|
58780
|
-
const layout = new (Factory.getLayout(this._spec.layout?.type ?? (use3dLayout ? 'layout3d' : 'base')))(this._spec.layout
|
|
58872
|
+
const layout = new (Factory.getLayout(this._spec.layout?.type ?? (use3dLayout ? 'layout3d' : 'base')))(this._spec.layout, {
|
|
58873
|
+
onError: this._option.onError
|
|
58874
|
+
});
|
|
58781
58875
|
this._layoutFunc = layout.layoutItems.bind(layout);
|
|
58782
58876
|
}
|
|
58783
58877
|
}
|
|
@@ -58995,7 +59089,8 @@
|
|
|
58995
59089
|
}
|
|
58996
59090
|
getSeriesData(id, index) {
|
|
58997
59091
|
if (!this._spec.data) {
|
|
58998
|
-
|
|
59092
|
+
this._option.onError('no data in spec!');
|
|
59093
|
+
return null;
|
|
58999
59094
|
}
|
|
59000
59095
|
if (typeof id === 'string') {
|
|
59001
59096
|
const metchData = this._spec.data.filter((data) => {
|
|
@@ -59004,13 +59099,15 @@
|
|
|
59004
59099
|
if (metchData[0]) {
|
|
59005
59100
|
return metchData[0];
|
|
59006
59101
|
}
|
|
59007
|
-
|
|
59102
|
+
this._option.onError(`no data matches dataId ${id}!`);
|
|
59103
|
+
return null;
|
|
59008
59104
|
}
|
|
59009
59105
|
if (typeof index === 'number') {
|
|
59010
59106
|
if (this._spec.data[index]) {
|
|
59011
59107
|
return this._spec.data[index];
|
|
59012
59108
|
}
|
|
59013
|
-
|
|
59109
|
+
this._option.onError(`no data matches dataIndex ${index}!`);
|
|
59110
|
+
return null;
|
|
59014
59111
|
}
|
|
59015
59112
|
return this._spec.data[0];
|
|
59016
59113
|
}
|
|
@@ -61068,7 +61165,7 @@
|
|
|
61068
61165
|
if (isFunction(dataKey)) {
|
|
61069
61166
|
return dataKey(datum, index);
|
|
61070
61167
|
}
|
|
61071
|
-
|
|
61168
|
+
this._option.onError(`invalid dataKey: ${dataKey}`);
|
|
61072
61169
|
}
|
|
61073
61170
|
_addDataIndexAndKey() {
|
|
61074
61171
|
if (this._rawData?.dataSet) {
|
|
@@ -65015,13 +65112,16 @@
|
|
|
65015
65112
|
longitudeToData(lon) {
|
|
65016
65113
|
}
|
|
65017
65114
|
dataToPositionX(data) {
|
|
65018
|
-
|
|
65115
|
+
this._option.onError('Method not implemented.');
|
|
65116
|
+
return 0;
|
|
65019
65117
|
}
|
|
65020
65118
|
dataToPositionY(data) {
|
|
65021
|
-
|
|
65119
|
+
this._option.onError('Method not implemented.');
|
|
65120
|
+
return 0;
|
|
65022
65121
|
}
|
|
65023
65122
|
dataToPositionZ(data) {
|
|
65024
|
-
|
|
65123
|
+
this._option.onError('Method not implemented.');
|
|
65124
|
+
return 0;
|
|
65025
65125
|
}
|
|
65026
65126
|
release() {
|
|
65027
65127
|
super.release();
|
|
@@ -65136,10 +65236,10 @@
|
|
|
65136
65236
|
this._valueField = this._spec.valueField;
|
|
65137
65237
|
this._spec.nameProperty && (this._nameProperty = this._spec.nameProperty);
|
|
65138
65238
|
if (!this.map) {
|
|
65139
|
-
|
|
65239
|
+
this._option.onError(`map type '${this.map}' is not specified !`);
|
|
65140
65240
|
}
|
|
65141
65241
|
if (!geoSourceMap.get(this.map)) {
|
|
65142
|
-
|
|
65242
|
+
this._option.onError(`'${this.map}' data is not registered !`);
|
|
65143
65243
|
}
|
|
65144
65244
|
}
|
|
65145
65245
|
initData() {
|
|
@@ -65149,7 +65249,7 @@
|
|
|
65149
65249
|
registerDataSetInstanceTransform(this._dataSet, 'lookup', lookup);
|
|
65150
65250
|
const features = geoSourceMap.get(this.map);
|
|
65151
65251
|
if (!features) {
|
|
65152
|
-
|
|
65252
|
+
this._option.onError('no valid map data found!');
|
|
65153
65253
|
}
|
|
65154
65254
|
const mapData = new DataView(this._dataSet);
|
|
65155
65255
|
mapData
|
|
@@ -65355,10 +65455,12 @@
|
|
|
65355
65455
|
return '';
|
|
65356
65456
|
}
|
|
65357
65457
|
dataToPositionX(data) {
|
|
65358
|
-
|
|
65458
|
+
this._option.onError('Method not implemented.');
|
|
65459
|
+
return 0;
|
|
65359
65460
|
}
|
|
65360
65461
|
dataToPositionY(data) {
|
|
65361
|
-
|
|
65462
|
+
this._option.onError('Method not implemented.');
|
|
65463
|
+
return 0;
|
|
65362
65464
|
}
|
|
65363
65465
|
viewDataUpdate(d) {
|
|
65364
65466
|
super.viewDataUpdate(d);
|
|
@@ -66905,10 +67007,12 @@
|
|
|
66905
67007
|
}
|
|
66906
67008
|
if (isArray$3(spec)) {
|
|
66907
67009
|
if (isNil(field)) {
|
|
66908
|
-
|
|
67010
|
+
this._option.onError(`${key}Field is required.`);
|
|
67011
|
+
return spec;
|
|
66909
67012
|
}
|
|
66910
67013
|
if (spec.length > 2) {
|
|
66911
|
-
|
|
67014
|
+
this._option.onError(`${key} length is invalid, specify up to 2 ${key}s.`);
|
|
67015
|
+
return spec;
|
|
66912
67016
|
}
|
|
66913
67017
|
const scaleName = `${PREFIX}_series_scatter_${this.id}_scale_${key}`;
|
|
66914
67018
|
this._option.globalScale.registerModelScale({
|
|
@@ -66929,7 +67033,8 @@
|
|
|
66929
67033
|
}
|
|
66930
67034
|
if (isObject$f(spec)) {
|
|
66931
67035
|
if (isNil(field)) {
|
|
66932
|
-
|
|
67036
|
+
this._option.onError(`${key}Field is required.`);
|
|
67037
|
+
return spec;
|
|
66933
67038
|
}
|
|
66934
67039
|
const scaleName = `${PREFIX}_series_scatter_${this.id}_scale_${key}`;
|
|
66935
67040
|
const visualSpec = {
|
|
@@ -66950,7 +67055,8 @@
|
|
|
66950
67055
|
field
|
|
66951
67056
|
};
|
|
66952
67057
|
}
|
|
66953
|
-
|
|
67058
|
+
this._option.onError(`${key} attribute is invalid.`);
|
|
67059
|
+
return spec;
|
|
66954
67060
|
}
|
|
66955
67061
|
getSizeAttribute(field, sizeSpec) {
|
|
66956
67062
|
if (isNil(sizeSpec)) {
|
|
@@ -76989,9 +77095,13 @@
|
|
|
76989
77095
|
}
|
|
76990
77096
|
}
|
|
76991
77097
|
else {
|
|
76992
|
-
spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data
|
|
77098
|
+
spec.data = dataToDataView(spec.data, this._dataSet, this._spec.data, {
|
|
77099
|
+
onError: this._option.onError
|
|
77100
|
+
});
|
|
76993
77101
|
if (spec.type === SeriesTypeEnum.link) {
|
|
76994
|
-
spec.dataDot = dataToDataView(this._spec.series[spec.dotSeriesIndex].data, this._dataSet, this._spec.data
|
|
77102
|
+
spec.dataDot = dataToDataView(this._spec.series[spec.dotSeriesIndex].data, this._dataSet, this._spec.data, {
|
|
77103
|
+
onError: this._option.onError
|
|
77104
|
+
});
|
|
76995
77105
|
}
|
|
76996
77106
|
}
|
|
76997
77107
|
if (spec.type === SeriesTypeEnum.link) {
|
|
@@ -80462,7 +80572,8 @@
|
|
|
80462
80572
|
inverse
|
|
80463
80573
|
}, options);
|
|
80464
80574
|
}
|
|
80465
|
-
|
|
80575
|
+
options.onError(`Component ${componentName} not found`);
|
|
80576
|
+
return null;
|
|
80466
80577
|
}
|
|
80467
80578
|
static createComponent(spec, options) {
|
|
80468
80579
|
if (!this.type.startsWith(CartesianAxis.type)) {
|
|
@@ -81470,7 +81581,8 @@
|
|
|
81470
81581
|
if (C) {
|
|
81471
81582
|
return new C(spec, options);
|
|
81472
81583
|
}
|
|
81473
|
-
|
|
81584
|
+
options.onError(`Component ${componentName} not found`);
|
|
81585
|
+
return null;
|
|
81474
81586
|
}
|
|
81475
81587
|
static createComponent(spec, options) {
|
|
81476
81588
|
if (!this.type.startsWith(PolarAxis.type)) {
|
|
@@ -82966,9 +83078,6 @@
|
|
|
82966
83078
|
projection;
|
|
82967
83079
|
constructor(projectionSpec) {
|
|
82968
83080
|
this.projection = projection(projectionSpec.type)();
|
|
82969
|
-
if (this.projection === null) {
|
|
82970
|
-
throw Error('unsupported projection type!');
|
|
82971
|
-
}
|
|
82972
83081
|
}
|
|
82973
83082
|
fit(start, size, features) {
|
|
82974
83083
|
const fitData = { type: 'FeatureCollection', features };
|
|
@@ -83119,6 +83228,10 @@
|
|
|
83119
83228
|
}
|
|
83120
83229
|
initProjection() {
|
|
83121
83230
|
this._projection = new Projection(this._projectionSpec);
|
|
83231
|
+
if (this._projection.projection === null) {
|
|
83232
|
+
this._option.onError('unsupported projection type!');
|
|
83233
|
+
return;
|
|
83234
|
+
}
|
|
83122
83235
|
}
|
|
83123
83236
|
coordinateHelper() {
|
|
83124
83237
|
const helper = {
|
|
@@ -85186,7 +85299,8 @@
|
|
|
85186
85299
|
}
|
|
85187
85300
|
}
|
|
85188
85301
|
}
|
|
85189
|
-
|
|
85302
|
+
this._option.onError('need at least one series');
|
|
85303
|
+
return null;
|
|
85190
85304
|
}
|
|
85191
85305
|
clear() {
|
|
85192
85306
|
if (this._markerComponent) {
|
|
@@ -88227,6 +88341,12 @@
|
|
|
88227
88341
|
});
|
|
88228
88342
|
});
|
|
88229
88343
|
}
|
|
88344
|
+
updateSpec(spec) {
|
|
88345
|
+
const result = super.updateSpec(spec);
|
|
88346
|
+
result.reRender = true;
|
|
88347
|
+
result.reMake = true;
|
|
88348
|
+
return result;
|
|
88349
|
+
}
|
|
88230
88350
|
onRender(ctx) {
|
|
88231
88351
|
}
|
|
88232
88352
|
changeRegions(regions) {
|
|
@@ -88253,7 +88373,8 @@
|
|
|
88253
88373
|
_rowElements;
|
|
88254
88374
|
_gridInfo;
|
|
88255
88375
|
_elementMap = new Map();
|
|
88256
|
-
|
|
88376
|
+
_onError;
|
|
88377
|
+
constructor(gridInfo, ctx) {
|
|
88257
88378
|
this.standardizationSpec(gridInfo);
|
|
88258
88379
|
this._gridInfo = gridInfo;
|
|
88259
88380
|
this._col = gridInfo.col;
|
|
@@ -88262,6 +88383,7 @@
|
|
|
88262
88383
|
this._rowSize = new Array(this._row).fill(null);
|
|
88263
88384
|
this._colElements = new Array(this._col).fill([]);
|
|
88264
88385
|
this._rowElements = new Array(this._row).fill([]);
|
|
88386
|
+
this._onError = ctx?.onError;
|
|
88265
88387
|
this.initUserSetting();
|
|
88266
88388
|
}
|
|
88267
88389
|
standardizationSpec(gridInfo) {
|