push the uni-demo project

This commit is contained in:
2022-06-21 10:55:37 +08:00
parent 37ca848bb6
commit 333705f703
8034 changed files with 1388875 additions and 0 deletions

View File

@@ -0,0 +1,93 @@
/*
* 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 MarkerModel from './MarkerModel.js';
var MarkAreaModel =
/** @class */
function (_super) {
__extends(MarkAreaModel, _super);
function MarkAreaModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkAreaModel.type;
return _this;
}
MarkAreaModel.prototype.createMarkerModelFromSeries = function (markerOpt, masterMarkerModel, ecModel) {
return new MarkAreaModel(markerOpt, masterMarkerModel, ecModel);
};
MarkAreaModel.type = 'markArea';
MarkAreaModel.defaultOption = {
// zlevel: 0,
// PENDING
z: 1,
tooltip: {
trigger: 'item'
},
// markArea should fixed on the coordinate system
animation: false,
label: {
show: true,
position: 'top'
},
itemStyle: {
// color and borderColor default to use color from series
// color: 'auto'
// borderColor: 'auto'
borderWidth: 0
},
emphasis: {
label: {
show: true,
position: 'top'
}
}
};
return MarkAreaModel;
}(MarkerModel);
export default MarkAreaModel;

View File

@@ -0,0 +1,376 @@
/*
* 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"; // TODO Optimize on polar
import * as colorUtil from 'zrender/lib/tool/color.js';
import SeriesData from '../../data/SeriesData.js';
import * as numberUtil from '../../util/number.js';
import * as graphic from '../../util/graphic.js';
import { toggleHoverEmphasis, setStatesStylesFromModel } from '../../util/states.js';
import * as markerHelper from './markerHelper.js';
import MarkerView from './MarkerView.js';
import { retrieve, mergeAll, map, curry, filter, extend, isString } from 'zrender/lib/core/util.js';
import { isCoordinateSystemType } from '../../coord/CoordinateSystem.js';
import MarkerModel from './MarkerModel.js';
import { makeInner } from '../../util/model.js';
import { getVisualFromData } from '../../visual/helper.js';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle.js';
import { getECData } from '../../util/innerStore.js';
import { parseDataValue } from '../../data/helper/dataValueHelper.js';
var inner = makeInner();
var markAreaTransform = function (seriesModel, coordSys, maModel, item) {
var lt = markerHelper.dataTransform(seriesModel, item[0]);
var rb = markerHelper.dataTransform(seriesModel, item[1]); // FIXME make sure lt is less than rb
var ltCoord = lt.coord;
var rbCoord = rb.coord;
ltCoord[0] = retrieve(ltCoord[0], -Infinity);
ltCoord[1] = retrieve(ltCoord[1], -Infinity);
rbCoord[0] = retrieve(rbCoord[0], Infinity);
rbCoord[1] = retrieve(rbCoord[1], Infinity); // Merge option into one
var result = mergeAll([{}, lt, rb]);
result.coord = [lt.coord, rb.coord];
result.x0 = lt.x;
result.y0 = lt.y;
result.x1 = rb.x;
result.y1 = rb.y;
return result;
};
function isInifinity(val) {
return !isNaN(val) && !isFinite(val);
} // If a markArea has one dim
function ifMarkAreaHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]);
}
function markAreaFilter(coordSys, item) {
var fromCoord = item.coord[0];
var toCoord = item.coord[1];
var item0 = {
coord: fromCoord,
x: item.x0,
y: item.y0
};
var item1 = {
coord: toCoord,
x: item.x1,
y: item.y1
};
if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
// In case
// {
// markArea: {
// data: [{ yAxis: 2 }]
// }
// }
if (fromCoord && toCoord && (ifMarkAreaHasOnlyDim(1, fromCoord, toCoord, coordSys) || ifMarkAreaHasOnlyDim(0, fromCoord, toCoord, coordSys))) {
return true;
} //Directly returning true may also do the work,
//because markArea will not be shown automatically
//when it's not included in coordinate system.
//But filtering ahead can avoid keeping rendering markArea
//when there are too many of them.
return markerHelper.zoneFilter(coordSys, item0, item1);
}
return markerHelper.dataFilter(coordSys, item0) || markerHelper.dataFilter(coordSys, item1);
} // dims can be ['x0', 'y0'], ['x1', 'y1'], ['x0', 'y1'], ['x1', 'y0']
function getSingleMarkerEndPoint(data, idx, dims, seriesModel, api) {
var coordSys = seriesModel.coordinateSystem;
var itemModel = data.getItemModel(idx);
var point;
var xPx = numberUtil.parsePercent(itemModel.get(dims[0]), api.getWidth());
var yPx = numberUtil.parsePercent(itemModel.get(dims[1]), api.getHeight());
if (!isNaN(xPx) && !isNaN(yPx)) {
point = [xPx, yPx];
} else {
// Chart like bar may have there own marker positioning logic
if (seriesModel.getMarkerPosition) {
// Use the getMarkerPoisition
point = seriesModel.getMarkerPosition(data.getValues(dims, idx));
} else {
var x = data.get(dims[0], idx);
var y = data.get(dims[1], idx);
var pt = [x, y];
coordSys.clampData && coordSys.clampData(pt, pt);
point = coordSys.dataToPoint(pt, true);
}
if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
// TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
var xAxis = coordSys.getAxis('x');
var yAxis = coordSys.getAxis('y');
var x = data.get(dims[0], idx);
var y = data.get(dims[1], idx);
if (isInifinity(x)) {
point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[dims[0] === 'x0' ? 0 : 1]);
} else if (isInifinity(y)) {
point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[dims[1] === 'y0' ? 0 : 1]);
}
} // Use x, y if has any
if (!isNaN(xPx)) {
point[0] = xPx;
}
if (!isNaN(yPx)) {
point[1] = yPx;
}
}
return point;
}
var dimPermutations = [['x0', 'y0'], ['x1', 'y0'], ['x1', 'y1'], ['x0', 'y1']];
var MarkAreaView =
/** @class */
function (_super) {
__extends(MarkAreaView, _super);
function MarkAreaView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkAreaView.type;
return _this;
}
MarkAreaView.prototype.updateTransform = function (markAreaModel, ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
var maModel = MarkerModel.getMarkerModelFromSeries(seriesModel, 'markArea');
if (maModel) {
var areaData_1 = maModel.getData();
areaData_1.each(function (idx) {
var points = map(dimPermutations, function (dim) {
return getSingleMarkerEndPoint(areaData_1, idx, dim, seriesModel, api);
}); // Layout
areaData_1.setItemLayout(idx, points);
var el = areaData_1.getItemGraphicEl(idx);
el.setShape('points', points);
});
}
}, this);
};
MarkAreaView.prototype.renderSeries = function (seriesModel, maModel, ecModel, api) {
var coordSys = seriesModel.coordinateSystem;
var seriesId = seriesModel.id;
var seriesData = seriesModel.getData();
var areaGroupMap = this.markerGroupMap;
var polygonGroup = areaGroupMap.get(seriesId) || areaGroupMap.set(seriesId, {
group: new graphic.Group()
});
this.group.add(polygonGroup.group);
this.markKeep(polygonGroup);
var areaData = createList(coordSys, seriesModel, maModel); // Line data for tooltip and formatter
maModel.setData(areaData); // Update visual and layout of line
areaData.each(function (idx) {
// Layout
var points = map(dimPermutations, function (dim) {
return getSingleMarkerEndPoint(areaData, idx, dim, seriesModel, api);
});
var xAxisScale = coordSys.getAxis('x').scale;
var yAxisScale = coordSys.getAxis('y').scale;
var xAxisExtent = xAxisScale.getExtent();
var yAxisExtent = yAxisScale.getExtent();
var xPointExtent = [xAxisScale.parse(areaData.get('x0', idx)), xAxisScale.parse(areaData.get('x1', idx))];
var yPointExtent = [yAxisScale.parse(areaData.get('y0', idx)), yAxisScale.parse(areaData.get('y1', idx))];
numberUtil.asc(xPointExtent);
numberUtil.asc(yPointExtent);
var overlapped = !(xAxisExtent[0] > xPointExtent[1] || xAxisExtent[1] < xPointExtent[0] || yAxisExtent[0] > yPointExtent[1] || yAxisExtent[1] < yPointExtent[0]); // If none of the area is inside coordSys, allClipped is set to be true
// in layout so that label will not be displayed. See #12591
var allClipped = !overlapped;
areaData.setItemLayout(idx, {
points: points,
allClipped: allClipped
});
var style = areaData.getItemModel(idx).getModel('itemStyle').getItemStyle();
var color = getVisualFromData(seriesData, 'color');
if (!style.fill) {
style.fill = color;
if (isString(style.fill)) {
style.fill = colorUtil.modifyAlpha(style.fill, 0.4);
}
}
if (!style.stroke) {
style.stroke = color;
} // Visual
areaData.setItemVisual(idx, 'style', style);
});
areaData.diff(inner(polygonGroup).data).add(function (idx) {
var layout = areaData.getItemLayout(idx);
if (!layout.allClipped) {
var polygon = new graphic.Polygon({
shape: {
points: layout.points
}
});
areaData.setItemGraphicEl(idx, polygon);
polygonGroup.group.add(polygon);
}
}).update(function (newIdx, oldIdx) {
var polygon = inner(polygonGroup).data.getItemGraphicEl(oldIdx);
var layout = areaData.getItemLayout(newIdx);
if (!layout.allClipped) {
if (polygon) {
graphic.updateProps(polygon, {
shape: {
points: layout.points
}
}, maModel, newIdx);
} else {
polygon = new graphic.Polygon({
shape: {
points: layout.points
}
});
}
areaData.setItemGraphicEl(newIdx, polygon);
polygonGroup.group.add(polygon);
} else if (polygon) {
polygonGroup.group.remove(polygon);
}
}).remove(function (idx) {
var polygon = inner(polygonGroup).data.getItemGraphicEl(idx);
polygonGroup.group.remove(polygon);
}).execute();
areaData.eachItemGraphicEl(function (polygon, idx) {
var itemModel = areaData.getItemModel(idx);
var style = areaData.getItemVisual(idx, 'style');
polygon.useStyle(areaData.getItemVisual(idx, 'style'));
setLabelStyle(polygon, getLabelStatesModels(itemModel), {
labelFetcher: maModel,
labelDataIndex: idx,
defaultText: areaData.getName(idx) || '',
inheritColor: isString(style.fill) ? colorUtil.modifyAlpha(style.fill, 1) : '#000'
});
setStatesStylesFromModel(polygon, itemModel);
toggleHoverEmphasis(polygon, null, null, itemModel.get(['emphasis', 'disabled']));
getECData(polygon).dataModel = maModel;
});
inner(polygonGroup).data = areaData;
polygonGroup.group.silent = maModel.get('silent') || seriesModel.get('silent');
};
MarkAreaView.type = 'markArea';
return MarkAreaView;
}(MarkerView);
function createList(coordSys, seriesModel, maModel) {
var areaData;
var dataDims;
var dims = ['x0', 'y0', 'x1', 'y1'];
if (coordSys) {
var coordDimsInfos_1 = map(coordSys && coordSys.dimensions, function (coordDim) {
var data = seriesModel.getData();
var info = data.getDimensionInfo(data.mapDimension(coordDim)) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
return extend(extend({}, info), {
name: coordDim,
// DON'T use ordinalMeta to parse and collect ordinal.
ordinalMeta: null
});
});
dataDims = map(dims, function (dim, idx) {
return {
name: dim,
type: coordDimsInfos_1[idx % 2].type
};
});
areaData = new SeriesData(dataDims, maModel);
} else {
dataDims = [{
name: 'value',
type: 'float'
}];
areaData = new SeriesData(dataDims, maModel);
}
var optData = map(maModel.get('data'), curry(markAreaTransform, seriesModel, coordSys, maModel));
if (coordSys) {
optData = filter(optData, curry(markAreaFilter, coordSys));
}
var dimValueGetter = coordSys ? function (item, dimName, dataIndex, dimIndex) {
// TODO should convert to ParsedValue?
var rawVal = item.coord[Math.floor(dimIndex / 2)][dimIndex % 2];
return parseDataValue(rawVal, dataDims[dimIndex]);
} : function (item, dimName, dataIndex, dimIndex) {
return parseDataValue(item.value, dataDims[dimIndex]);
};
areaData.initData(optData, null, dimValueGetter);
areaData.hasItemOption = true;
return areaData;
}
export default MarkAreaView;

