逐步完成前后端服务器

This commit is contained in:
2025-09-09 15:00:30 +08:00
parent fcb09432e9
commit c7dfa1e9fc
2937 changed files with 1477567 additions and 0 deletions

View File

@ -0,0 +1,103 @@
/*
* 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 { AxisModelCommonMixin } from '../axisModelCommonMixin.js';
import { mixin } from 'zrender/lib/core/util.js';
var SingleAxisModel = /** @class */function (_super) {
__extends(SingleAxisModel, _super);
function SingleAxisModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = SingleAxisModel.type;
return _this;
}
SingleAxisModel.prototype.getCoordSysModel = function () {
return this;
};
SingleAxisModel.type = 'singleAxis';
SingleAxisModel.layoutMode = 'box';
SingleAxisModel.defaultOption = {
left: '5%',
top: '5%',
right: '5%',
bottom: '5%',
type: 'value',
position: 'bottom',
orient: 'horizontal',
axisLine: {
show: true,
lineStyle: {
width: 1,
type: 'solid'
}
},
// Single coordinate system and single axis is the,
// which is used as the parent tooltip model.
// same model, so we set default tooltip show as true.
tooltip: {
show: true
},
axisTick: {
show: true,
length: 6,
lineStyle: {
width: 1
}
},
axisLabel: {
show: true,
interval: 'auto'
},
splitLine: {
show: true,
lineStyle: {
type: 'dashed',
opacity: 0.2
}
}
};
return SingleAxisModel;
}(ComponentModel);
mixin(SingleAxisModel, AxisModelCommonMixin.prototype);
export default SingleAxisModel;

View File

@ -0,0 +1,210 @@
/*
* 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.
*/
/**
* Single coordinates system.
*/
import SingleAxis from './SingleAxis.js';
import * as axisHelper from '../axisHelper.js';
import { getLayoutRect } from '../../util/layout.js';
import { each } from 'zrender/lib/core/util.js';
export var singleDimensions = ['single'];
/**
* Create a single coordinates system.
*/
var Single = /** @class */function () {
function Single(axisModel, ecModel, api) {
this.type = 'single';
this.dimension = 'single';
/**
* Add it just for draw tooltip.
*/
this.dimensions = singleDimensions;
this.axisPointerEnabled = true;
this.model = axisModel;
this._init(axisModel, ecModel, api);
}
/**
* Initialize single coordinate system.
*/
Single.prototype._init = function (axisModel, ecModel, api) {
var dim = this.dimension;
var axis = new SingleAxis(dim, axisHelper.createScaleByModel(axisModel), [0, 0], axisModel.get('type'), axisModel.get('position'));
var isCategory = axis.type === 'category';
axis.onBand = isCategory && axisModel.get('boundaryGap');
axis.inverse = axisModel.get('inverse');
axis.orient = axisModel.get('orient');
axisModel.axis = axis;
axis.model = axisModel;
axis.coordinateSystem = this;
this._axis = axis;
};
/**
* Update axis scale after data processed
*/
Single.prototype.update = function (ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.coordinateSystem === this) {
var data_1 = seriesModel.getData();
each(data_1.mapDimensionsAll(this.dimension), function (dim) {
this._axis.scale.unionExtentFromData(data_1, dim);
}, this);
axisHelper.niceScaleExtent(this._axis.scale, this._axis.model);
}
}, this);
};
/**
* Resize the single coordinate system.
*/
Single.prototype.resize = function (axisModel, api) {
this._rect = getLayoutRect({
left: axisModel.get('left'),
top: axisModel.get('top'),
right: axisModel.get('right'),
bottom: axisModel.get('bottom'),
width: axisModel.get('width'),
height: axisModel.get('height')
}, {
width: api.getWidth(),
height: api.getHeight()
});
this._adjustAxis();
};
Single.prototype.getRect = function () {
return this._rect;
};
Single.prototype._adjustAxis = function () {
var rect = this._rect;
var axis = this._axis;
var isHorizontal = axis.isHorizontal();
var extent = isHorizontal ? [0, rect.width] : [0, rect.height];
var idx = axis.inverse ? 1 : 0;
axis.setExtent(extent[idx], extent[1 - idx]);
this._updateAxisTransform(axis, isHorizontal ? rect.x : rect.y);
};
Single.prototype._updateAxisTransform = function (axis, coordBase) {
var axisExtent = axis.getExtent();
var extentSum = axisExtent[0] + axisExtent[1];
var isHorizontal = axis.isHorizontal();
axis.toGlobalCoord = isHorizontal ? function (coord) {
return coord + coordBase;
} : function (coord) {
return extentSum - coord + coordBase;
};
axis.toLocalCoord = isHorizontal ? function (coord) {
return coord - coordBase;
} : function (coord) {
return extentSum - coord + coordBase;
};
};
/**
* Get axis.
*/
Single.prototype.getAxis = function () {
return this._axis;
};
/**
* Get axis, add it just for draw tooltip.
*/
Single.prototype.getBaseAxis = function () {
return this._axis;
};
Single.prototype.getAxes = function () {
return [this._axis];
};
Single.prototype.getTooltipAxes = function () {
return {
baseAxes: [this.getAxis()],
// Empty otherAxes
otherAxes: []
};
};
/**
* If contain point.
*/
Single.prototype.containPoint = function (point) {
var rect = this.getRect();
var axis = this.getAxis();
var orient = axis.orient;
if (orient === 'horizontal') {
return axis.contain(axis.toLocalCoord(point[0])) && point[1] >= rect.y && point[1] <= rect.y + rect.height;
} else {
return axis.contain(axis.toLocalCoord(point[1])) && point[0] >= rect.y && point[0] <= rect.y + rect.height;
}
};
Single.prototype.pointToData = function (point) {
var axis = this.getAxis();
return [axis.coordToData(axis.toLocalCoord(point[axis.orient === 'horizontal' ? 0 : 1]))];
};
/**
* Convert the series data to concrete point.
* Can be [val] | val
*/
Single.prototype.dataToPoint = function (val) {
var axis = this.getAxis();
var rect = this.getRect();
var pt = [];
var idx = axis.orient === 'horizontal' ? 0 : 1;
if (val instanceof Array) {
val = val[0];
}
pt[idx] = axis.toGlobalCoord(axis.dataToCoord(+val));
pt[1 - idx] = idx === 0 ? rect.y + rect.height / 2 : rect.x + rect.width / 2;
return pt;
};
Single.prototype.convertToPixel = function (ecModel, finder, value) {
var coordSys = getCoordSys(finder);
return coordSys === this ? this.dataToPoint(value) : null;
};
Single.prototype.convertFromPixel = function (ecModel, finder, pixel) {
var coordSys = getCoordSys(finder);
return coordSys === this ? this.pointToData(pixel) : null;
};
return Single;
}();
function getCoordSys(finder) {
var seriesModel = finder.seriesModel;
var singleModel = finder.singleAxisModel;
return singleModel && singleModel.coordinateSystem || seriesModel && seriesModel.coordinateSystem;
}
export default Single;

