逐步完成前后端服务器

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,58 @@
/*
* 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 makeStyleMapper from './makeStyleMapper.js';
export var AREA_STYLE_KEY_MAP = [['fill', 'color'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['opacity'], ['shadowColor']
// Option decal is in `DecalObject` but style.decal is in `PatternObject`.
// So do not transfer decal directly.
];
var getAreaStyle = makeStyleMapper(AREA_STYLE_KEY_MAP);
var AreaStyleMixin = /** @class */function () {
function AreaStyleMixin() {}
AreaStyleMixin.prototype.getAreaStyle = function (excludes, includes) {
return getAreaStyle(this, excludes, includes);
};
return AreaStyleMixin;
}();
;
export { AreaStyleMixin };

View File

@ -0,0 +1,202 @@
/*
* 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';
import { retrieveRawValue } from '../../data/helper/dataProvider.js';
import { formatTpl } from '../../util/format.js';
import { error, makePrintable } from '../../util/log.js';
var DIMENSION_LABEL_REG = /\{@(.+?)\}/g;
var DataFormatMixin = /** @class */function () {
function DataFormatMixin() {}
/**
* Get params for formatter
*/
DataFormatMixin.prototype.getDataParams = function (dataIndex, dataType) {
var data = this.getData(dataType);
var rawValue = this.getRawValue(dataIndex, dataType);
var rawDataIndex = data.getRawIndex(dataIndex);
var name = data.getName(dataIndex);
var itemOpt = data.getRawDataItem(dataIndex);
var style = data.getItemVisual(dataIndex, 'style');
var color = style && style[data.getItemVisual(dataIndex, 'drawType') || 'fill'];
var borderColor = style && style.stroke;
var mainType = this.mainType;
var isSeries = mainType === 'series';
var userOutput = data.userOutput && data.userOutput.get();
return {
componentType: mainType,
componentSubType: this.subType,
componentIndex: this.componentIndex,
seriesType: isSeries ? this.subType : null,
seriesIndex: this.seriesIndex,
seriesId: isSeries ? this.id : null,
seriesName: isSeries ? this.name : null,
name: name,
dataIndex: rawDataIndex,
data: itemOpt,
dataType: dataType,
value: rawValue,
color: color,
borderColor: borderColor,
dimensionNames: userOutput ? userOutput.fullDimensions : null,
encode: userOutput ? userOutput.encode : null,
// Param name list for mapping `a`, `b`, `c`, `d`, `e`
$vars: ['seriesName', 'name', 'value']
};
};
/**
* Format label
* @param dataIndex
* @param status 'normal' by default
* @param dataType
* @param labelDimIndex Only used in some chart that
* use formatter in different dimensions, like radar.
* @param formatter Formatter given outside.
* @return return null/undefined if no formatter
*/
DataFormatMixin.prototype.getFormattedLabel = function (dataIndex, status, dataType, labelDimIndex, formatter, extendParams) {
status = status || 'normal';
var data = this.getData(dataType);
var params = this.getDataParams(dataIndex, dataType);
if (extendParams) {
params.value = extendParams.interpolatedValue;
}
if (labelDimIndex != null && zrUtil.isArray(params.value)) {
params.value = params.value[labelDimIndex];
}
if (!formatter) {
var itemModel = data.getItemModel(dataIndex);
// @ts-ignore
formatter = itemModel.get(status === 'normal' ? ['label', 'formatter'] : [status, 'label', 'formatter']);
}
if (zrUtil.isFunction(formatter)) {
params.status = status;
params.dimensionIndex = labelDimIndex;
return formatter(params);
} else if (zrUtil.isString(formatter)) {
var str = formatTpl(formatter, params);
// Support 'aaa{@[3]}bbb{@product}ccc'.
// Do not support '}' in dim name util have to.
return str.replace(DIMENSION_LABEL_REG, function (origin, dimStr) {
var len = dimStr.length;
var dimLoose = dimStr;
if (dimLoose.charAt(0) === '[' && dimLoose.charAt(len - 1) === ']') {
dimLoose = +dimLoose.slice(1, len - 1); // Also support: '[]' => 0
if (process.env.NODE_ENV !== 'production') {
if (isNaN(dimLoose)) {
error("Invalide label formatter: @" + dimStr + ", only support @[0], @[1], @[2], ...");
}
}
}
var val = retrieveRawValue(data, dataIndex, dimLoose);
if (extendParams && zrUtil.isArray(extendParams.interpolatedValue)) {
var dimIndex = data.getDimensionIndex(dimLoose);
if (dimIndex >= 0) {
val = extendParams.interpolatedValue[dimIndex];
}
}
return val != null ? val + '' : '';
});
}
};
/**
* Get raw value in option
*/
DataFormatMixin.prototype.getRawValue = function (idx, dataType) {
return retrieveRawValue(this.getData(dataType), idx);
};
/**
* Should be implemented.
* @param {number} dataIndex
* @param {boolean} [multipleSeries=false]
* @param {string} [dataType]
*/
DataFormatMixin.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
// Empty function
return;
};
return DataFormatMixin;
}();
export { DataFormatMixin };
;
// PENDING: previously we accept this type when calling `formatTooltip`,
// but guess little chance has been used outside. Do we need to backward
// compat it?
// type TooltipFormatResultLegacyObject = {
// // `html` means the markup language text, either in 'html' or 'richText'.
// // The name `html` is not appropriate because in 'richText' it is not a HTML
// // string. But still support it for backward compatibility.
// html: string;
// markers: Dictionary<ColorString>;
// };
/**
* For backward compat, normalize the return from `formatTooltip`.
*/
export function normalizeTooltipFormatResult(result) {
var markupText;
// let markers: Dictionary<ColorString>;
var markupFragment;
if (zrUtil.isObject(result)) {
if (result.type) {
markupFragment = result;
} else {
if (process.env.NODE_ENV !== 'production') {
console.warn('The return type of `formatTooltip` is not supported: ' + makePrintable(result));
}
}
// else {
// markupText = (result as TooltipFormatResultLegacyObject).html;
// markers = (result as TooltipFormatResultLegacyObject).markers;
// if (markersExisting) {
// markers = zrUtil.merge(markersExisting, markers);
// }
// }
} else {
markupText = result;
}
return {
text: markupText,
// markers: markers || markersExisting,
frag: markupFragment
};
}