View File

@@ -0,0 +1,96 @@
/*
* 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 MarkerModel from './MarkerModel.js';
var MarkLineModel =
/** @class */
function (_super) {
__extends(MarkLineModel, _super);
function MarkLineModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkLineModel.type;
return _this;
}
MarkLineModel.prototype.createMarkerModelFromSeries = function (markerOpt, masterMarkerModel, ecModel) {
return new MarkLineModel(markerOpt, masterMarkerModel, ecModel);
};
MarkLineModel.type = 'markLine';
MarkLineModel.defaultOption = {
// zlevel: 0,
z: 5,
symbol: ['circle', 'arrow'],
symbolSize: [8, 16],
//symbolRotate: 0,
symbolOffset: 0,
precision: 2,
tooltip: {
trigger: 'item'
},
label: {
show: true,
position: 'end',
distance: 5
},
lineStyle: {
type: 'dashed'
},
emphasis: {
label: {
show: true
},
lineStyle: {
width: 3
}
},
animationEasing: 'linear'
};
return MarkLineModel;
}(MarkerModel);
export default MarkLineModel;

View File

@@ -0,0 +1,407 @@
/*
* 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 SeriesData from '../../data/SeriesData.js';
import * as numberUtil from '../../util/number.js';
import * as markerHelper from './markerHelper.js';
import LineDraw from '../../chart/helper/LineDraw.js';
import MarkerView from './MarkerView.js';
import { getStackedDimension } from '../../data/helper/dataStackHelper.js';
import { isCoordinateSystemType } from '../../coord/CoordinateSystem.js';
import { getECData } from '../../util/innerStore.js';
import MarkerModel from './MarkerModel.js';
import { isArray, retrieve, retrieve2, clone, extend, logError, merge, map, curry, filter, isNumber } from 'zrender/lib/core/util.js';
import { makeInner } from '../../util/model.js';
import { getVisualFromData } from '../../visual/helper.js';
var inner = makeInner();
var markLineTransform = function (seriesModel, coordSys, mlModel, item) {
var data = seriesModel.getData();
var itemArray;
if (!isArray(item)) {
// Special type markLine like 'min', 'max', 'average', 'median'
var mlType = item.type;
if (mlType === 'min' || mlType === 'max' || mlType === 'average' || mlType === 'median' // In case
// data: [{
// yAxis: 10
// }]
|| item.xAxis != null || item.yAxis != null) {
var valueAxis = void 0;
var value = void 0;
if (item.yAxis != null || item.xAxis != null) {
valueAxis = coordSys.getAxis(item.yAxis != null ? 'y' : 'x');
value = retrieve(item.yAxis, item.xAxis);
} else {
var axisInfo = markerHelper.getAxisInfo(item, data, coordSys, seriesModel);
valueAxis = axisInfo.valueAxis;
var valueDataDim = getStackedDimension(data, axisInfo.valueDataDim);
value = markerHelper.numCalculate(data, valueDataDim, mlType);
}
var valueIndex = valueAxis.dim === 'x' ? 0 : 1;
var baseIndex = 1 - valueIndex; // Normized to 2d data with start and end point
var mlFrom = clone(item);
var mlTo = {
coord: []
};
mlFrom.type = null;
mlFrom.coord = [];
mlFrom.coord[baseIndex] = -Infinity;
mlTo.coord[baseIndex] = Infinity;
var precision = mlModel.get('precision');
if (precision >= 0 && isNumber(value)) {
value = +value.toFixed(Math.min(precision, 20));
}
mlFrom.coord[valueIndex] = mlTo.coord[valueIndex] = value;
itemArray = [mlFrom, mlTo, {
type: mlType,
valueIndex: item.valueIndex,
// Force to use the value of calculated value.
value: value
}];
} else {
// Invalid data
if (process.env.NODE_ENV !== 'production') {
logError('Invalid markLine data.');
}
itemArray = [];
}
} else {
itemArray = item;
}
var normalizedItem = [markerHelper.dataTransform(seriesModel, itemArray[0]), markerHelper.dataTransform(seriesModel, itemArray[1]), extend({}, itemArray[2])]; // Avoid line data type is extended by from(to) data type
normalizedItem[2].type = normalizedItem[2].type || null; // Merge from option and to option into line option
merge(normalizedItem[2], normalizedItem[0]);
merge(normalizedItem[2], normalizedItem[1]);
return normalizedItem;
};
function isInifinity(val) {
return !isNaN(val) && !isFinite(val);
} // If a markLine has one dim
function ifMarkLineHasOnlyDim(dimIndex, fromCoord, toCoord, coordSys) {
var otherDimIndex = 1 - dimIndex;
var dimName = coordSys.dimensions[dimIndex];
return isInifinity(fromCoord[otherDimIndex]) && isInifinity(toCoord[otherDimIndex]) && fromCoord[dimIndex] === toCoord[dimIndex] && coordSys.getAxis(dimName).containData(fromCoord[dimIndex]);
}
function markLineFilter(coordSys, item) {
if (coordSys.type === 'cartesian2d') {
var fromCoord = item[0].coord;
var toCoord = item[1].coord; // In case
// {
// markLine: {
// data: [{ yAxis: 2 }]
// }
// }
if (fromCoord && toCoord && (ifMarkLineHasOnlyDim(1, fromCoord, toCoord, coordSys) || ifMarkLineHasOnlyDim(0, fromCoord, toCoord, coordSys))) {
return true;
}
}
return markerHelper.dataFilter(coordSys, item[0]) && markerHelper.dataFilter(coordSys, item[1]);
}
function updateSingleMarkerEndLayout(data, idx, isFrom, seriesModel, api) {
var coordSys = seriesModel.coordinateSystem;
var itemModel = data.getItemModel(idx);
var point;
var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
if (!isNaN(xPx) && !isNaN(yPx)) {
point = [xPx, yPx];
} else {
// Chart like bar may have there own marker positioning logic
if (seriesModel.getMarkerPosition) {
// Use the getMarkerPoisition
point = seriesModel.getMarkerPosition(data.getValues(data.dimensions, idx));
} else {
var dims = coordSys.dimensions;
var x = data.get(dims[0], idx);
var y = data.get(dims[1], idx);
point = coordSys.dataToPoint([x, y]);
} // Expand line to the edge of grid if value on one axis is Inifnity
// In case
// markLine: {
// data: [{
// yAxis: 2
// // or
// type: 'average'
// }]
// }
if (isCoordinateSystemType(coordSys, 'cartesian2d')) {
// TODO: TYPE ts@4.1 may still infer it as Axis instead of Axis2D. Not sure if it's a bug
var xAxis = coordSys.getAxis('x');
var yAxis = coordSys.getAxis('y');
var dims = coordSys.dimensions;
if (isInifinity(data.get(dims[0], idx))) {
point[0] = xAxis.toGlobalCoord(xAxis.getExtent()[isFrom ? 0 : 1]);
} else if (isInifinity(data.get(dims[1], idx))) {
point[1] = yAxis.toGlobalCoord(yAxis.getExtent()[isFrom ? 0 : 1]);
}
} // Use x, y if has any
if (!isNaN(xPx)) {
point[0] = xPx;
}
if (!isNaN(yPx)) {
point[1] = yPx;
}
}
data.setItemLayout(idx, point);
}
var MarkLineView =
/** @class */
function (_super) {
__extends(MarkLineView, _super);
function MarkLineView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkLineView.type;
return _this;
}
MarkLineView.prototype.updateTransform = function (markLineModel, ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
var mlModel = MarkerModel.getMarkerModelFromSeries(seriesModel, 'markLine');
if (mlModel) {
var mlData_1 = mlModel.getData();
var fromData_1 = inner(mlModel).from;
var toData_1 = inner(mlModel).to; // Update visual and layout of from symbol and to symbol
fromData_1.each(function (idx) {
updateSingleMarkerEndLayout(fromData_1, idx, true, seriesModel, api);
updateSingleMarkerEndLayout(toData_1, idx, false, seriesModel, api);
}); // Update layout of line
mlData_1.each(function (idx) {
mlData_1.setItemLayout(idx, [fromData_1.getItemLayout(idx), toData_1.getItemLayout(idx)]);
});
this.markerGroupMap.get(seriesModel.id).updateLayout();
}
}, this);
};
MarkLineView.prototype.renderSeries = function (seriesModel, mlModel, ecModel, api) {
var coordSys = seriesModel.coordinateSystem;
var seriesId = seriesModel.id;
var seriesData = seriesModel.getData();
var lineDrawMap = this.markerGroupMap;
var lineDraw = lineDrawMap.get(seriesId) || lineDrawMap.set(seriesId, new LineDraw());
this.group.add(lineDraw.group);
var mlData = createList(coordSys, seriesModel, mlModel);
var fromData = mlData.from;
var toData = mlData.to;
var lineData = mlData.line;
inner(mlModel).from = fromData;
inner(mlModel).to = toData; // Line data for tooltip and formatter
mlModel.setData(lineData); // TODO
// Functionally, `symbolSize` & `symbolOffset` can also be 2D array now.
// But the related logic and type definition are not finished yet.
// Finish it if required
var symbolType = mlModel.get('symbol');
var symbolSize = mlModel.get('symbolSize');
var symbolRotate = mlModel.get('symbolRotate');
var symbolOffset = mlModel.get('symbolOffset'); // TODO: support callback function like markPoint
if (!isArray(symbolType)) {
symbolType = [symbolType, symbolType];
}
if (!isArray(symbolSize)) {
symbolSize = [symbolSize, symbolSize];
}
if (!isArray(symbolRotate)) {
symbolRotate = [symbolRotate, symbolRotate];
}
if (!isArray(symbolOffset)) {
symbolOffset = [symbolOffset, symbolOffset];
} // Update visual and layout of from symbol and to symbol
mlData.from.each(function (idx) {
updateDataVisualAndLayout(fromData, idx, true);
updateDataVisualAndLayout(toData, idx, false);
}); // Update visual and layout of line
lineData.each(function (idx) {
var lineStyle = lineData.getItemModel(idx).getModel('lineStyle').getLineStyle(); // lineData.setItemVisual(idx, {
// color: lineColor || fromData.getItemVisual(idx, 'color')
// });
lineData.setItemLayout(idx, [fromData.getItemLayout(idx), toData.getItemLayout(idx)]);
if (lineStyle.stroke == null) {
lineStyle.stroke = fromData.getItemVisual(idx, 'style').fill;
}
lineData.setItemVisual(idx, {
fromSymbolKeepAspect: fromData.getItemVisual(idx, 'symbolKeepAspect'),
fromSymbolOffset: fromData.getItemVisual(idx, 'symbolOffset'),
fromSymbolRotate: fromData.getItemVisual(idx, 'symbolRotate'),
fromSymbolSize: fromData.getItemVisual(idx, 'symbolSize'),
fromSymbol: fromData.getItemVisual(idx, 'symbol'),
toSymbolKeepAspect: toData.getItemVisual(idx, 'symbolKeepAspect'),
toSymbolOffset: toData.getItemVisual(idx, 'symbolOffset'),
toSymbolRotate: toData.getItemVisual(idx, 'symbolRotate'),
toSymbolSize: toData.getItemVisual(idx, 'symbolSize'),
toSymbol: toData.getItemVisual(idx, 'symbol'),
style: lineStyle
});
});
lineDraw.updateData(lineData); // Set host model for tooltip
// FIXME
mlData.line.eachItemGraphicEl(function (el) {
getECData(el).dataModel = mlModel;
el.traverse(function (child) {
getECData(child).dataModel = mlModel;
});
});
function updateDataVisualAndLayout(data, idx, isFrom) {
var itemModel = data.getItemModel(idx);
updateSingleMarkerEndLayout(data, idx, isFrom, seriesModel, api);
var style = itemModel.getModel('itemStyle').getItemStyle();
if (style.fill == null) {
style.fill = getVisualFromData(seriesData, 'color');
}
data.setItemVisual(idx, {
symbolKeepAspect: itemModel.get('symbolKeepAspect'),
// `0` should be considered as a valid value, so use `retrieve2` instead of `||`
symbolOffset: retrieve2(itemModel.get('symbolOffset', true), symbolOffset[isFrom ? 0 : 1]),
symbolRotate: retrieve2(itemModel.get('symbolRotate', true), symbolRotate[isFrom ? 0 : 1]),
// TODO: when 2d array is supported, it should ignore parent
symbolSize: retrieve2(itemModel.get('symbolSize'), symbolSize[isFrom ? 0 : 1]),
symbol: retrieve2(itemModel.get('symbol', true), symbolType[isFrom ? 0 : 1]),
style: style
});
}
this.markKeep(lineDraw);
lineDraw.group.silent = mlModel.get('silent') || seriesModel.get('silent');
};
MarkLineView.type = 'markLine';
return MarkLineView;
}(MarkerView);
function createList(coordSys, seriesModel, mlModel) {
var coordDimsInfos;
if (coordSys) {
coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) {
var info = seriesModel.getData().getDimensionInfo(seriesModel.getData().mapDimension(coordDim)) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
return extend(extend({}, info), {
name: coordDim,
// DON'T use ordinalMeta to parse and collect ordinal.
ordinalMeta: null
});
});
} else {
coordDimsInfos = [{
name: 'value',
type: 'float'
}];
}
var fromData = new SeriesData(coordDimsInfos, mlModel);
var toData = new SeriesData(coordDimsInfos, mlModel); // No dimensions
var lineData = new SeriesData([], mlModel);
var optData = map(mlModel.get('data'), curry(markLineTransform, seriesModel, coordSys, mlModel));
if (coordSys) {
optData = filter(optData, curry(markLineFilter, coordSys));
}
var dimValueGetter = markerHelper.createMarkerDimValueGetter(!!coordSys, coordDimsInfos);
fromData.initData(map(optData, function (item) {
return item[0];
}), null, dimValueGetter);
toData.initData(map(optData, function (item) {
return item[1];
}), null, dimValueGetter);
lineData.initData(map(optData, function (item) {
return item[2];
}));
lineData.hasItemOption = true;
return {
from: fromData,
to: toData,
line: lineData
};
}
export default MarkLineView;

