Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions src/component/marker/MarkPointModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export interface MarkPointDataItemOption extends
SymbolOptionMixin<CallbackDataParams>,
MarkerPositionOption {
name: string
relativeTo: 'container' | 'coordinate'
}

export interface MarkPointOption extends MarkerOption,
Expand Down
21 changes: 19 additions & 2 deletions src/component/marker/MarkPointView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,28 @@ function updateMarkerLayout(
api: ExtensionAPI
) {
const coordSys = seriesModel.coordinateSystem;
const apiWidth = api.getWidth();
const apiHeight = api.getHeight();
const coordRect = coordSys.getArea && coordSys.getArea();
mpData.each(function (idx: number) {
const itemModel = mpData.getItemModel<MarkPointDataItemOption>(idx);
const relativeTo = itemModel.get('relativeTo');
const width = relativeTo === 'coordinate'
? coordRect ? coordRect.width : 0
: apiWidth;
const height = relativeTo === 'coordinate'
? coordRect ? coordRect.height : 0
: apiHeight;
const left = relativeTo === 'coordinate'
? coordRect ? coordRect.x : 0
: 0;
const top = relativeTo === 'coordinate'
? coordRect ? coordRect.y : 0
: 0;

let point;
const xPx = numberUtil.parsePercent(itemModel.get('x'), api.getWidth());
const yPx = numberUtil.parsePercent(itemModel.get('y'), api.getHeight());
const xPx = numberUtil.parsePercent(itemModel.get('x'), width) + left;
const yPx = numberUtil.parsePercent(itemModel.get('y'), height) + top;
if (!isNaN(xPx) && !isNaN(yPx)) {
point = [xPx, yPx];
}
Expand Down
1 change: 1 addition & 0 deletions src/component/marker/MarkerModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
// Absolute position, px or percent string
x?: number | string
y?: number | string
relativeTo?: 'container' | 'coordinate'

/**
* Coord on any coordinate system
Expand Down Expand Up @@ -259,7 +260,7 @@
}
}

interface MarkerModel<Opts extends MarkerOption = MarkerOption> extends DataFormatMixin {}

Check warning on line 263 in src/component/marker/MarkerModel.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'Opts' is defined but never used
zrUtil.mixin(MarkerModel, DataFormatMixin.prototype);

export default MarkerModel;
3 changes: 3 additions & 0 deletions src/component/marker/markerHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ export function dataTransform(
// x y is provided
if (item.coord == null || !isArray(dims)) {
item.coord = [];
const baseAxis = seriesModel.getBaseAxis();
const otherAxis = coordSys.getOtherAxis(baseAxis);
item.value = numCalculate(data, data.mapDimension(otherAxis.dim), item.type);
}
else {
// Each coord support max, min, average
Expand Down
6 changes: 5 additions & 1 deletion src/coord/CoordinateSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,11 @@ export interface CoordinateSystemHostModel extends ComponentModel {
* It is used to clip the graphic elements with the contain methods.
*/
export interface CoordinateSystemClipArea {
contain(x: number, y: number): boolean
x: number;
y: number;
width: number;
height: number;
contain(x: number, y: number): boolean;
}

export function isCoordinateSystemType<T extends CoordinateSystem, S = T['type']>(
Expand Down
8 changes: 7 additions & 1 deletion src/coord/polar/Polar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,13 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster {
// minus a tiny value 1e-4 in double side to avoid being clipped unexpectedly
// r == r0 contain nothing
return r !== r0 && (d2 - EPSILON) <= r * r && (d2 + EPSILON) >= r0 * r0;
}
},

// As the bounding box
x: this.cx - radiusExtent[1],
y: this.cy - radiusExtent[1],
width: radiusExtent[1] * 2,
height: radiusExtent[1] * 2
};
}

Expand Down
207 changes: 207 additions & 0 deletions test/markPoint-stock.html

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