@visactor/vchart 1.2.2-alpha.0 → 1.2.2-beta.2
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/es5/index.js +1 -1
- package/build/index.js +128 -90
- package/build/index.min.js +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/cjs/compile/compiler.d.ts +2 -1
- package/cjs/compile/compiler.js +4 -0
- package/cjs/compile/compiler.js.map +1 -1
- package/cjs/component/title/title.js +1 -1
- package/cjs/component/title/title.js.map +1 -1
- package/cjs/component/tooltip/handler/utils/get-spec.js +71 -53
- package/cjs/component/tooltip/handler/utils/get-spec.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 +1 -0
- package/cjs/core/vchart.js +13 -11
- package/cjs/core/vchart.js.map +1 -1
- package/cjs/series/base/tooltip-helper.js +1 -0
- package/cjs/series/base/tooltip-helper.js.map +1 -1
- package/cjs/typings/tooltip/line.d.ts +0 -1
- package/cjs/typings/tooltip/line.js.map +1 -1
- package/cjs/typings/tooltip/shape.d.ts +1 -0
- package/cjs/typings/tooltip/shape.js.map +1 -1
- package/esm/compile/compiler.d.ts +2 -1
- package/esm/compile/compiler.js +4 -0
- package/esm/compile/compiler.js.map +1 -1
- package/esm/component/title/title.js +1 -1
- package/esm/component/title/title.js.map +1 -1
- package/esm/component/tooltip/handler/utils/get-spec.js +68 -50
- package/esm/component/tooltip/handler/utils/get-spec.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 +1 -0
- package/esm/core/vchart.js +13 -11
- package/esm/core/vchart.js.map +1 -1
- package/esm/series/base/tooltip-helper.js +1 -0
- package/esm/series/base/tooltip-helper.js.map +1 -1
- package/esm/typings/tooltip/line.d.ts +0 -1
- package/esm/typings/tooltip/line.js.map +1 -1
- package/esm/typings/tooltip/shape.d.ts +1 -0
- package/esm/typings/tooltip/shape.js.map +1 -1
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -54684,6 +54684,9 @@
|
|
|
54684
54684
|
this._view.resize(width, height);
|
|
54685
54685
|
return this.reRenderAsync({ morph: false });
|
|
54686
54686
|
}
|
|
54687
|
+
setBackground(color) {
|
|
54688
|
+
this._view?.background(color);
|
|
54689
|
+
}
|
|
54687
54690
|
reRenderAsync(morphConfig) {
|
|
54688
54691
|
if (this.isInited) {
|
|
54689
54692
|
if (this._rafId) {
|
|
@@ -54979,7 +54982,6 @@
|
|
|
54979
54982
|
this._currentThemeName = ThemeManager.getCurrentThemeName();
|
|
54980
54983
|
this._setSpec(spec);
|
|
54981
54984
|
this._updateCurrentTheme();
|
|
54982
|
-
const specBackground = typeof spec.background === 'string' ? spec.background : null;
|
|
54983
54985
|
this._compiler = new Compiler({
|
|
54984
54986
|
dom: this._container ?? 'none',
|
|
54985
54987
|
canvas: renderCanvas
|
|
@@ -54988,7 +54990,7 @@
|
|
|
54988
54990
|
stage,
|
|
54989
54991
|
pluginList: poptip !== false ? ['poptipForText'] : [],
|
|
54990
54992
|
...restOptions,
|
|
54991
|
-
background:
|
|
54993
|
+
background: this._getBackground(),
|
|
54992
54994
|
onError: this._onError
|
|
54993
54995
|
});
|
|
54994
54996
|
this._eventDispatcher = new EventDispatcher(this, this._compiler);
|
|
@@ -55150,10 +55152,8 @@
|
|
|
55150
55152
|
this._compiler?.releaseGrammar();
|
|
55151
55153
|
}
|
|
55152
55154
|
else {
|
|
55153
|
-
|
|
55154
|
-
|
|
55155
|
-
this._compiler?.compile({ chart: this._chart, vChart: this }, {});
|
|
55156
|
-
}
|
|
55155
|
+
this.getComponents().forEach(c => c.clear());
|
|
55156
|
+
this._compiler?.compile({ chart: this._chart, vChart: this }, {});
|
|
55157
55157
|
}
|
|
55158
55158
|
}
|
|
55159
55159
|
renderSync(morphConfig) {
|
|
@@ -55392,6 +55392,11 @@
|
|
|
55392
55392
|
this._currentTheme = merge$2({}, ThemeManager.getTheme(this._currentThemeName), this._spec?.theme ?? {});
|
|
55393
55393
|
}
|
|
55394
55394
|
setPoptipTheme(merge$2({}, this._currentTheme.component?.poptip));
|
|
55395
|
+
this._compiler?.setBackground(this._getBackground());
|
|
55396
|
+
}
|
|
55397
|
+
_getBackground() {
|
|
55398
|
+
const specBackground = typeof this._spec.background === 'string' ? this._spec.background : null;
|
|
55399
|
+
return specBackground || this._currentTheme.background || this._option.background;
|
|
55395
55400
|
}
|
|
55396
55401
|
getCurrentTheme() {
|
|
55397
55402
|
return this._currentTheme;
|
|
@@ -58413,7 +58418,7 @@
|
|
|
58413
58418
|
VChart.useMark([ComponentMark, GroupMark, ImageMark]);
|
|
58414
58419
|
Factory.registerRegion('region', Region);
|
|
58415
58420
|
Factory.registerLayout('base', Layout);
|
|
58416
|
-
const version = "1.2.2-
|
|
58421
|
+
const version = "1.2.2-beta.2";
|
|
58417
58422
|
Logger.getInstance(LoggerLevel.Error);
|
|
58418
58423
|
|
|
58419
58424
|
var SeriesMarkNameEnum;
|
|
@@ -61013,6 +61018,7 @@
|
|
|
61013
61018
|
},
|
|
61014
61019
|
content: [
|
|
61015
61020
|
{
|
|
61021
|
+
seriesId: this.series.id,
|
|
61016
61022
|
key: this.contentKeyCallback,
|
|
61017
61023
|
value: this.contentValueCallback,
|
|
61018
61024
|
hasShape: true,
|
|
@@ -83771,7 +83777,7 @@
|
|
|
83771
83777
|
};
|
|
83772
83778
|
}
|
|
83773
83779
|
_getTitleAttrs() {
|
|
83774
|
-
const realWidth = this._spec.width ?? this.getLayoutRect().width;
|
|
83780
|
+
const realWidth = Math.max(0, this._spec.width ?? this.getLayoutRect().width);
|
|
83775
83781
|
return {
|
|
83776
83782
|
text: this._spec.text ?? '',
|
|
83777
83783
|
subtext: this._spec.subtext ?? '',
|
|
@@ -86712,8 +86718,6 @@
|
|
|
86712
86718
|
...globalSpec,
|
|
86713
86719
|
activeType
|
|
86714
86720
|
};
|
|
86715
|
-
let defaultPattern = {};
|
|
86716
|
-
let userPattern = {};
|
|
86717
86721
|
if (activeType === 'mark' && series) {
|
|
86718
86722
|
const seriesSpec = (series.tooltipHelper?.spec ?? {});
|
|
86719
86723
|
if (isValid(seriesSpec.visible) || isValid(seriesSpec.activeType)) {
|
|
@@ -86729,11 +86733,9 @@
|
|
|
86729
86733
|
if (finalSpec.handler?.showTooltip) {
|
|
86730
86734
|
return finalSpec;
|
|
86731
86735
|
}
|
|
86732
|
-
defaultPattern = makeDefaultPattern(series, 'mark') ?? {};
|
|
86733
|
-
userPattern = merge$2({}, cloneDeep(globalSpec.mark), cloneDeep(seriesSpec.mark));
|
|
86734
86736
|
}
|
|
86735
86737
|
else if (activeType === 'dimension' && dimensionInfo?.length) {
|
|
86736
|
-
const seriesList = dimensionInfo
|
|
86738
|
+
const seriesList = getSeriesListFromDimensionInfo(dimensionInfo);
|
|
86737
86739
|
if (seriesList.every(series => !getTooltipActualActiveType(series.tooltipHelper?.spec).includes('dimension'))) {
|
|
86738
86740
|
finalSpec.visible = false;
|
|
86739
86741
|
}
|
|
@@ -86747,6 +86749,83 @@
|
|
|
86747
86749
|
if (finalSpec.handler?.showTooltip) {
|
|
86748
86750
|
return finalSpec;
|
|
86749
86751
|
}
|
|
86752
|
+
}
|
|
86753
|
+
const defaultPattern = getDefaultTooltipPattern(activeType, series, dimensionInfo);
|
|
86754
|
+
const seriesPattern = getSeriesTooltipPattern(activeType, series, dimensionInfo);
|
|
86755
|
+
const userPattern = merge$2({}, cloneDeep(globalSpec[activeType]), seriesPattern);
|
|
86756
|
+
const defaultPatternTitle = defaultPattern.title;
|
|
86757
|
+
const titleShape = getShapePattern(undefined, userPattern, undefined, defaultPatternTitle);
|
|
86758
|
+
if (isValid(userPattern.title)) {
|
|
86759
|
+
if (!isFunction(userPattern.title)) {
|
|
86760
|
+
userPattern.title = {
|
|
86761
|
+
...defaultPattern.title,
|
|
86762
|
+
...titleShape,
|
|
86763
|
+
...userPattern.title
|
|
86764
|
+
};
|
|
86765
|
+
}
|
|
86766
|
+
else {
|
|
86767
|
+
const userPatternTitle = userPattern.title;
|
|
86768
|
+
userPattern.title = (data, params) => {
|
|
86769
|
+
const userResult = userPatternTitle(data, params) ?? {};
|
|
86770
|
+
return {
|
|
86771
|
+
...titleShape,
|
|
86772
|
+
...userResult
|
|
86773
|
+
};
|
|
86774
|
+
};
|
|
86775
|
+
}
|
|
86776
|
+
}
|
|
86777
|
+
else {
|
|
86778
|
+
userPattern.title = {
|
|
86779
|
+
...defaultPattern.title,
|
|
86780
|
+
...titleShape
|
|
86781
|
+
};
|
|
86782
|
+
}
|
|
86783
|
+
const defaultPatternContent = array(defaultPattern.content);
|
|
86784
|
+
if (isValid(userPattern.content)) {
|
|
86785
|
+
const shapePatternMap = getShapePatternMapOfEachSeries(defaultPatternContent);
|
|
86786
|
+
if (!isFunction(userPattern.content)) {
|
|
86787
|
+
const newPatternContent = [];
|
|
86788
|
+
array(userPattern.content).forEach(userLine => {
|
|
86789
|
+
newPatternContent.push({
|
|
86790
|
+
...getShapePattern(userLine, userPattern, shapePatternMap),
|
|
86791
|
+
...userLine
|
|
86792
|
+
});
|
|
86793
|
+
});
|
|
86794
|
+
userPattern.content = newPatternContent;
|
|
86795
|
+
}
|
|
86796
|
+
else {
|
|
86797
|
+
const userPatternContent = userPattern.content;
|
|
86798
|
+
userPattern.content = (data, params) => {
|
|
86799
|
+
const newPatternContent = [];
|
|
86800
|
+
array(userPatternContent(data, params) ?? []).forEach(userLine => {
|
|
86801
|
+
newPatternContent.push({
|
|
86802
|
+
...getShapePattern(userLine, userPattern, shapePatternMap),
|
|
86803
|
+
...userLine
|
|
86804
|
+
});
|
|
86805
|
+
});
|
|
86806
|
+
return newPatternContent;
|
|
86807
|
+
};
|
|
86808
|
+
}
|
|
86809
|
+
}
|
|
86810
|
+
else {
|
|
86811
|
+
userPattern.content = defaultPatternContent.map(line => ({
|
|
86812
|
+
...line,
|
|
86813
|
+
...getShapePattern(undefined, userPattern, undefined, line)
|
|
86814
|
+
}));
|
|
86815
|
+
}
|
|
86816
|
+
finalSpec[activeType] = {
|
|
86817
|
+
...defaultPattern,
|
|
86818
|
+
...userPattern,
|
|
86819
|
+
activeType
|
|
86820
|
+
};
|
|
86821
|
+
return finalSpec;
|
|
86822
|
+
};
|
|
86823
|
+
const getDefaultTooltipPattern = (activeType, series, dimensionInfo) => {
|
|
86824
|
+
let defaultPattern = {};
|
|
86825
|
+
if (activeType === 'mark' && series) {
|
|
86826
|
+
defaultPattern = makeDefaultPattern(series, 'mark') ?? {};
|
|
86827
|
+
}
|
|
86828
|
+
else if (activeType === 'dimension' && dimensionInfo?.length) {
|
|
86750
86829
|
const patternList = [];
|
|
86751
86830
|
dimensionInfo[0].data.forEach(data => {
|
|
86752
86831
|
const { series } = data;
|
|
@@ -86774,16 +86853,23 @@
|
|
|
86774
86853
|
...patternList[0],
|
|
86775
86854
|
content: defaultPatternContent
|
|
86776
86855
|
};
|
|
86777
|
-
|
|
86856
|
+
}
|
|
86857
|
+
return defaultPattern;
|
|
86858
|
+
};
|
|
86859
|
+
const getSeriesTooltipPattern = (activeType, series, dimensionInfo) => {
|
|
86860
|
+
let seriesPattern = {};
|
|
86861
|
+
if (activeType === 'mark' && series) {
|
|
86862
|
+
const seriesSpec = (series.tooltipHelper?.spec ?? {});
|
|
86863
|
+
seriesPattern = seriesSpec.mark ? cloneDeep(seriesSpec.mark) : {};
|
|
86864
|
+
}
|
|
86865
|
+
else if (activeType === 'dimension' && dimensionInfo?.length) {
|
|
86866
|
+
const seriesList = getSeriesListFromDimensionInfo(dimensionInfo);
|
|
86778
86867
|
const seriesPatternList = seriesList
|
|
86779
86868
|
.filter(series => {
|
|
86780
86869
|
const spec = series.tooltipHelper?.spec;
|
|
86781
86870
|
return isValid(spec?.dimension) && getTooltipActualActiveType(spec).includes('dimension');
|
|
86782
86871
|
})
|
|
86783
|
-
.map(series =>
|
|
86784
|
-
const pattern = series.tooltipHelper.spec.dimension;
|
|
86785
|
-
return pattern;
|
|
86786
|
-
});
|
|
86872
|
+
.map(series => series.tooltipHelper.spec.dimension);
|
|
86787
86873
|
if (seriesPatternList.length) {
|
|
86788
86874
|
let seriesPatternContent = [];
|
|
86789
86875
|
if (seriesPatternList.every(({ content }) => isNil(content))) {
|
|
@@ -86802,86 +86888,38 @@
|
|
|
86802
86888
|
}
|
|
86803
86889
|
});
|
|
86804
86890
|
}
|
|
86805
|
-
|
|
86891
|
+
seriesPattern = {
|
|
86806
86892
|
...seriesPatternList[0],
|
|
86807
86893
|
content: seriesPatternContent
|
|
86808
86894
|
};
|
|
86809
86895
|
}
|
|
86810
|
-
userPattern = merge$2({}, cloneDeep(globalSpec.dimension), seriesDimensionPattern);
|
|
86811
86896
|
}
|
|
86812
|
-
|
|
86813
|
-
|
|
86814
|
-
|
|
86815
|
-
|
|
86816
|
-
|
|
86817
|
-
|
|
86818
|
-
|
|
86819
|
-
|
|
86820
|
-
|
|
86821
|
-
|
|
86822
|
-
|
|
86823
|
-
...userPattern.title
|
|
86824
|
-
};
|
|
86825
|
-
}
|
|
86826
|
-
else {
|
|
86827
|
-
const userPatternTitle = userPattern.title;
|
|
86828
|
-
userPattern.title = (data, params) => {
|
|
86829
|
-
const userResult = userPatternTitle(data, params) ?? {};
|
|
86830
|
-
return {
|
|
86831
|
-
...titleShape,
|
|
86832
|
-
...userResult
|
|
86833
|
-
};
|
|
86834
|
-
};
|
|
86897
|
+
return seriesPattern;
|
|
86898
|
+
};
|
|
86899
|
+
const getSeriesListFromDimensionInfo = (dimensionInfo) => {
|
|
86900
|
+
return dimensionInfo.reduce((list, cur) => list.concat(cur.data.map(data => data.series).filter(isValid)), []);
|
|
86901
|
+
};
|
|
86902
|
+
const getShapePatternMapOfEachSeries = (content) => {
|
|
86903
|
+
const shapePatternMap = {};
|
|
86904
|
+
content.forEach(line => {
|
|
86905
|
+
const key = line.seriesId ?? 0;
|
|
86906
|
+
if (!shapePatternMap[key]) {
|
|
86907
|
+
shapePatternMap[key] = line;
|
|
86835
86908
|
}
|
|
86836
|
-
}
|
|
86837
|
-
else {
|
|
86838
|
-
userPattern.title = {
|
|
86839
|
-
...defaultPattern.title,
|
|
86840
|
-
...titleShape
|
|
86841
|
-
};
|
|
86842
|
-
}
|
|
86843
|
-
const getContentShape = (defaultContentLine) => ({
|
|
86844
|
-
hasShape: userPattern.hasShape ?? defaultContentLine?.hasShape,
|
|
86845
|
-
shapeType: userPattern.shapeType ?? defaultContentLine?.shapeType,
|
|
86846
|
-
shapeColor: userPattern.shapeColor ?? defaultContentLine?.shapeColor
|
|
86847
86909
|
});
|
|
86848
|
-
|
|
86849
|
-
|
|
86850
|
-
|
|
86851
|
-
|
|
86852
|
-
|
|
86853
|
-
|
|
86854
|
-
|
|
86855
|
-
|
|
86856
|
-
|
|
86857
|
-
|
|
86858
|
-
}
|
|
86859
|
-
else {
|
|
86860
|
-
const userPatternContent = userPattern.content;
|
|
86861
|
-
userPattern.content = (data, params) => {
|
|
86862
|
-
const userResult = array(userPatternContent(data, params) ?? []);
|
|
86863
|
-
userResult.forEach((line, i) => {
|
|
86864
|
-
userResult[i] = {
|
|
86865
|
-
...getContentShape(defaultPatternContent[0]),
|
|
86866
|
-
...line
|
|
86867
|
-
};
|
|
86868
|
-
});
|
|
86869
|
-
return userResult;
|
|
86870
|
-
};
|
|
86910
|
+
return shapePatternMap;
|
|
86911
|
+
};
|
|
86912
|
+
const getShapePattern = (userLinePattern, userPattern, shapePatternMap, defaultShapePattern) => {
|
|
86913
|
+
const shapePatternFromMap = shapePatternMap?.[userLinePattern?.seriesId ?? 0] ?? shapePatternMap?.[0];
|
|
86914
|
+
const shapeKeys = ['hasShape', 'shapeType', 'shapeColor'];
|
|
86915
|
+
const shapePattern = {};
|
|
86916
|
+
shapeKeys.forEach(key => {
|
|
86917
|
+
const value = userLinePattern?.[key] ?? userPattern?.[key] ?? shapePatternFromMap?.[key] ?? defaultShapePattern?.[key];
|
|
86918
|
+
if (value !== undefined) {
|
|
86919
|
+
shapePattern[key] = value;
|
|
86871
86920
|
}
|
|
86872
|
-
}
|
|
86873
|
-
|
|
86874
|
-
userPattern.content = defaultPatternContent.map(line => ({
|
|
86875
|
-
...line,
|
|
86876
|
-
...getContentShape(line)
|
|
86877
|
-
}));
|
|
86878
|
-
}
|
|
86879
|
-
finalSpec[activeType] = {
|
|
86880
|
-
...defaultPattern,
|
|
86881
|
-
...userPattern,
|
|
86882
|
-
activeType
|
|
86883
|
-
};
|
|
86884
|
-
return finalSpec;
|
|
86921
|
+
});
|
|
86922
|
+
return shapePattern;
|
|
86885
86923
|
};
|
|
86886
86924
|
|
|
86887
86925
|
const getActualTooltipPositionValue = (position, event) => {
|