View File

@@ -0,0 +1,90 @@
/*
* 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 MarkerModel from './MarkerModel.js';
var MarkPointModel =
/** @class */
function (_super) {
__extends(MarkPointModel, _super);
function MarkPointModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkPointModel.type;
return _this;
}
MarkPointModel.prototype.createMarkerModelFromSeries = function (markerOpt, masterMarkerModel, ecModel) {
return new MarkPointModel(markerOpt, masterMarkerModel, ecModel);
};
MarkPointModel.type = 'markPoint';
MarkPointModel.defaultOption = {
// zlevel: 0,
z: 5,
symbol: 'pin',
symbolSize: 50,
//symbolRotate: 0,
//symbolOffset: [0, 0]
tooltip: {
trigger: 'item'
},
label: {
show: true,
position: 'inside'
},
itemStyle: {
borderWidth: 2
},
emphasis: {
label: {
show: true
}
}
};
return MarkPointModel;
}(MarkerModel);
export default MarkPointModel;

View File

@@ -0,0 +1,217 @@
/*
* 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 '../../chart/helper/SymbolDraw.js';
import * as numberUtil from '../../util/number.js';
import SeriesData from '../../data/SeriesData.js';
import * as markerHelper from './markerHelper.js';
import MarkerView from './MarkerView.js';
import MarkerModel from './MarkerModel.js';
import { isFunction, map, filter, curry, extend } from 'zrender/lib/core/util.js';
import { getECData } from '../../util/innerStore.js';
import { getVisualFromData } from '../../visual/helper.js';
function updateMarkerLayout(mpData, seriesModel, api) {
var coordSys = seriesModel.coordinateSystem;
mpData.each(function (idx) {
var itemModel = mpData.getItemModel(idx);
var point;
var xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
var yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
if (!isNaN(xPx) && !isNaN(yPx)) {
point = [xPx, yPx];
} // Chart like bar may have there own marker positioning logic
else if (seriesModel.getMarkerPosition) {
// Use the getMarkerPoisition
point = seriesModel.getMarkerPosition(mpData.getValues(mpData.dimensions, idx));
} else if (coordSys) {
var x = mpData.get(coordSys.dimensions[0], idx);
var y = mpData.get(coordSys.dimensions[1], idx);
point = coordSys.dataToPoint([x, y]);
} // Use x, y if has any
if (!isNaN(xPx)) {
point[0] = xPx;
}
if (!isNaN(yPx)) {
point[1] = yPx;
}
mpData.setItemLayout(idx, point);
});
}
var MarkPointView =
/** @class */
function (_super) {
__extends(MarkPointView, _super);
function MarkPointView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkPointView.type;
return _this;
}
MarkPointView.prototype.updateTransform = function (markPointModel, ecModel, api) {
ecModel.eachSeries(function (seriesModel) {
var mpModel = MarkerModel.getMarkerModelFromSeries(seriesModel, 'markPoint');
if (mpModel) {
updateMarkerLayout(mpModel.getData(), seriesModel, api);
this.markerGroupMap.get(seriesModel.id).updateLayout();
}
}, this);
};
MarkPointView.prototype.renderSeries = function (seriesModel, mpModel, ecModel, api) {
var coordSys = seriesModel.coordinateSystem;
var seriesId = seriesModel.id;
var seriesData = seriesModel.getData();
var symbolDrawMap = this.markerGroupMap;
var symbolDraw = symbolDrawMap.get(seriesId) || symbolDrawMap.set(seriesId, new SymbolDraw());
var mpData = createData(coordSys, seriesModel, mpModel); // FIXME
mpModel.setData(mpData);
updateMarkerLayout(mpModel.getData(), seriesModel, api);
mpData.each(function (idx) {
var itemModel = mpData.getItemModel(idx);
var symbol = itemModel.getShallow('symbol');
var symbolSize = itemModel.getShallow('symbolSize');
var symbolRotate = itemModel.getShallow('symbolRotate');
var symbolOffset = itemModel.getShallow('symbolOffset');
var symbolKeepAspect = itemModel.getShallow('symbolKeepAspect'); // TODO: refactor needed: single data item should not support callback function
if (isFunction(symbol) || isFunction(symbolSize) || isFunction(symbolRotate) || isFunction(symbolOffset)) {
var rawIdx = mpModel.getRawValue(idx);
var dataParams = mpModel.getDataParams(idx);
if (isFunction(symbol)) {
symbol = symbol(rawIdx, dataParams);
}
if (isFunction(symbolSize)) {
// FIXME 这里不兼容 ECharts 2.x2.x 貌似参数是整个数据?
symbolSize = symbolSize(rawIdx, dataParams);
}
if (isFunction(symbolRotate)) {
symbolRotate = symbolRotate(rawIdx, dataParams);
}
if (isFunction(symbolOffset)) {
symbolOffset = symbolOffset(rawIdx, dataParams);
}
}
var style = itemModel.getModel('itemStyle').getItemStyle();
var color = getVisualFromData(seriesData, 'color');
if (!style.fill) {
style.fill = color;
}
mpData.setItemVisual(idx, {
symbol: symbol,
symbolSize: symbolSize,
symbolRotate: symbolRotate,
symbolOffset: symbolOffset,
symbolKeepAspect: symbolKeepAspect,
style: style
});
}); // TODO Text are wrong
symbolDraw.updateData(mpData);
this.group.add(symbolDraw.group); // Set host model for tooltip
// FIXME
mpData.eachItemGraphicEl(function (el) {
el.traverse(function (child) {
getECData(child).dataModel = mpModel;
});
});
this.markKeep(symbolDraw);
symbolDraw.group.silent = mpModel.get('silent') || seriesModel.get('silent');
};
MarkPointView.type = 'markPoint';
return MarkPointView;
}(MarkerView);
function createData(coordSys, seriesModel, mpModel) {
var coordDimsInfos;
if (coordSys) {
coordDimsInfos = map(coordSys && coordSys.dimensions, function (coordDim) {
var info = seriesModel.getData().getDimensionInfo(seriesModel.getData().mapDimension(coordDim)) || {}; // In map series data don't have lng and lat dimension. Fallback to same with coordSys
return extend(extend({}, info), {
name: coordDim,
// DON'T use ordinalMeta to parse and collect ordinal.
ordinalMeta: null
});
});
} else {
coordDimsInfos = [{
name: 'value',
type: 'float'
}];
}
var mpData = new SeriesData(coordDimsInfos, mpModel);
var dataOpt = map(mpModel.get('data'), curry(markerHelper.dataTransform, seriesModel));
if (coordSys) {
dataOpt = filter(dataOpt, curry(markerHelper.dataFilter, coordSys));
}
var dimValueGetter = markerHelper.createMarkerDimValueGetter(!!coordSys, coordDimsInfos);
mpData.initData(dataOpt, null, dimValueGetter);
return mpData;
}
export default MarkPointView;