View File

@ -0,0 +1,66 @@
/*
* 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 Axis from '../Axis.js';
var SingleAxis = /** @class */function (_super) {
__extends(SingleAxis, _super);
function SingleAxis(dim, scale, coordExtent, axisType, position) {
var _this = _super.call(this, dim, scale, coordExtent) || this;
_this.type = axisType || 'value';
_this.position = position || 'bottom';
return _this;
}
/**
* Judge the orient of the axis.
*/
SingleAxis.prototype.isHorizontal = function () {
var position = this.position;
return position === 'top' || position === 'bottom';
};
SingleAxis.prototype.pointToData = function (point, clamp) {
return this.coordinateSystem.pointToData(point)[0];
};
return SingleAxis;
}(Axis);
export default SingleAxis;

View File

@ -0,0 +1,70 @@
/*
* 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 { bind } from 'zrender/lib/core/util.js';
function dataToCoordSize(dataSize, dataItem) {
// dataItem is necessary in log axis.
var axis = this.getAxis();
var val = dataItem instanceof Array ? dataItem[0] : dataItem;
var halfSize = (dataSize instanceof Array ? dataSize[0] : dataSize) / 2;
return axis.type === 'category' ? axis.getBandWidth() : Math.abs(axis.dataToCoord(val - halfSize) - axis.dataToCoord(val + halfSize));
}
export default function singlePrepareCustom(coordSys) {
var rect = coordSys.getRect();
return {
coordSys: {
type: 'singleAxis',
x: rect.x,
y: rect.y,
width: rect.width,
height: rect.height
},
api: {
coord: function (val) {
// do not provide "out" param
return coordSys.dataToPoint(val);
},
size: bind(dataToCoordSize, coordSys)
}
};
}

View File

@ -0,0 +1,88 @@
/*
* 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 * as zrUtil from 'zrender/lib/core/util.js';
export function layout(axisModel, opt) {
opt = opt || {};
var single = axisModel.coordinateSystem;
var axis = axisModel.axis;
var layout = {};
var axisPosition = axis.position;
var orient = axis.orient;
var rect = single.getRect();
var rectBound = [rect.x, rect.x + rect.width, rect.y, rect.y + rect.height];
var positionMap = {
horizontal: {
top: rectBound[2],
bottom: rectBound[3]
},
vertical: {
left: rectBound[0],
right: rectBound[1]
}
};
layout.position = [orient === 'vertical' ? positionMap.vertical[axisPosition] : rectBound[0], orient === 'horizontal' ? positionMap.horizontal[axisPosition] : rectBound[3]];
var r = {
horizontal: 0,
vertical: 1
};
layout.rotation = Math.PI / 2 * r[orient];
var directionMap = {
top: -1,
bottom: 1,
right: 1,
left: -1
};
layout.labelDirection = layout.tickDirection = layout.nameDirection = directionMap[axisPosition];
if (axisModel.get(['axisTick', 'inside'])) {
layout.tickDirection = -layout.tickDirection;
}
if (zrUtil.retrieve(opt.labelInside, axisModel.get(['axisLabel', 'inside']))) {
layout.labelDirection = -layout.labelDirection;
}
var labelRotation = opt.rotate;
labelRotation == null && (labelRotation = axisModel.get(['axisLabel', 'rotate']));
layout.labelRotation = axisPosition === 'top' ? -labelRotation : labelRotation;
layout.z2 = 1;
return layout;
}

View File

@ -0,0 +1,73 @@
/*
* 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.
*/
/**
* Single coordinate system creator.
*/
import Single, { singleDimensions } from './Single.js';
import { SINGLE_REFERRING } from '../../util/model.js';
/**
* Create single coordinate system and inject it into seriesModel.
*/
function create(ecModel, api) {
var singles = [];
ecModel.eachComponent('singleAxis', function (axisModel, idx) {
var single = new Single(axisModel, ecModel, api);
single.name = 'single_' + idx;
single.resize(axisModel, api);
axisModel.coordinateSystem = single;
singles.push(single);
});
ecModel.eachSeries(function (seriesModel) {
if (seriesModel.get('coordinateSystem') === 'singleAxis') {
var singleAxisModel = seriesModel.getReferringComponents('singleAxis', SINGLE_REFERRING).models[0];
seriesModel.coordinateSystem = singleAxisModel && singleAxisModel.coordinateSystem;
}
});
return singles;
}
var singleCreator = {
create: create,
dimensions: singleDimensions
};
export default singleCreator;