first commit

This commit is contained in:
2026-02-06 20:21:10 +08:00
commit f9d7f980bb
3994 changed files with 1146030 additions and 0 deletions
+83
View File
@@ -0,0 +1,83 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { calcZ2Range } from '../../util/graphic.js';
/**
* [CAVEAT]: the call order of `ThumbnailView['render']` and other
* `ChartView['render']/ComponentView['render']` is not guaranteed.
*/
var ThumbnailBridgeImpl = /** @class */function () {
function ThumbnailBridgeImpl(thumbnailModel) {
this._thumbnailModel = thumbnailModel;
}
ThumbnailBridgeImpl.prototype.reset = function (api) {
this._renderVersion = api.getMainProcessVersion();
};
ThumbnailBridgeImpl.prototype.renderContent = function (opt) {
var thumbnailView = opt.api.getViewOfComponentModel(this._thumbnailModel);
if (!thumbnailView) {
return;
}
opt.group.silent = true;
thumbnailView.renderContent({
group: opt.group,
targetTrans: opt.targetTrans,
z2Range: calcZ2Range(opt.group),
roamType: opt.roamType,
viewportRect: opt.viewportRect,
renderVersion: this._renderVersion
});
};
ThumbnailBridgeImpl.prototype.updateWindow = function (targetTrans, api) {
var thumbnailView = api.getViewOfComponentModel(this._thumbnailModel);
if (!thumbnailView) {
return;
}
thumbnailView.updateWindow({
targetTrans: targetTrans,
renderVersion: this._renderVersion
});
};
return ThumbnailBridgeImpl;
}();
export { ThumbnailBridgeImpl };
+135
View File
@@ -0,0 +1,135 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { __extends } from "tslib";
import ComponentModel from '../../model/Component.js';
import { error } from '../../util/log.js';
import tokens from '../../visual/tokens.js';
import { injectThumbnailBridge } from '../helper/thumbnailBridge.js';
import { ThumbnailBridgeImpl } from './ThumbnailBridgeImpl.js';
var ThumbnailModel = /** @class */function (_super) {
__extends(ThumbnailModel, _super);
function ThumbnailModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = ThumbnailModel.type;
_this.preventAutoZ = true;
return _this;
}
ThumbnailModel.prototype.optionUpdated = function (newCptOption, isInit) {
this._updateBridge();
};
ThumbnailModel.prototype._updateBridge = function () {
var bridge = this._birdge = this._birdge || new ThumbnailBridgeImpl(this);
// Clear all, in case of option changed.
this._target = null;
this.ecModel.eachSeries(function (series) {
injectThumbnailBridge(series, null);
});
if (this.shouldShow()) {
var target = this.getTarget();
// If a component is targeted by more than one thumbnails, simply only the last one works.
injectThumbnailBridge(target.baseMapProvider, bridge);
}
};
ThumbnailModel.prototype.shouldShow = function () {
return this.getShallow('show', true);
};
ThumbnailModel.prototype.getBridge = function () {
return this._birdge;
};
ThumbnailModel.prototype.getTarget = function () {
if (this._target) {
return this._target;
}
// Find by `seriesId`/`seriesIndex`.
var series = this.getReferringComponents('series', {
useDefault: false,
enableAll: false,
enableNone: false
}).models[0];
if (series) {
if (series.subType !== 'graph') {
series = null;
if (process.env.NODE_ENV !== 'production') {
error("series." + series.subType + " is not supported in thumbnail.", true);
}
}
} else {
// If no xxxId and xxxIndex specified, find the first series.graph. If other components,
// such as geo, is supported in future, the default stretagy may be extended.
series = this.ecModel.queryComponents({
mainType: 'series',
subType: 'graph'
})[0];
}
this._target = {
baseMapProvider: series
};
return this._target;
};
ThumbnailModel.type = 'thumbnail';
ThumbnailModel.layoutMode = 'box';
// All the supported components should be added here.
ThumbnailModel.dependencies = ['series', 'geo'];
ThumbnailModel.defaultOption = {
show: true,
right: 1,
bottom: 1,
height: '25%',
width: '25%',
itemStyle: {
// Use echarts option.backgorundColor by default.
borderColor: tokens.color.border,
borderWidth: 2
},
windowStyle: {
borderWidth: 1,
color: tokens.color.neutral30,
borderColor: tokens.color.neutral40,
opacity: 0.3
},
z: 10
};
return ThumbnailModel;
}(ComponentModel);
export { ThumbnailModel };
+286
View File
@@ -0,0 +1,286 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { __extends } from "tslib";
import ComponentView from '../../view/Component.js';
import BoundingRect from 'zrender/lib/core/BoundingRect.js';
import * as matrix from 'zrender/lib/core/matrix.js';
import RoamController from '../helper/RoamController.js';
import tokens from '../../visual/tokens.js';
import { createBoxLayoutReference, getBoxLayoutParams, getLayoutRect } from '../../util/layout.js';
import { expandOrShrinkRect, Rect, Group, traverseUpdateZ, retrieveZInfo } from '../../util/graphic.js';
import { applyTransform } from 'zrender/lib/core/vector.js';
import View from '../../coord/View.js';
import { bind, defaults, extend } from 'zrender/lib/core/util.js';
var ThumbnailView = /** @class */function (_super) {
__extends(ThumbnailView, _super);
function ThumbnailView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = ThumbnailView.type;
return _this;
}
ThumbnailView.prototype.render = function (thumbnailModel, ecModel, api) {
this._api = api;
this._model = thumbnailModel;
if (!this._coordSys) {
this._coordSys = new View();
}
if (!this._isEnabled()) {
this._clear();
return;
}
this._renderVersion = api.getMainProcessVersion();
var group = this.group;
group.removeAll();
var itemStyleModel = thumbnailModel.getModel('itemStyle');
var itemStyle = itemStyleModel.getItemStyle();
if (itemStyle.fill == null) {
itemStyle.fill = ecModel.get('backgroundColor') || tokens.color.neutral00;
}
var refContainer = createBoxLayoutReference(thumbnailModel, api).refContainer;
var boxRect = getLayoutRect(getBoxLayoutParams(thumbnailModel, true), refContainer);
var boxBorderWidth = itemStyle.lineWidth || 0;
var contentRect = this._contentRect = expandOrShrinkRect(boxRect.clone(), boxBorderWidth / 2, true, true);
var contentGroup = new Group();
group.add(contentGroup);
contentGroup.setClipPath(new Rect({
shape: contentRect.plain()
}));
var targetGroup = this._targetGroup = new Group();
contentGroup.add(targetGroup);
// Draw border and background and shadow of thumbnail box.
var borderShape = boxRect.plain();
borderShape.r = itemStyleModel.getShallow('borderRadius', true);
group.add(this._bgRect = new Rect({
style: itemStyle,
shape: borderShape,
silent: false,
cursor: 'grab'
}));
var windowStyleModel = thumbnailModel.getModel('windowStyle');
var windowR = windowStyleModel.getShallow('borderRadius', true);
contentGroup.add(this._windowRect = new Rect({
shape: {
x: 0,
y: 0,
width: 0,
height: 0,
r: windowR
},
style: windowStyleModel.getItemStyle(),
silent: false,
cursor: 'grab'
}));
this._dealRenderContent();
this._dealUpdateWindow();
updateZ(thumbnailModel, this);
};
/**
* Can be called asynchronously directly.
* This method should be idempotent.
*/
ThumbnailView.prototype.renderContent = function (bridgeRendered) {
this._bridgeRendered = bridgeRendered;
if (this._isEnabled()) {
this._dealRenderContent();
this._dealUpdateWindow();
updateZ(this._model, this);
}
};
ThumbnailView.prototype._dealRenderContent = function () {
var bridgeRendered = this._bridgeRendered;
if (!bridgeRendered || bridgeRendered.renderVersion !== this._renderVersion) {
return;
}
var targetGroup = this._targetGroup;
var coordSys = this._coordSys;
var contentRect = this._contentRect;
targetGroup.removeAll();
if (!bridgeRendered) {
return;
}
var bridgeGroup = bridgeRendered.group;
var bridgeRect = bridgeGroup.getBoundingRect();
targetGroup.add(bridgeGroup);
this._bgRect.z2 = bridgeRendered.z2Range.min - 10;
coordSys.setBoundingRect(bridgeRect.x, bridgeRect.y, bridgeRect.width, bridgeRect.height);
// Use `getLayoutRect` is just to find an approperiate rect in thumbnail.
var viewRect = getLayoutRect({
left: 'center',
top: 'center',
aspect: bridgeRect.width / bridgeRect.height
}, contentRect);
coordSys.setViewRect(viewRect.x, viewRect.y, viewRect.width, viewRect.height);
bridgeGroup.attr(coordSys.getTransformInfo().raw);
this._windowRect.z2 = bridgeRendered.z2Range.max + 10;
this._resetRoamController(bridgeRendered.roamType);
};
/**
* Can be called from action handler directly.
* This method should be idempotent.
*/
ThumbnailView.prototype.updateWindow = function (param) {
var bridgeRendered = this._bridgeRendered;
if (bridgeRendered && bridgeRendered.renderVersion === param.renderVersion) {
bridgeRendered.targetTrans = param.targetTrans;
}
if (this._isEnabled()) {
this._dealUpdateWindow();
}
};
ThumbnailView.prototype._dealUpdateWindow = function () {
var bridgeRendered = this._bridgeRendered;
if (!bridgeRendered || bridgeRendered.renderVersion !== this._renderVersion) {
return;
}
var invTargetTrans = matrix.invert([], bridgeRendered.targetTrans);
var transTargetToThis = matrix.mul([], this._coordSys.transform, invTargetTrans);
this._transThisToTarget = matrix.invert([], transTargetToThis);
var viewportRect = bridgeRendered.viewportRect;
if (!viewportRect) {
viewportRect = new BoundingRect(0, 0, this._api.getWidth(), this._api.getHeight());
} else {
viewportRect = viewportRect.clone();
}
viewportRect.applyTransform(transTargetToThis);
var windowRect = this._windowRect;
var r = windowRect.shape.r;
windowRect.setShape(defaults({
r: r
}, viewportRect));
};
ThumbnailView.prototype._resetRoamController = function (roamType) {
var _this = this;
var api = this._api;
var roamController = this._roamController;
if (!roamController) {
roamController = this._roamController = new RoamController(api.getZr());
}
if (!roamType || !this._isEnabled()) {
roamController.disable();
return;
}
roamController.enable(roamType, {
api: api,
zInfo: {
component: this._model
},
triggerInfo: {
roamTrigger: null,
isInSelf: function (e, x, y) {
return _this._contentRect.contain(x, y);
}
}
});
roamController.off('pan').off('zoom').on('pan', bind(this._onPan, this)).on('zoom', bind(this._onZoom, this));
};
ThumbnailView.prototype._onPan = function (event) {
var trans = this._transThisToTarget;
if (!this._isEnabled() || !trans) {
return;
}
var oldOffset = applyTransform([], [event.oldX, event.oldY], trans);
var newOffset = applyTransform([], [event.oldX - event.dx, event.oldY - event.dy], trans);
this._api.dispatchAction(makeRoamPayload(this._model.getTarget().baseMapProvider, {
dx: newOffset[0] - oldOffset[0],
dy: newOffset[1] - oldOffset[1]
}));
};
ThumbnailView.prototype._onZoom = function (event) {
var trans = this._transThisToTarget;
if (!this._isEnabled() || !trans) {
return;
}
var offset = applyTransform([], [event.originX, event.originY], trans);
this._api.dispatchAction(makeRoamPayload(this._model.getTarget().baseMapProvider, {
zoom: 1 / event.scale,
originX: offset[0],
originY: offset[1]
}));
};
/**
* This method is also responsible for check enable in asynchronous situation,
* e.g., in event listeners that is supposed to be outdated but not be removed.
*/
ThumbnailView.prototype._isEnabled = function () {
var thumbnailModel = this._model;
if (!thumbnailModel || !thumbnailModel.shouldShow()) {
return false;
}
var baseMapProvider = thumbnailModel.getTarget().baseMapProvider;
if (!baseMapProvider) {
return false;
}
return true;
};
ThumbnailView.prototype._clear = function () {
this.group.removeAll();
this._bridgeRendered = null;
if (this._roamController) {
this._roamController.disable();
}
};
ThumbnailView.prototype.remove = function () {
this._clear();
};
ThumbnailView.prototype.dispose = function () {
this._clear();
};
ThumbnailView.type = 'thumbnail';
return ThumbnailView;
}(ComponentView);
export { ThumbnailView };
function makeRoamPayload(baseMapProvider, params) {
var type = baseMapProvider.mainType === 'series' ? baseMapProvider.subType + "Roam" // e.g. 'graphRoam'
: baseMapProvider.mainType + "Roam"; // e.g., 'geoRoam'
var payload = {
type: type
};
payload[baseMapProvider.mainType + "Id"] = baseMapProvider.id;
extend(payload, params);
return payload;
}
function updateZ(thumbnailModel, thumbnailView) {
var zInfo = retrieveZInfo(thumbnailModel);
traverseUpdateZ(thumbnailView.group, zInfo.z, zInfo.zlevel);
}
+49
View File
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
/**
* AUTO-GENERATED FILE. DO NOT MODIFY.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { ThumbnailModel } from './ThumbnailModel.js';
import { ThumbnailView } from './ThumbnailView.js';
export function install(registers) {
registers.registerComponentModel(ThumbnailModel);
registers.registerComponentView(ThumbnailView);
}