You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by ov...@apache.org on 2024/07/16 09:15:36 UTC
(echarts) branch feat/stock-marker created (now 8c4a2d83b)
This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a change to branch feat/stock-marker
in repository https://gitbox.apache.org/repos/asf/echarts.git
at 8c4a2d83b test(marker): add test case for markline
This branch includes the following new commits:
new ec7d08229 feat(marker): relativeTo
new 8c4a2d83b test(marker): add test case for markline
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
(echarts) 01/02: feat(marker): relativeTo
Posted by ov...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a commit to branch feat/stock-marker
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit ec7d082293f7979b0c137a4fbcadf449c2e4999f
Author: Ovilia <zw...@gmail.com>
AuthorDate: Thu Jul 11 18:28:19 2024 +0800
feat(marker): relativeTo
---
src/component/marker/MarkPointModel.ts | 1 +
src/component/marker/MarkPointView.ts | 22 ++++++++++++++++++++--
src/component/marker/MarkerModel.ts | 1 +
src/component/marker/markerHelper.ts | 2 +-
src/coord/CoordinateSystem.ts | 6 +++++-
src/coord/polar/Polar.ts | 9 ++++++++-
6 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/src/component/marker/MarkPointModel.ts b/src/component/marker/MarkPointModel.ts
index 1b672317c..5fc5c59f4 100644
--- a/src/component/marker/MarkPointModel.ts
+++ b/src/component/marker/MarkPointModel.ts
@@ -43,6 +43,7 @@ export interface MarkPointDataItemOption extends
SymbolOptionMixin<CallbackDataParams>,
MarkerPositionOption {
name: string
+ relativeTo: 'screen' | 'coordinate'
}
export interface MarkPointOption extends MarkerOption,
diff --git a/src/component/marker/MarkPointView.ts b/src/component/marker/MarkPointView.ts
index 3e4499c0d..054c0a5d9 100644
--- a/src/component/marker/MarkPointView.ts
+++ b/src/component/marker/MarkPointView.ts
@@ -41,11 +41,29 @@ function updateMarkerLayout(
api: ExtensionAPI
) {
const coordSys = seriesModel.coordinateSystem;
+ const apiWidth = api.getWidth();
+ const apiHeight = api.getHeight();
+ const coordRect = coordSys.getArea && coordSys.getArea();
+ console.log(coordSys)
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];
}
diff --git a/src/component/marker/MarkerModel.ts b/src/component/marker/MarkerModel.ts
index 28d29a576..9699278c3 100644
--- a/src/component/marker/MarkerModel.ts
+++ b/src/component/marker/MarkerModel.ts
@@ -53,6 +53,7 @@ export interface MarkerPositionOption {
// Absolute position, px or percent string
x?: number | string
y?: number | string
+ relativeTo?: 'screen' | 'coordinate'
/**
* Coord on any coordinate system
diff --git a/src/component/marker/markerHelper.ts b/src/component/marker/markerHelper.ts
index f5e5b7ddf..61acfd4d6 100644
--- a/src/component/marker/markerHelper.ts
+++ b/src/component/marker/markerHelper.ts
@@ -144,7 +144,7 @@ export function dataTransform(
}
}
// x y is provided
- if (item.coord == null || !isArray(dims)) {
+ if ((item.coord == null || !isArray(dims)) && item.relativeTo === 'screen') {
item.coord = [];
}
else {
diff --git a/src/coord/CoordinateSystem.ts b/src/coord/CoordinateSystem.ts
index 8c778ab83..ea17e8a9a 100644
--- a/src/coord/CoordinateSystem.ts
+++ b/src/coord/CoordinateSystem.ts
@@ -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']>(
diff --git a/src/coord/polar/Polar.ts b/src/coord/polar/Polar.ts
index e7b9db6cc..9ff3fb0e4 100644
--- a/src/coord/polar/Polar.ts
+++ b/src/coord/polar/Polar.ts
@@ -25,6 +25,7 @@ import GlobalModel from '../../model/Global';
import { ParsedModelFinder, ParsedModelFinderKnown } from '../../util/model';
import { ScaleDataValue } from '../../util/types';
import ExtensionAPI from '../../core/ExtensionAPI';
+import { BoundingRect } from 'zrender';
export const polarDimensions = ['radius', 'angle'];
@@ -234,7 +235,13 @@ class Polar implements CoordinateSystem, CoordinateSystemMaster {
const r0 = this.r0;
return d2 <= r * r && d2 >= r0 * r0;
- }
+ },
+
+ // As the bounding box
+ x: this.cx - radiusExtent[1],
+ y: this.cy - radiusExtent[1],
+ width: radiusExtent[1] * 2,
+ height: radiusExtent[1] * 2
};
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
(echarts) 02/02: test(marker): add test case for markline
Posted by ov...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ovilia pushed a commit to branch feat/stock-marker
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 8c4a2d83b07143696dd8f9c4fdbbdc1d283503fb
Author: Ovilia <zw...@gmail.com>
AuthorDate: Fri Jul 12 12:01:56 2024 +0800
test(marker): add test case for markline
---
test/markPoint-stock.html | 123 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 123 insertions(+)
diff --git a/test/markPoint-stock.html b/test/markPoint-stock.html
new file mode 100644
index 000000000..e91d9344f
--- /dev/null
+++ b/test/markPoint-stock.html
@@ -0,0 +1,123 @@
+<!DOCTYPE html>
+<!--
+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.
+-->
+
+
+<html>
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <script src="lib/simpleRequire.js"></script>
+ <script src="lib/config.js"></script>
+ <script src="lib/jquery.min.js"></script>
+ <script src="lib/facePrint.js"></script>
+ <script src="lib/testHelper.js"></script>
+ <!-- <script src="ut/lib/canteen.js"></script> -->
+ <link rel="stylesheet" href="lib/reset.css" />
+ </head>
+ <body>
+ <style>
+ </style>
+
+
+
+ <div id="main0"></div>
+
+
+
+
+
+
+ <script>
+ require([
+ 'echarts',
+ // 'map/js/china',
+ // './data/nutrients.json'
+ ], function (echarts) {
+ var option;
+
+ const data = [];
+ let date = new Date('2024-07-11 9:30:00');
+ const endDate = new Date('2024-07-11 15:00:00');
+ let value = 120;
+ for (; date <= endDate;) {
+ if (date < new Date('2024-07-11 11:30:00').getTime()
+ || date > new Date('2024-07-11 13:00:00').getTime()
+ ) {
+ value = value + Math.round((Math.random() - 0.5) * 20);
+ }
+ data.push([
+ date,
+ value
+ ]);
+ date = new Date(date.getTime() + 1000 * 60);
+ }
+
+ option = {
+ xAxis: {
+ type: 'time',
+ axisLabel: {
+ showMinLabel: true,
+ showMaxLabel: true,
+ }
+ },
+ yAxis: {
+ axisLabel: {
+ show: false,
+ },
+ min: 'dataMin',
+ max: 'dataMax'
+ },
+ series: {
+ type: 'line',
+ data,
+ showSymbol: false,
+ markPoint: {
+ data: [{
+ type: 'min',
+ // x: 0,
+ // y: 0,
+ // relativeTo: 'coordinate'
+ }, {
+ type: 'max',
+ x: 0,
+ y: '100%',
+ // relativeTo: 'coordinate'
+ }]
+ }
+ }
+ };
+
+ var chart = testHelper.create(echarts, 'main0', {
+ title: [
+ 'Test Case Description of main0',
+ '(Muliple lines and **emphasis** are supported in description)'
+ ],
+ option: option
+ // height: 300,
+ // buttons: [{text: 'btn-txt', onclick: function () {}}],
+ // recordCanvas: true,
+ });
+ });
+ </script>
+
+
+ </body>
+</html>
+
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org