View File

@ -0,0 +1,57 @@
/*
* 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 makeStyleMapper from './makeStyleMapper.js';
export var ITEM_STYLE_KEY_MAP = [['fill', 'color'], ['stroke', 'borderColor'], ['lineWidth', 'borderWidth'], ['opacity'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['shadowColor'], ['lineDash', 'borderType'], ['lineDashOffset', 'borderDashOffset'], ['lineCap', 'borderCap'], ['lineJoin', 'borderJoin'], ['miterLimit', 'borderMiterLimit']
// Option decal is in `DecalObject` but style.decal is in `PatternObject`.
// So do not transfer decal directly.
];
var getItemStyle = makeStyleMapper(ITEM_STYLE_KEY_MAP);
var ItemStyleMixin = /** @class */function () {
function ItemStyleMixin() {}
ItemStyleMixin.prototype.getItemStyle = function (excludes, includes) {
return getItemStyle(this, excludes, includes);
};
return ItemStyleMixin;
}();
export { ItemStyleMixin };

View File

@ -0,0 +1,58 @@
/*
* 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 makeStyleMapper from './makeStyleMapper.js';
export var LINE_STYLE_KEY_MAP = [['lineWidth', 'width'], ['stroke', 'color'], ['opacity'], ['shadowBlur'], ['shadowOffsetX'], ['shadowOffsetY'], ['shadowColor'], ['lineDash', 'type'], ['lineDashOffset', 'dashOffset'], ['lineCap', 'cap'], ['lineJoin', 'join'], ['miterLimit']
// Option decal is in `DecalObject` but style.decal is in `PatternObject`.
// So do not transfer decal directly.
];
var getLineStyle = makeStyleMapper(LINE_STYLE_KEY_MAP);
var LineStyleMixin = /** @class */function () {
function LineStyleMixin() {}
LineStyleMixin.prototype.getLineStyle = function (excludes) {
return getLineStyle(this, excludes);
};
return LineStyleMixin;
}();
;
export { LineStyleMixin };

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.
*/
// TODO Parse shadow style
// TODO Only shallow path support
import * as zrUtil from 'zrender/lib/core/util.js';
export default function makeStyleMapper(properties, ignoreParent) {
// Normalize
for (var i = 0; i < properties.length; i++) {
if (!properties[i][1]) {
properties[i][1] = properties[i][0];
}
}
ignoreParent = ignoreParent || false;
return function (model, excludes, includes) {
var style = {};
for (var i = 0; i < properties.length; i++) {
var propName = properties[i][1];
if (excludes && zrUtil.indexOf(excludes, propName) >= 0 || includes && zrUtil.indexOf(includes, propName) < 0) {
continue;
}
var val = model.getShallow(propName, ignoreParent);
if (val != null) {
style[properties[i][0]] = val;
}
}
// TODO Text or image?
return style;
};
}

