You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by su...@apache.org on 2021/04/08 09:02:21 UTC
[echarts] branch fix/geo-location created (now f76f6f8)
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a change to branch fix/geo-location
in repository https://gitbox.apache.org/repos/asf/echarts.git.
at f76f6f8 fix: [geo svg] fix labelLayout broken by geo refactor.
This branch includes the following new commits:
new 5ea8147 fix: fix geo center incorrect brought by geo refactor (test case: test/map.html 'main2')
new 710984f fix: [geo svg] add notion for the issue of cut label.
new 7306b7f fix: [map labelLayout] fix hideOverlap work correct in map series.
new f76f6f8 fix: [geo svg] fix labelLayout broken by geo refactor.
The 4 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] 02/04: fix: [geo svg] add notion for the issue of cut
label.
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix/geo-location
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 710984fa29ee649448f4cc0dd8b8b213032cc4af
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Apr 8 13:43:28 2021 +0800
fix: [geo svg] add notion for the issue of cut label.
---
src/coord/geo/GeoSVGResource.ts | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/coord/geo/GeoSVGResource.ts b/src/coord/geo/GeoSVGResource.ts
index 8018f39..e0e6d59 100644
--- a/src/coord/geo/GeoSVGResource.ts
+++ b/src/coord/geo/GeoSVGResource.ts
@@ -236,6 +236,12 @@ export class GeoSVGResource implements GeoResource {
rootFromParse.y = viewBoxTransform.y;
}
+ // SVG needs to clip based on `viewBox`. And some SVG files really rely on this feature.
+ // They do not strictly confine all of the content inside a display rect, but deliberately
+ // use a `viewBox` to define a displayable rect.
+ // PENDING:
+ // The drawback of the `setClipPath` here is: the region label (genereted by echarts) near the
+ // edge might also be clipped, because region labels are put as `textContent` of the SVG path.
root.setClipPath(new Rect({
shape: boundingRect.plain()
}));
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts] 01/04: fix: fix geo center incorrect brought by geo
refactor (test case: test/map.html 'main2')
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix/geo-location
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 5ea81477400e8a588ba158bfe44d573cf3dba61c
Author: 100pah <su...@gmail.com>
AuthorDate: Wed Apr 7 21:10:15 2021 +0800
fix: fix geo center incorrect brought by geo refactor (test case: test/map.html 'main2')
---
src/component/helper/MapDraw.ts | 1 -
src/coord/View.ts | 18 +++++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/src/component/helper/MapDraw.ts b/src/component/helper/MapDraw.ts
index 4d9104f..da88c3e 100644
--- a/src/component/helper/MapDraw.ts
+++ b/src/component/helper/MapDraw.ts
@@ -709,7 +709,6 @@ function resetLabelForRegion(
if (labelXY) {
// Compute a relative offset based on the el bounding rect.
const rect = el.getBoundingRect().clone();
- rect.applyTransform(el.getComputedTransform());
el.textConfig.position = [
((labelXY[0] - rect.x) / rect.width * 100) + '%',
((labelXY[1] - rect.y) / rect.height * 100) + '%'
diff --git a/src/coord/View.ts b/src/coord/View.ts
index f6a68f9..452fb0e 100644
--- a/src/coord/View.ts
+++ b/src/coord/View.ts
@@ -226,14 +226,22 @@ class View extends Transformable implements CoordinateSystemMaster, CoordinateSy
roam: ViewCoordSysTransformInfoPart
raw: ViewCoordSysTransformInfoPart
} {
- const roamTransformable = this._roamTransformable;
const rawTransformable = this._rawTransformable;
+
+ const roamTransformable = this._roamTransformable;
+ // Becuase roamTransformabel has `originX/originY` modified,
+ // but the caller of `getTransformInfo` can not handle `originX/originY`,
+ // so need to recalcualte them.
+ const dummyTransformable = new Transformable();
+ dummyTransformable.transform = roamTransformable.transform;
+ dummyTransformable.decomposeTransform();
+
return {
roam: {
- x: roamTransformable.x,
- y: roamTransformable.y,
- scaleX: roamTransformable.scaleX,
- scaleY: roamTransformable.scaleY
+ x: dummyTransformable.x,
+ y: dummyTransformable.y,
+ scaleX: dummyTransformable.scaleX,
+ scaleY: dummyTransformable.scaleY
},
raw: {
x: rawTransformable.x,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts] 03/04: fix: [map labelLayout] fix hideOverlap work
correct in map series.
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix/geo-location
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 7306b7ff3a11d45add20fae67c8792b3a37c582b
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Apr 8 16:55:53 2021 +0800
fix: [map labelLayout] fix hideOverlap work correct in map series.
---
src/chart/map/MapView.ts | 4 ++
src/component/helper/MapDraw.ts | 29 +++++++----
test/label-layout.html | 92 ++++++++++++++++++++++++++++++++++
test/runTest/actions/__meta__.json | 2 +-
test/runTest/actions/label-layout.json | 2 +-
5 files changed, 118 insertions(+), 11 deletions(-)
diff --git a/src/chart/map/MapView.ts b/src/chart/map/MapView.ts
index b8984c8..1a960d5 100644
--- a/src/chart/map/MapView.ts
+++ b/src/chart/map/MapView.ts
@@ -56,6 +56,10 @@ class MapView extends ChartView {
return;
}
+ if (this._mapDraw && payload && payload.type === 'geoRoam') {
+ this._mapDraw.resetForLabelLayout();
+ }
+
// Not update map if it is an roam action from self
if (!(payload && payload.type === 'geoRoam'
&& payload.componentType === 'series'
diff --git a/src/component/helper/MapDraw.ts b/src/component/helper/MapDraw.ts
index da88c3e..b1e2341 100644
--- a/src/component/helper/MapDraw.ts
+++ b/src/component/helper/MapDraw.ts
@@ -534,15 +534,6 @@ class MapDraw {
roamHelper.updateViewOnZoom(controllerHost, e.scale, e.originX, e.originY);
- // Reset ignore, avoid ignore is changed in LabelManager and can't restored.
- // TODO: roam action in map should not run LabelManager#addLabelsOfSeries
- this.group.traverse(el => {
- const label = el.getTextContent();
- if (label) {
- label.ignore = mapLabelRaw(label).ignore;
- }
- });
-
api.dispatchAction(zrUtil.extend(makeActionBase(), {
zoom: e.scale,
originX: e.originX,
@@ -557,6 +548,26 @@ class MapDraw {
});
}
+ /**
+ * FIXME: this is a temporarily workaround.
+ * When `geoRoam` the elements need to be reset in `MapView['render']`, because the props like
+ * `ignore` might have been modified by `LabelManager`, and `LabelManager#addLabelsOfSeries`
+ * will subsequently cache `defaultAttr` like `ignore`. If do not do this reset, the modified
+ * props will have no chance to be restored.
+ * Note: this reset should be after `clearStates` in `renderSeries` becuase `useStates` in
+ * `renderSeries` will cache the modified `ignore` to `el._normalState`.
+ * TODO:
+ * Use clone/immutable in `LabelManager`?
+ */
+ resetForLabelLayout() {
+ this.group.traverse(el => {
+ const label = el.getTextContent();
+ if (label) {
+ label.ignore = mapLabelRaw(label).ignore;
+ }
+ });
+ }
+
private _updateMapSelectHandler(
mapOrGeoModel: GeoModel | MapSeries,
regionsGroup: RegionsGroup,
diff --git a/test/label-layout.html b/test/label-layout.html
index 6c49908..cf23862 100644
--- a/test/label-layout.html
+++ b/test/label-layout.html
@@ -52,6 +52,8 @@ under the License.
<div id="main9"></div>
<div id="main10"></div>
<div id="main11"></div>
+ <div id="main12"></div>
+ <div id="main13"></div>
@@ -827,6 +829,96 @@ under the License.
});
});
</script>
+
+
+ <script>
+ require(['echarts'/*, 'map/js/china' */], function (echarts) {
+ const svg = [
+ '<?xml version="1.0" encoding="utf-8"?>',
+ '<svg viewBox="-25 0 300 100" xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.2" fill-rule="evenodd" xml:space="preserve">',
+ '<path name="left_rect" d="M 0,0 L 0,100 100,100 100,0 Z" fill="#765" stroke="rgb(56,93,138)" stroke-width="0" stroke-linecap="square" stroke-linejoin="miter"/>',
+ '<path name="right_rect" d="M 150,0 L 150,100 250,100 250,0 Z" fill="#567" stroke="rgb(56,93,138)" stroke-width="0" stroke-linecap="square" stroke-linejoin="miter"/>',
+ '</svg>'
+ ].join('')
+
+ echarts.registerMap('testGeoSVG_coord1', { svg: svg });
+
+ option = {
+ series: [{
+ type: 'map',
+ roam: true,
+ top: 10,
+ bottom: 10,
+ left: 10,
+ right: 10,
+ selectedMode: 'multiple',
+ map: 'testGeoSVG_coord1',
+ select: {
+ itemStyle: {
+ color: 'red'
+ },
+ label: {
+ color: '#fff'
+ }
+ },
+ label: {
+ show: true,
+ fontSize: 30
+ },
+ labelLayout: {
+ hideOverlap: true
+ }
+ }]
+ };
+
+ var chart = testHelper.create(echarts, 'main12', {
+ title: [
+ 'Click both rect make them selected (become red)',
+ '(1) zoom to trigger label **hideOverlap**',
+ 'zoom back, check labels should be restored',
+ '(2) mouseover one the **right rect** and zoom to trigger label **hideOverlap**',
+ 'zoom back, mouseout, check the label should not disappear'
+ ],
+ option: option,
+ height: 200,
+ });
+ });
+ </script>
+
+
+
+ <script>
+ require(['echarts'/*, 'map/js/china' */], function (echarts) {
+ const svg = [
+ '<?xml version="1.0" encoding="utf-8"?>',
+ '<svg xmlns="http://www.w3.org/2000/svg" xmlns:ooo="http://xml.openoffice.org/svg/export" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.2" fill-rule="evenodd" xml:space="preserve">',
+ '<path name="left_rect" d="M 0,0 L 0,100 100,100 100,0 Z" fill="#765" stroke="rgb(56,93,138)" stroke-width="0" stroke-linecap="square" stroke-linejoin="miter"/>',
+ '</svg>'
+ ].join('')
+
+ echarts.registerMap('testGeoSVG_coord2', { svg: svg });
+
+ option = {
+ geo: {
+ map: 'testGeoSVG_coord2',
+ roam: true
+ }
+ };
+
+ var chart = testHelper.create(echarts, 'main13', {
+ title: [
+ '(geo coordSys) label displayed only on hover',
+ 'zoom: label should keep displayed.'
+ ],
+ option: option,
+ height: 200,
+ });
+ });
+ </script>
+
+
+
+
</body>
</html>
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index 69a7a44..4271bd7 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -94,7 +94,7 @@
"hoverStyle": 14,
"hoverStyle2": 1,
"label-animation": 3,
- "label-layout": 2,
+ "label-layout": 4,
"label-position": 1,
"largeLine-tooltip": 1,
"legend": 11,
diff --git a/test/runTest/actions/label-layout.json b/test/runTest/actions/label-layout.json
index a1bd982..dbf8a20 100644
--- a/test/runTest/actions/label-layout.json
+++ b/test/runTest/actions/label-layout.json
@@ -1 +1 @@
-[{"name":"Action 1","ops":[{"type":"mousemove","time":47,"x":689,"y":417},{"type":"mousemove","time":320,"x":689,"y":415},{"type":"mousemove","time":473,"x":689,"y":415},{"type":"mousedown","time":546,"x":689,"y":415},{"type":"mousemove","time":679,"x":682,"y":380},{"type":"mousemove","time":1002,"x":675,"y":339},{"type":"mouseup","time":1054,"x":675,"y":339},{"time":1055,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":1240,"x":674,"y":339},{"type":"mousemove","time":144 [...]
\ No newline at end of file
+[{"name":"Action 1","ops":[{"type":"mousemove","time":47,"x":689,"y":417},{"type":"mousemove","time":320,"x":689,"y":415},{"type":"mousemove","time":473,"x":689,"y":415},{"type":"mousedown","time":546,"x":689,"y":415},{"type":"mousemove","time":679,"x":682,"y":380},{"type":"mousemove","time":1002,"x":675,"y":339},{"type":"mouseup","time":1054,"x":675,"y":339},{"time":1055,"delay":400,"type":"screenshot-auto"},{"type":"mousemove","time":1240,"x":674,"y":339},{"type":"mousemove","time":144 [...]
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
[echarts] 04/04: fix: [geo svg] fix labelLayout broken by geo
refactor.
Posted by su...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
sushuang pushed a commit to branch fix/geo-location
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit f76f6f8cf3878c09a80a6077b8978e1d4e3c6b39
Author: 100pah <su...@gmail.com>
AuthorDate: Thu Apr 8 17:01:19 2021 +0800
fix: [geo svg] fix labelLayout broken by geo refactor.
---
src/component/helper/MapDraw.ts | 4 +++-
src/label/labelStyle.ts | 13 ++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/component/helper/MapDraw.ts b/src/component/helper/MapDraw.ts
index b1e2341..aefc310 100644
--- a/src/component/helper/MapDraw.ts
+++ b/src/component/helper/MapDraw.ts
@@ -38,7 +38,7 @@ import GeoView from '../geo/GeoView';
import MapView from '../../chart/map/MapView';
import Geo from '../../coord/geo/Geo';
import Model from '../../model/Model';
-import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
+import { setLabelStyle, getLabelStatesModels, enableLayoutLayoutFeatures } from '../../label/labelStyle';
import { getECData } from '../../util/innerStore';
import { createOrUpdatePatternFromDecal } from '../../util/decal';
import ZRText, {TextStyleProps} from 'zrender/src/graphic/Text';
@@ -728,6 +728,8 @@ function resetLabelForRegion(
}
}
+ enableLayoutLayoutFeatures(el, dataIdx, null);
+
(el as ECElement).disableLabelAnimation = true;
}
else {
diff --git a/src/label/labelStyle.ts b/src/label/labelStyle.ts
index 713093a..002a77d 100644
--- a/src/label/labelStyle.ts
+++ b/src/label/labelStyle.ts
@@ -30,7 +30,8 @@ import {
ColorString,
ZRStyleProps,
AnimationOptionMixin,
- InterpolatableValue
+ InterpolatableValue,
+ SeriesDataType
} from '../util/types';
import GlobalModel from '../model/Global';
import { isFunction, retrieve2, extend, keys, trim } from 'zrender/src/core/util';
@@ -39,6 +40,7 @@ import { deprecateReplaceLog } from '../util/log';
import { makeInner, interpolateRawValues } from '../util/model';
import List from '../data/List';
import { initProps, updateProps } from '../util/graphic';
+import { getECData } from '../util/innerStore';
type TextCommonParams = {
/**
@@ -727,3 +729,12 @@ export function animateLabelValue(
: updateProps
)(textEl, {}, animatableModel, dataIndex, null, during);
}
+
+export function enableLayoutLayoutFeatures(
+ el: Element,
+ dataIndex: number,
+ dataType: SeriesDataType
+): void {
+ getECData(el).dataIndex = dataIndex;
+ getECData(el).dataType = dataType;
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org