View File

@@ -0,0 +1,193 @@
/*
* 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 * as zrUtil from 'zrender/lib/core/util.js';
import env from 'zrender/lib/core/env.js';
import { DataFormatMixin } from '../../model/mixin/dataFormat.js';
import ComponentModel from '../../model/Component.js';
import { makeInner, defaultEmphasis } from '../../util/model.js';
import { createTooltipMarkup } from '../tooltip/tooltipMarkup.js';
function fillLabel(opt) {
defaultEmphasis(opt, 'label', ['show']);
} // { [componentType]: MarkerModel }
var inner = makeInner();
var MarkerModel =
/** @class */
function (_super) {
__extends(MarkerModel, _super);
function MarkerModel() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkerModel.type;
/**
* If marker model is created by self from series
*/
_this.createdBySelf = false;
return _this;
}
/**
* @overrite
*/
MarkerModel.prototype.init = function (option, parentModel, ecModel) {
if (process.env.NODE_ENV !== 'production') {
if (this.type === 'marker') {
throw new Error('Marker component is abstract component. Use markLine, markPoint, markArea instead.');
}
}
this.mergeDefaultAndTheme(option, ecModel);
this._mergeOption(option, ecModel, false, true);
};
MarkerModel.prototype.isAnimationEnabled = function () {
if (env.node) {
return false;
}
var hostSeries = this.__hostSeries;
return this.getShallow('animation') && hostSeries && hostSeries.isAnimationEnabled();
};
/**
* @overrite
*/
MarkerModel.prototype.mergeOption = function (newOpt, ecModel) {
this._mergeOption(newOpt, ecModel, false, false);
};
MarkerModel.prototype._mergeOption = function (newOpt, ecModel, createdBySelf, isInit) {
var componentType = this.mainType;
if (!createdBySelf) {
ecModel.eachSeries(function (seriesModel) {
// mainType can be markPoint, markLine, markArea
var markerOpt = seriesModel.get(this.mainType, true);
var markerModel = inner(seriesModel)[componentType];
if (!markerOpt || !markerOpt.data) {
inner(seriesModel)[componentType] = null;
return;
}
if (!markerModel) {
if (isInit) {
// Default label emphasis `position` and `show`
fillLabel(markerOpt);
}
zrUtil.each(markerOpt.data, function (item) {
// FIXME Overwrite fillLabel method ?
if (item instanceof Array) {
fillLabel(item[0]);
fillLabel(item[1]);
} else {
fillLabel(item);
}
});
markerModel = this.createMarkerModelFromSeries(markerOpt, this, ecModel); // markerModel = new ImplementedMarkerModel(
// markerOpt, this, ecModel
// );
zrUtil.extend(markerModel, {
mainType: this.mainType,
// Use the same series index and name
seriesIndex: seriesModel.seriesIndex,
name: seriesModel.name,
createdBySelf: true
});
markerModel.__hostSeries = seriesModel;
} else {
markerModel._mergeOption(markerOpt, ecModel, true);
}
inner(seriesModel)[componentType] = markerModel;
}, this);
}
};
MarkerModel.prototype.formatTooltip = function (dataIndex, multipleSeries, dataType) {
var data = this.getData();
var value = this.getRawValue(dataIndex);
var itemName = data.getName(dataIndex);
return createTooltipMarkup('section', {
header: this.name,
blocks: [createTooltipMarkup('nameValue', {
name: itemName,
value: value,
noName: !itemName,
noValue: value == null
})]
});
};
MarkerModel.prototype.getData = function () {
return this._data;
};
MarkerModel.prototype.setData = function (data) {
this._data = data;
};
MarkerModel.getMarkerModelFromSeries = function (seriesModel, // Support three types of markers. Strict check.
componentType) {
return inner(seriesModel)[componentType];
};
MarkerModel.type = 'marker';
MarkerModel.dependencies = ['series', 'grid', 'polar', 'geo'];
return MarkerModel;
}(ComponentModel);
zrUtil.mixin(MarkerModel, DataFormatMixin.prototype);
export default MarkerModel;