View File

@ -0,0 +1,105 @@
/*
* 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 { makeInner, normalizeToArray } from '../../util/model.js';
var innerColor = makeInner();
var innerDecal = makeInner();
var PaletteMixin = /** @class */function () {
function PaletteMixin() {}
PaletteMixin.prototype.getColorFromPalette = function (name, scope, requestNum) {
var defaultPalette = normalizeToArray(this.get('color', true));
var layeredPalette = this.get('colorLayer', true);
return getFromPalette(this, innerColor, defaultPalette, layeredPalette, name, scope, requestNum);
};
PaletteMixin.prototype.clearColorPalette = function () {
clearPalette(this, innerColor);
};
return PaletteMixin;
}();
export function getDecalFromPalette(ecModel, name, scope, requestNum) {
var defaultDecals = normalizeToArray(ecModel.get(['aria', 'decal', 'decals']));
return getFromPalette(ecModel, innerDecal, defaultDecals, null, name, scope, requestNum);
}
function getNearestPalette(palettes, requestColorNum) {
var paletteNum = palettes.length;
// TODO palettes must be in order
for (var i = 0; i < paletteNum; i++) {
if (palettes[i].length > requestColorNum) {
return palettes[i];
}
}
return palettes[paletteNum - 1];
}
/**
* @param name MUST NOT be null/undefined. Otherwise call this function
* twise with the same parameters will get different result.
* @param scope default this.
* @return Can be null/undefined
*/
function getFromPalette(that, inner, defaultPalette, layeredPalette, name, scope, requestNum) {
scope = scope || that;
var scopeFields = inner(scope);
var paletteIdx = scopeFields.paletteIdx || 0;
var paletteNameMap = scopeFields.paletteNameMap = scopeFields.paletteNameMap || {};
// Use `hasOwnProperty` to avoid conflict with Object.prototype.
if (paletteNameMap.hasOwnProperty(name)) {
return paletteNameMap[name];
}
var palette = requestNum == null || !layeredPalette ? defaultPalette : getNearestPalette(layeredPalette, requestNum);
// In case can't find in layered color palette.
palette = palette || defaultPalette;
if (!palette || !palette.length) {
return;
}
var pickedPaletteItem = palette[paletteIdx];
if (name) {
paletteNameMap[name] = pickedPaletteItem;
}
scopeFields.paletteIdx = (paletteIdx + 1) % palette.length;
return pickedPaletteItem;
}
function clearPalette(that, inner) {
inner(that).paletteIdx = 0;
inner(that).paletteNameMap = {};
}
export { PaletteMixin };

View File

@ -0,0 +1,87 @@
/*
* 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 { getFont } from '../../label/labelStyle.js';
import ZRText from 'zrender/lib/graphic/Text.js';
var PATH_COLOR = ['textStyle', 'color'];
var textStyleParams = ['fontStyle', 'fontWeight', 'fontSize', 'fontFamily', 'padding', 'lineHeight', 'rich', 'width', 'height', 'overflow'];
// TODO Performance improvement?
var tmpText = new ZRText();
var TextStyleMixin = /** @class */function () {
function TextStyleMixin() {}
/**
* Get color property or get color from option.textStyle.color
*/
// TODO Callback
TextStyleMixin.prototype.getTextColor = function (isEmphasis) {
var ecModel = this.ecModel;
return this.getShallow('color') || (!isEmphasis && ecModel ? ecModel.get(PATH_COLOR) : null);
};
/**
* Create font string from fontStyle, fontWeight, fontSize, fontFamily
* @return {string}
*/
TextStyleMixin.prototype.getFont = function () {
return getFont({
fontStyle: this.getShallow('fontStyle'),
fontWeight: this.getShallow('fontWeight'),
fontSize: this.getShallow('fontSize'),
fontFamily: this.getShallow('fontFamily')
}, this.ecModel);
};
TextStyleMixin.prototype.getTextRect = function (text) {
var style = {
text: text,
verticalAlign: this.getShallow('verticalAlign') || this.getShallow('baseline')
};
for (var i = 0; i < textStyleParams.length; i++) {
style[textStyleParams[i]] = this.getShallow(textStyleParams[i]);
}
tmpText.useStyle(style);
tmpText.update();
return tmpText.getBoundingRect();
};
return TextStyleMixin;
}();
;
export default TextStyleMixin;