Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/component/marker/MarkAreaView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,15 @@ const markAreaTransform = function (
maModel: MarkAreaModel,
item: MarkArea2DDataItemOption
): MarkAreaMergedItemOption {
const lt = markerHelper.dataTransform(seriesModel, item[0]);
const rb = markerHelper.dataTransform(seriesModel, item[1]);
// item may be null
const item0 = item[0];
const item1 = item[1];
if (!item0 || !item1) {
return;
}

const lt = markerHelper.dataTransform(seriesModel, item0);
const rb = markerHelper.dataTransform(seriesModel, item1);

// FIXME make sure lt is less than rb
const ltCoord = lt.coord;
Expand Down
29 changes: 19 additions & 10 deletions src/component/marker/markerHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,20 @@ export function dataTransform(
seriesModel: SeriesModel,
item: MarkerPositionOption
) {
if (!item) {
return;
}

const data = seriesModel.getData();
const coordSys = seriesModel.coordinateSystem;
const dims = coordSys.dimensions;

// 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) {
const dims = coordSys.dimensions;
if (!hasXAndY(item) && !isArray(item.coord) && coordSys) {
const axisInfo = getAxisInfo(item, data, coordSys, seriesModel);

// Clone the option
Expand All @@ -130,21 +134,26 @@ export function dataTransform(
// 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.
const coord = [
item.coord = [
item.xAxis != null ? item.xAxis : item.radiusAxis,
item.yAxis != null ? item.yAxis : item.angleAxis
];
// Each coord support max, min, average
for (let i = 0; i < 2; i++) {
if (markerTypeCalculator[coord[i] as MarkerStatisticType]) {
coord[i] = numCalculate(data, data.mapDimension(dims[i]), coord[i] as MarkerStatisticType);
}
}
}
// x y is provided
if (item.coord == null) {
item.coord = [];
Comment thread
plainheart marked this conversation as resolved.
}
else {
// Each coord support max, min, average
const coord = item.coord;
for (let i = 0; i < 2; i++) {
if (markerTypeCalculator[coord[i] as MarkerStatisticType]) {
coord[i] = numCalculate(data, data.mapDimension(dims[i]), coord[i] as MarkerStatisticType);
}
item.coord = coord;
}
}
return item;
Expand Down
157 changes: 139 additions & 18 deletions test/markArea.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.