前端初始化

This commit is contained in:
“hsc”
2026-08-21 15:36:24 +08:00
commit e4d8ecde13
14411 changed files with 2275932 additions and 0 deletions
+116
View File
@@ -0,0 +1,116 @@
/*
* 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 createSeriesData from '../helper/createSeriesData.js';
import SeriesModel from '../../model/Series.js';
import tokens from '../../visual/tokens.js';
var ScatterSeriesModel = /** @class */function (_super) {
__extends(ScatterSeriesModel, _super);
function ScatterSeriesModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = ScatterSeriesModel.type;
_this.hasSymbolVisual = true;
return _this;
}
ScatterSeriesModel.prototype.getInitialData = function (option, ecModel) {
return createSeriesData(null, this, {
useEncodeDefaulter: true
});
};
ScatterSeriesModel.prototype.getProgressive = function () {
var progressive = this.option.progressive;
if (progressive == null) {
// PENDING
return this.option.large ? 5e3 : this.get('progressive');
}
return progressive;
};
ScatterSeriesModel.prototype.getProgressiveThreshold = function () {
var progressiveThreshold = this.option.progressiveThreshold;
if (progressiveThreshold == null) {
// PENDING
return this.option.large ? 1e4 : this.get('progressiveThreshold');
}
return progressiveThreshold;
};
ScatterSeriesModel.prototype.brushSelector = function (dataIndex, data, selectors) {
return selectors.point(data.getItemLayout(dataIndex));
};
ScatterSeriesModel.prototype.getZLevelKey = function () {
// PENDING: See `GET_ZLEVEL_KEY_FOR_PROGRESSIVE`
return this.getData().count() > this.getProgressiveThreshold() ? this.id : '';
};
ScatterSeriesModel.type = 'series.scatter';
ScatterSeriesModel.dependencies = ['grid', 'polar', 'geo', 'singleAxis', 'calendar', 'matrix'];
ScatterSeriesModel.defaultOption = {
coordinateSystem: 'cartesian2d',
// zlevel: 0,
z: 2,
legendHoverLink: true,
symbolSize: 10,
// symbolRotate: null,
large: false,
// Available when large is true
largeThreshold: 2000,
// cursor: null,
itemStyle: {
opacity: 0.8
},
emphasis: {
scale: true
},
clip: true,
select: {
itemStyle: {
borderColor: tokens.color.primary
}
},
universalTransition: {
divideShape: 'clone'
}
// progressive: null
};
return ScatterSeriesModel;
}(SeriesModel);
export default ScatterSeriesModel;
+132
View File
@@ -0,0 +1,132 @@
/*
* 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 SymbolDraw from '../helper/SymbolDraw.js';
import LargeSymbolDraw from '../helper/LargeSymbolDraw.js';
import pointsLayout from '../../layout/points.js';
import ChartView from '../../view/Chart.js';
import { getIncrementalId } from '../../util/model.js';
import { createCoordSysClipAreaSimply } from '../helper/createClipPathFromCoordSys.js';
var ScatterView = /** @class */function (_super) {
__extends(ScatterView, _super);
function ScatterView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = ScatterView.type;
return _this;
}
ScatterView.prototype.render = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var symbolDraw = this._updateSymbolDraw(data, seriesModel);
symbolDraw.updateData(data, createSymbolDrawOpt(seriesModel));
this._finished = true;
};
ScatterView.prototype.incrementalPrepareRender = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
var symbolDraw = this._updateSymbolDraw(data, seriesModel);
symbolDraw.incrementalPrepareUpdate(data);
this._finished = false;
};
ScatterView.prototype.incrementalRender = function (taskParams, seriesModel, ecModel) {
this._symbolDraw.incrementalUpdate(taskParams, seriesModel.getData(), getIncrementalId(seriesModel), createSymbolDrawOpt(seriesModel));
this._finished = taskParams.end === seriesModel.getData().count();
};
/**
* See also VIEW_COORD_SYS_ANIMATION
*/
ScatterView.prototype.updateTransform = function (seriesModel, ecModel, api) {
var data = seriesModel.getData();
// Must mark group dirty and make sure the incremental layer will be cleared
// PENDING
this.group.dirty();
if (!this._finished) {
// FIXME: _finished checking is unnecessary?
return {
update: true
};
} else {
var res = pointsLayout('').reset(seriesModel, ecModel, api);
if (res.progress) {
res.progress({
start: 0,
end: data.count(),
count: data.count()
}, data);
}
this._symbolDraw.updateLayout(createSymbolDrawOpt(seriesModel));
}
};
ScatterView.prototype.eachRendered = function (cb) {
this._symbolDraw && this._symbolDraw.eachRendered(cb);
};
ScatterView.prototype._updateSymbolDraw = function (data, seriesModel) {
var symbolDraw = this._symbolDraw;
var pipelineContext = seriesModel.pipelineContext;
var isLargeDraw = pipelineContext.large;
if (!symbolDraw || isLargeDraw !== this._isLargeDraw) {
symbolDraw && symbolDraw.remove();
symbolDraw = this._symbolDraw = isLargeDraw ? new LargeSymbolDraw() : new SymbolDraw();
this._isLargeDraw = isLargeDraw;
this.group.removeAll();
}
this.group.add(symbolDraw.group);
return symbolDraw;
};
ScatterView.prototype.remove = function (ecModel, api) {
this._symbolDraw && this._symbolDraw.remove(true);
this._symbolDraw = null;
};
ScatterView.prototype.dispose = function () {};
ScatterView.type = 'scatter';
return ScatterView;
}(ChartView);
function createSymbolDrawOpt(seriesModel) {
return {
// TODO
// If this parameter should be a shape or a bounding volume
// shape will be more general.
// But bounding volume like bounding rect will be much faster in the contain calculation
clipShape: createCoordSysClipAreaSimply(seriesModel)
};
}
export default ScatterView;
+59
View File
@@ -0,0 +1,59 @@
/*
* 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 { use } from '../../extension.js';
import ScatterSeriesModel from './ScatterSeries.js';
import ScatterView from './ScatterView.js';
import { install as installGridSimple } from '../../component/grid/installSimple.js';
import layoutPoints from '../../layout/points.js';
import jitterLayout from './jitterLayout.js';
export function install(registers) {
// In case developer forget to include grid component
use(installGridSimple);
registers.registerSeriesModel(ScatterSeriesModel);
registers.registerChartView(ScatterView);
registers.registerLayout(layoutPoints('scatter'));
}
export function installScatterJitter(registers) {
registers.registerLayout(registers.PRIORITY.VISUAL.POST_CHART_LAYOUT, jitterLayout());
}
+108
View File
@@ -0,0 +1,108 @@
/*
* 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 { needFixJitter, fixJitter } from '../../util/jitter.js';
import createRenderPlanner from '../helper/createRenderPlanner.js';
import { COORD_SYS_TYPE_CARTESIAN_2D } from '../../coord/cartesian/GridModel.js';
import { COORD_SYS_TYPE_SINGLE } from '../../coord/single/AxisModel.js';
import { validateUpstreamOutputRange } from '../../util/model.js';
export default function jitterLayout() {
return {
seriesType: 'scatter',
plan: createRenderPlanner(),
reset: function (seriesModel) {
var coordSys = seriesModel.coordinateSystem;
if (!coordSys || coordSys.type !== COORD_SYS_TYPE_CARTESIAN_2D && coordSys.type !== COORD_SYS_TYPE_SINGLE) {
return;
}
var baseAxis = coordSys.getBaseAxis && coordSys.getBaseAxis();
var hasJitter = baseAxis && needFixJitter(seriesModel, baseAxis);
if (!hasJitter) {
return;
}
var dim = baseAxis.dim;
var orient = baseAxis.orient;
var isSingleY = orient === 'horizontal' && baseAxis.type !== 'category' || orient === 'vertical' && baseAxis.type === 'category';
var jitterOnY = dim === 'y' || dim === 'single' && isSingleY;
var jitterOnX = dim === 'x' || dim === 'single' && !isSingleY;
if (!jitterOnY && !jitterOnX) {
return;
}
return {
progress: function (params, data) {
var points = data.getLayout('points');
var hasPoints = !!points;
if (process.env.NODE_ENV !== 'production') {
hasPoints && validateUpstreamOutputRange(data.getLayout('pointsRange'), params);
}
for (var i = params.start; i < params.end; i++) {
var offset = hasPoints ? (i - params.start) * 2 : -1;
var layout = hasPoints ? [points[offset], points[offset + 1]] : data.getItemLayout(i);
if (!layout) {
continue;
}
var rawSize = data.getItemVisual(i, 'symbolSize');
var size = rawSize instanceof Array ? (rawSize[1] + rawSize[0]) / 2 : rawSize;
if (jitterOnY) {
// x is fixed, and y is floating
var jittered = fixJitter(baseAxis, layout[0], layout[1], size / 2);
if (hasPoints) {
points[offset + 1] = jittered;
} else {
layout[1] = jittered;
}
} else if (jitterOnX) {
// y is fixed, and x is floating
var jittered = fixJitter(baseAxis, layout[1], layout[0], size / 2);
if (hasPoints) {
points[offset] = jittered;
} else {
layout[0] = jittered;
}
}
}
}
};
}
};
}