View File

@@ -0,0 +1,109 @@
/*
* 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 { createHashMap, each } from 'zrender/lib/core/util.js';
import MarkerModel from './MarkerModel.js';
import { makeInner } from '../../util/model.js';
import { enterBlur, leaveBlur } from '../../util/states.js';
var inner = makeInner();
var MarkerView =
/** @class */
function (_super) {
__extends(MarkerView, _super);
function MarkerView() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.type = MarkerView.type;
return _this;
}
MarkerView.prototype.init = function () {
this.markerGroupMap = createHashMap();
};
MarkerView.prototype.render = function (markerModel, ecModel, api) {
var _this = this;
var markerGroupMap = this.markerGroupMap;
markerGroupMap.each(function (item) {
inner(item).keep = false;
});
ecModel.eachSeries(function (seriesModel) {
var markerModel = MarkerModel.getMarkerModelFromSeries(seriesModel, _this.type);
markerModel && _this.renderSeries(seriesModel, markerModel, ecModel, api);
});
markerGroupMap.each(function (item) {
!inner(item).keep && _this.group.remove(item.group);
});
};
MarkerView.prototype.markKeep = function (drawGroup) {
inner(drawGroup).keep = true;
};
MarkerView.prototype.toggleBlurSeries = function (seriesModelList, isBlur) {
var _this = this;
each(seriesModelList, function (seriesModel) {
var markerModel = MarkerModel.getMarkerModelFromSeries(seriesModel, _this.type);
if (markerModel) {
var data = markerModel.getData();
data.eachItemGraphicEl(function (el) {
if (el) {
isBlur ? enterBlur(el) : leaveBlur(el);
}
});
}
});
};
MarkerView.type = 'marker';
return MarkerView;
}(ComponentView);
export default MarkerView;

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 { isArray } from 'zrender/lib/core/util.js';
export default function checkMarkerInSeries(seriesOpts, markerType) {
if (!seriesOpts) {
return false;
}
var seriesOptArr = isArray(seriesOpts) ? seriesOpts : [seriesOpts];
for (var idx = 0; idx < seriesOptArr.length; idx++) {
if (seriesOptArr[idx] && seriesOptArr[idx][markerType]) {
return true;
}
}
return false;
}

