plainheart commented on code in PR #20166:
URL: https://github.com/apache/echarts/pull/20166#discussion_r2032725287
##########
src/component/marker/MarkPointModel.ts:
##########
@@ -43,6 +43,7 @@ export interface MarkPointDataItemOption extends
SymbolOptionMixin<CallbackDataParams>,
MarkerPositionOption {
name: string
+ relativeTo: 'container' | 'coordinate'
Review Comment:
This line can be removed as `MarkPointDataItemOption` extends
`MarkerPositionOption`, which has declared the `relativeTo` option.
##########
src/component/marker/MarkPointView.ts:
##########
@@ -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'
Review Comment:
Extract `relativeTo === 'coordinate'` to a boolean constant.
```ts
const isRelativeToCoordinate = itemModel.get('relativeTo') === 'coordinate';
```
##########
src/component/marker/MarkPointView.ts:
##########
@@ -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;
Review Comment:
Can be simplified as
```ts
const top = isRelativeToCoordinate && coordRect ? coordRect.y : 0;
```
`left` & `height` & `width` are similar to this.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]