View File

@@ -0,0 +1,56 @@
/*
* 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 checkMarkerInSeries from './checkMarkerInSeries.js';
import MarkAreaModel from './MarkAreaModel.js';
import MarkAreaView from './MarkAreaView.js';
export function install(registers) {
registers.registerComponentModel(MarkAreaModel);
registers.registerComponentView(MarkAreaView);
registers.registerPreprocessor(function (opt) {
if (checkMarkerInSeries(opt.series, 'markArea')) {
// Make sure markArea component is enabled
opt.markArea = opt.markArea || {};
}
});
}

View File

@@ -0,0 +1,38 @@
/*
* 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.
*/
import checkMarkerInSeries from './checkMarkerInSeries.js';
import MarkLineModel from './MarkLineModel.js';
import MarkLineView from './MarkLineView.js';
export function install(registers) {
registers.registerComponentModel(MarkLineModel);
registers.registerComponentView(MarkLineView);
registers.registerPreprocessor(function (opt) {
if (checkMarkerInSeries(opt.series, 'markLine')) {
// Make sure markLine component is enabled
opt.markLine = opt.markLine || {};
}
});
}

View File

@@ -0,0 +1,38 @@
/*
* 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.
*/
import checkMarkerInSeries from './checkMarkerInSeries.js';
import MarkPointModel from './MarkPointModel.js';
import MarkPointView from './MarkPointView.js';
export function install(registers) {
registers.registerComponentModel(MarkPointModel);
registers.registerComponentView(MarkPointView);
registers.registerPreprocessor(function (opt) {
if (checkMarkerInSeries(opt.series, 'markPoint')) {
// Make sure markPoint component is enabled
opt.markPoint = opt.markPoint || {};
}
});
}

View File

@@ -0,0 +1,194 @@
/*
* 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 numberUtil from '../../util/number.js';
import { isDimensionStacked } from '../../data/helper/dataStackHelper.js';
import { indexOf, curry, clone, isArray } from 'zrender/lib/core/util.js';
import { parseDataValue } from '../../data/helper/dataValueHelper.js';
function hasXOrY(item) {
return !(isNaN(parseFloat(item.x)) && isNaN(parseFloat(item.y)));
}
function hasXAndY(item) {
return !isNaN(parseFloat(item.x)) && !isNaN(parseFloat(item.y));
}
function markerTypeCalculatorWithExtent(markerType, data, otherDataDim, targetDataDim, otherCoordIndex, targetCoordIndex) {
var coordArr = [];
var stacked = isDimensionStacked(data, targetDataDim
/*, otherDataDim*/
);
var calcDataDim = stacked ? data.getCalculationInfo('stackResultDimension') : targetDataDim;
var value = numCalculate(data, calcDataDim, markerType);
var dataIndex = data.indicesOfNearest(calcDataDim, value)[0];
coordArr[otherCoordIndex] = data.get(otherDataDim, dataIndex);
coordArr[targetCoordIndex] = data.get(calcDataDim, dataIndex);
var coordArrValue = data.get(targetDataDim, dataIndex); // Make it simple, do not visit all stacked value to count precision.
var precision = numberUtil.getPrecision(data.get(targetDataDim, dataIndex));
precision = Math.min(precision, 20);
if (precision >= 0) {
coordArr[targetCoordIndex] = +coordArr[targetCoordIndex].toFixed(precision);
}
return [coordArr, coordArrValue];
} // TODO Specified percent
var markerTypeCalculator = {
min: curry(markerTypeCalculatorWithExtent, 'min'),
max: curry(markerTypeCalculatorWithExtent, 'max'),
average: curry(markerTypeCalculatorWithExtent, 'average'),
median: curry(markerTypeCalculatorWithExtent, 'median')
};
/**
* Transform markPoint data item to format used in List by do the following
* 1. Calculate statistic like `max`, `min`, `average`
* 2. Convert `item.xAxis`, `item.yAxis` to `item.coord` array
*/
export function dataTransform(seriesModel, item) {
var data = seriesModel.getData();
var coordSys = seriesModel.coordinateSystem; // 1. If not specify the position with pixel directly
// 2. If `coord` is not a data array. Which uses `xAxis`,
// `yAxis` to specify the coord on each dimension
// parseFloat first because item.x and item.y can be percent string like '20%'
if (item && !hasXAndY(item) && !isArray(item.coord) && coordSys) {
var dims = coordSys.dimensions;
var axisInfo = getAxisInfo(item, data, coordSys, seriesModel); // Clone the option
// Transform the properties xAxis, yAxis, radiusAxis, angleAxis, geoCoord to value
item = clone(item);
if (item.type && markerTypeCalculator[item.type] && axisInfo.baseAxis && axisInfo.valueAxis) {
var otherCoordIndex = indexOf(dims, axisInfo.baseAxis.dim);
var targetCoordIndex = indexOf(dims, axisInfo.valueAxis.dim);
var coordInfo = markerTypeCalculator[item.type](data, axisInfo.baseDataDim, axisInfo.valueDataDim, otherCoordIndex, targetCoordIndex);
item.coord = coordInfo[0]; // Force to use the value of calculated value.
// let item use the value without stack.
item.value = coordInfo[1];
} else {
// FIXME Only has one of xAxis and yAxis.
var coord = [item.xAxis != null ? item.xAxis : item.radiusAxis, item.yAxis != null ? item.yAxis : item.angleAxis]; // Each coord support max, min, average
for (var i = 0; i < 2; i++) {
if (markerTypeCalculator[coord[i]]) {
coord[i] = numCalculate(data, data.mapDimension(dims[i]), coord[i]);
}
}
item.coord = coord;
}
}
return item;
}
export function getAxisInfo(item, data, coordSys, seriesModel) {
var ret = {};
if (item.valueIndex != null || item.valueDim != null) {
ret.valueDataDim = item.valueIndex != null ? data.getDimension(item.valueIndex) : item.valueDim;
ret.valueAxis = coordSys.getAxis(dataDimToCoordDim(seriesModel, ret.valueDataDim));
ret.baseAxis = coordSys.getOtherAxis(ret.valueAxis);
ret.baseDataDim = data.mapDimension(ret.baseAxis.dim);
} else {
ret.baseAxis = seriesModel.getBaseAxis();
ret.valueAxis = coordSys.getOtherAxis(ret.baseAxis);
ret.baseDataDim = data.mapDimension(ret.baseAxis.dim);
ret.valueDataDim = data.mapDimension(ret.valueAxis.dim);
}
return ret;
}
function dataDimToCoordDim(seriesModel, dataDim) {
var dimItem = seriesModel.getData().getDimensionInfo(dataDim);
return dimItem && dimItem.coordDim;
}
/**
* Filter data which is out of coordinateSystem range
* [dataFilter description]
*/
export function dataFilter( // Currently only polar and cartesian has containData.
coordSys, item) {
// Alwalys return true if there is no coordSys
return coordSys && coordSys.containData && item.coord && !hasXOrY(item) ? coordSys.containData(item.coord) : true;
}
export function zoneFilter( // Currently only polar and cartesian has containData.
coordSys, item1, item2) {
// Alwalys return true if there is no coordSys
return coordSys && coordSys.containZone && item1.coord && item2.coord && !hasXOrY(item1) && !hasXOrY(item2) ? coordSys.containZone(item1.coord, item2.coord) : true;
}
export function createMarkerDimValueGetter(inCoordSys, dims) {
return inCoordSys ? function (item, dimName, dataIndex, dimIndex) {
var rawVal = dimIndex < 2 // x, y, radius, angle
? item.coord && item.coord[dimIndex] : item.value;
return parseDataValue(rawVal, dims[dimIndex]);
} : function (item, dimName, dataIndex, dimIndex) {
return parseDataValue(item.value, dims[dimIndex]);
};
}
export function numCalculate(data, valueDataDim, type) {
if (type === 'average') {
var sum_1 = 0;
var count_1 = 0;
data.each(valueDataDim, function (val, idx) {
if (!isNaN(val)) {
sum_1 += val;
count_1++;
}
});
return sum_1 / count_1;
} else if (type === 'median') {
return data.getMedian(valueDataDim);
} else {
// max & min
return data.getDataExtent(valueDataDim)[type === 'max' ? 1 : 0];
}
}