[echarts] branch enhance-morph updated: feat(ut): support mulitple from/to in setOption transition

2021-06-17 Thread shenyi
This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch enhance-morph
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/enhance-morph by this push:
 new c9f4853  feat(ut): support mulitple from/to in setOption transition
c9f4853 is described below

commit c9f4853aff22bb48b868a75806c013303de1524d
Author: pissang 
AuthorDate: Thu Jun 17 17:24:19 2021 +0800

feat(ut): support mulitple from/to in setOption transition
---
 src/animation/universalTransition.ts | 52 +++-
 src/core/echarts.ts  |  5 ++--
 src/core/lifecycle.ts|  6 ++---
 3 files changed, 38 insertions(+), 25 deletions(-)

diff --git a/src/animation/universalTransition.ts 
b/src/animation/universalTransition.ts
index 1b44203..fa96d2f 100644
--- a/src/animation/universalTransition.ts
+++ b/src/animation/universalTransition.ts
@@ -20,7 +20,7 @@
 // Universal transitions that can animate between any shapes(series) and any 
properties in any amounts.
 
 import SeriesModel from '../model/Series';
-import {createHashMap, each, map, filter, isArray} from 
'zrender/src/core/util';
+import {createHashMap, each, map, filter, isArray, find} from 
'zrender/src/core/util';
 import Element, { ElementAnimateConfig } from 'zrender/src/Element';
 import { applyMorphAnimation, getPathList } from './morphTransitionHelper';
 import Path from 'zrender/src/graphic/Path';
@@ -29,7 +29,12 @@ import { initProps } from '../util/graphic';
 import DataDiffer from '../data/DataDiffer';
 import List from '../data/List';
 import { DimensionLoose, OptionDataItemObject } from '../util/types';
-import { UpdateLifecycleParams, UpdateLifecycleTransitionItem } from 
'../core/lifecycle';
+import {
+UpdateLifecycleParams,
+UpdateLifecycleTransitionItem,
+UpdateLifecycleTransitionSeriesFinder
+} from '../core/lifecycle';
+import { normalizeToArray } from '../util/model';
 
 interface DiffItem {
 data: List
@@ -418,7 +423,7 @@ function findTransitionSeriesBatches(params: 
UpdateLifecycleParams) {
 return updateBatches;
 }
 
-function querySeries(series: SeriesModel[], finder: 
UpdateLifecycleTransitionItem['from']) {
+function querySeries(series: SeriesModel[], finder: 
UpdateLifecycleTransitionSeriesFinder) {
 for (let i = 0; i < series.length; i++) {
 const found = finder.seriesIndex != null && finder.seriesIndex === 
series[i].seriesIndex
 || finder.seriesId != null && finder.seriesId === series[i].id;
@@ -429,16 +434,28 @@ function querySeries(series: SeriesModel[], finder: 
UpdateLifecycleTransitionIte
 }
 
 function transitionSeriesFromOpt(transitionOpt: UpdateLifecycleTransitionItem, 
params: UpdateLifecycleParams) {
-const fromSeriesIdx = querySeries(params.oldSeries, transitionOpt.from);
-const toSeriesIdx = querySeries(params.updatedSeries, transitionOpt.to);
-if (fromSeriesIdx >= 0 && toSeriesIdx >= 0) {
-transitionBetween([{
-data: params.oldData[fromSeriesIdx],
-dim: transitionOpt.from.dimension
-}], [{
-data: params.updatedSeries[toSeriesIdx].getData(),
-dim: transitionOpt.to.dimension
-}]);
+const from: TransitionSeries[] = [];
+const to: TransitionSeries[] = [];
+each(normalizeToArray(transitionOpt.from), finder => {
+const idx = querySeries(params.oldSeries, finder);
+if (idx >= 0) {
+from.push({
+data: params.oldData[idx],
+dim: finder.dimension
+});
+}
+});
+each(normalizeToArray(transitionOpt.to), finder => {
+const idx = querySeries(params.updatedSeries, finder);
+if (idx >= 0) {
+to.push({
+data: params.updatedSeries[idx].getData(),
+dim: finder.dimension
+});
+}
+});
+if (from.length > 0 && to.length > 0) {
+transitionBetween(from, to);
 }
 }
 
@@ -449,12 +466,9 @@ export function installUniversalTransition(registers: 
EChartsExtensionInstallReg
 // Use give transition config if its' give;
 const transitionOpt = params.seriesTransition;
 if (transitionOpt) {
-if (!isArray(transitionOpt)) {
-transitionSeriesFromOpt(transitionOpt, params);
-}
-else {
-each(transitionOpt, opt => transitionSeriesFromOpt(opt, 
params));
-}
+each(normalizeToArray(transitionOpt), opt => {
+transitionSeriesFromOpt(opt, params);
+});
 }
 else {  // Else guess from series based on transition series key.
 const updateBatches = findTransitionSeriesBatches(params);
diff --git a/src/core/echarts.ts b/src/core/echarts.ts
index 6f9351f..cf00d17 100644
--- 

[echarts] branch enhance-morph updated: feat(ut): fix some null access bug.

2021-06-17 Thread shenyi
This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch enhance-morph
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/enhance-morph by this push:
 new 87e58b9  feat(ut): fix some null access bug.
87e58b9 is described below

commit 87e58b9acb2eda867008c9c729083262d40e5fd5
Author: pissang 
AuthorDate: Thu Jun 17 17:03:58 2021 +0800

feat(ut): fix some null access bug.
---
 src/animation/universalTransition.ts | 10 ++
 test/custom-shape-morphing2.html |  2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/animation/universalTransition.ts 
b/src/animation/universalTransition.ts
index 9e6f97c..1b44203 100644
--- a/src/animation/universalTransition.ts
+++ b/src/animation/universalTransition.ts
@@ -92,9 +92,11 @@ function transitionBetween(
 rawFrom: Path, rawTo: Path,
 animationCfg: ElementAnimateConfig
 ) {
-to.animateFrom({
-style: rawFrom.style
-}, animationCfg);
+if (rawFrom || from) {
+to.animateFrom({
+style: (rawFrom || from).style
+}, animationCfg);
+}
 }
 
 function fadeInElement(newEl: Element, newSeries: SeriesModel, newIndex: 
number) {
@@ -152,7 +154,7 @@ function transitionBetween(
 const dimInfo = keyDim && data.getDimensionInfo(keyDim);
 const dimOrdinalMeta = dimInfo && dimInfo.ordinalMeta;
 
-if (keyDim) {
+if (dimInfo) {
 // Get from encode.itemGroupId.
 const key = data.get(dimInfo.name, dataIndex);
 if (dimOrdinalMeta) {
diff --git a/test/custom-shape-morphing2.html b/test/custom-shape-morphing2.html
index 39976d1..8b5d2bc 100644
--- a/test/custom-shape-morphing2.html
+++ b/test/custom-shape-morphing2.html
@@ -397,7 +397,7 @@ under the License.
 encode: {
 x: 'M_TAG',
 y: 'ATA',
-dataGroupId: 'M_TAG',
+itemGroupId: 'M_TAG',
 tooltip: ['M_TAG', 'ATA']
 },
 renderItem: function (params, api) {

-
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org



[echarts] branch enhance-morph updated: feat(ut): keep the original transition working

2021-06-17 Thread shenyi
This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch enhance-morph
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/enhance-morph by this push:
 new feb0656  feat(ut): keep the original transition working
feb0656 is described below

commit feb0656a0e85f83c9995a82d89c844f36b4eb1fb
Author: pissang 
AuthorDate: Thu Jun 17 16:56:46 2021 +0800

feat(ut): keep the original transition working
---
 src/animation/universalTransition.ts | 311 ---
 src/chart/custom/CustomView.ts   |   2 +-
 src/core/echarts.ts  |  49 --
 src/core/lifecycle.ts|  21 +++
 src/model/Series.ts  |  22 +--
 test/custom-shape-morphing3.html |   4 -
 test/universalTransition2.html   |   6 +-
 7 files changed, 246 insertions(+), 169 deletions(-)

diff --git a/src/animation/universalTransition.ts 
b/src/animation/universalTransition.ts
index 600f301..9e6f97c 100644
--- a/src/animation/universalTransition.ts
+++ b/src/animation/universalTransition.ts
@@ -28,20 +28,40 @@ import { EChartsExtensionInstallRegisters } from 
'../extension';
 import { initProps } from '../util/graphic';
 import DataDiffer from '../data/DataDiffer';
 import List from '../data/List';
-import { OptionDataItemObject } from '../util/types';
+import { DimensionLoose, OptionDataItemObject } from '../util/types';
+import { UpdateLifecycleParams, UpdateLifecycleTransitionItem } from 
'../core/lifecycle';
 
 interface DiffItem {
 data: List
+dim: DimensionLoose
 dataIndex: number
 }
-function flattenDataDiffItems(dataList: List[]) {
+interface TransitionSeries {
+data: List
+dim?: DimensionLoose
+}
+
+function getGroupIdDimension(data: List) {
+const dimensions = data.dimensions;
+for (let i = 0; i < dimensions.length; i++) {
+const dimInfo = data.getDimensionInfo(dimensions[i]);
+if (dimInfo && dimInfo.otherDims.itemGroupId === 0) {
+return dimensions[i];
+}
+}
+}
+
+function flattenDataDiffItems(list: TransitionSeries[]) {
 const items: DiffItem[] = [];
 
-each(dataList, data => {
+each(list, seriesInfo => {
+const data = seriesInfo.data;
 const indices = data.getIndices();
+const groupDim = getGroupIdDimension(data);
 for (let dataIndex = 0; dataIndex < indices.length; dataIndex++) {
 items.push({
 data,
+dim: seriesInfo.dim || groupDim,
 dataIndex
 });
 }
@@ -50,20 +70,13 @@ function flattenDataDiffItems(dataList: List[]) {
 return items;
 }
 
-function transitionBetweenData(
-oldDataList: List[],
-newDataList: List[]
+function transitionBetween(
+oldList: TransitionSeries[],
+newList: TransitionSeries[]
 ) {
 
-const oldDiffItems = flattenDataDiffItems(oldDataList);
-const newDiffItems = flattenDataDiffItems(newDataList);
-// // No data or data are in the same series.
-// if (!oldData || !newData || oldData === newData) {
-// return;
-// }
-
-// const oldSeriesModel = oldData.hostModel;
-// const isTransitionSameSeries = oldSeriesModel === seriesModel;
+const oldDiffItems = flattenDataDiffItems(oldList);
+const newDiffItems = flattenDataDiffItems(newList);
 
 function stopAnimation(el: Element) {
 el.stopAnimation();
@@ -74,22 +87,6 @@ function transitionBetweenData(
 }
 }
 
-// function stopAnimation(pathList: Path[] | Path[][]) {
-// if (isArray(pathList[0])) {
-// for (let i = 0; i < pathList.length; i++) {
-// stopAnimation(pathList[i] as Path[]);
-// }
-// }
-// else {
-// // TODO Group itself should also invoke the callback.
-// // Force finish the leave animation.
-// for (let i = 0; i < pathList.length; i++) {
-// (pathList as Path[])[i].stopAnimation();
-// }
-// }
-// return pathList;
-// }
-
 function updateMorphingPathProps(
 from: Path, to: Path,
 rawFrom: Path, rawTo: Path,
@@ -126,23 +123,17 @@ function transitionBetweenData(
 }
 }
 
-function getGroupIdDimension(data: List) {
-const dimensions = data.dimensions;
-for (let i = 0; i < dimensions.length; i++) {
-const dimInfo = data.getDimensionInfo(dimensions[i]);
-if (dimInfo && dimInfo.otherDims.itemGroupId === 0) {
-return dimensions[i];
+function findKeyDim(items: DiffItem[]) {
+for (let i = 0; i < items.length; i++) {
+if (items[i].dim) {
+return items[i].dim;
 }
 }
 }
+const oldKeyDim = findKeyDim(oldDiffItems);
+const newKeyDim = findKeyDim(newDiffItems);
 
-
-// TODO Query from all data.
-const 

[echarts-bar-racing] branch master updated: update chart according to table

2021-06-17 Thread ovilia
This is an automated email from the ASF dual-hosted git repository.

ovilia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-bar-racing.git


The following commit(s) were added to refs/heads/master by this push:
 new 6e0fd69  update chart according to table
6e0fd69 is described below

commit 6e0fd693c586dc378a063dbec8e2dbd6dd756125
Author: Ovilia 
AuthorDate: Thu Jun 17 16:46:34 2021 +0800

update chart according to table
---
 src/components/BBody.vue  | 21 ---
 src/components/BChart.vue | 53 +--
 2 files changed, 60 insertions(+), 14 deletions(-)

diff --git a/src/components/BBody.vue b/src/components/BBody.vue
index 498a897..5972da0 100644
--- a/src/components/BBody.vue
+++ b/src/components/BBody.vue
@@ -27,13 +27,25 @@
 
 
 
+
+显示排名上限
+
+
+
 
 
 
@@ -52,6 +64,8 @@
 
 
 
@@ -68,8 +82,9 @@ export default defineComponent({
 data() {
 return {
 title: '汽车销量',
-maxDataCnt: 10,
-chartData: null
+maxDataCnt: null,
+chartData: null,
+animationDuration: 5000
 }
 },
 components: {
diff --git a/src/components/BChart.vue b/src/components/BChart.vue
index 97dc9db..fc55c9f 100644
--- a/src/components/BChart.vue
+++ b/src/components/BChart.vue
@@ -1,7 +1,7 @@
 
 
 
-预览{{title}}
+预览
 
 
 
@@ -18,6 +18,17 @@
 import {defineComponent} from 'vue';
 import * as echarts from 'echarts';
 
+const colorAll = [
+'#5470c6',
+'#91cc75',
+'#fac858',
+'#ee',
+'#73c0de',
+'#3ba272',
+'#fc8452',
+'#9a60b4',
+'#ea7ccc'
+];
 const headerLength = 2;
 let chart: echarts.ECharts;
 
@@ -25,7 +36,9 @@ export default defineComponent({
 name: 'BChart',
 props: {
 title: String,
-chartData: Array
+chartData: Array,
+maxDataCnt: Number,
+animationDuration: Number
 },
 data() {
 return {
@@ -38,25 +51,31 @@ export default defineComponent({
 }
 },
 mounted() {
-chart = echarts.init(this.$refs.chart as HTMLElement);
 },
 methods: {
 run() {
-if (!chart) {
-return;
+this.clearTimeoutHandlers();
+if (chart) {
+chart.dispose();
 }
+
+chart = echarts.init(this.$refs.chart as HTMLElement);
+const animationDuration = this.animationDuration || 5000;
+
 const option = {
 dataset: {
 source: this.chartData
 },
 xAxis: {
-type: 'value'
+type: 'value',
+max: 'dataMax'
 },
 yAxis: {
 type: 'category',
 inverse: true,
 animationDuration: 300,
-animationDurationUpdate: 300
+animationDurationUpdate: 300,
+max: this.maxDataCnt ? this.maxDataCnt - 1 : null
 },
 series: [{
 id: 'bar',
@@ -68,13 +87,25 @@ export default defineComponent({
 realtimeSort: true,
 label: {
 show: true,
-position: 'right'
+position: 'right',
+valueAnimation: true
+},
+itemStyle: {
+color: param => {
+return param.data[1] || colorAll[param.dataIndex % 
colorAll.length];
+}
 }
 }],
 grid: {
 right: 60
 },
-animationDurationUpdate: 5000,
+title: {
+text: this.title,
+left: 10,
+top: 10
+},
+animationDuration: 0,
+animationDurationUpdate: animationDuration,
 animationEasing: 'linear',
 animationEasingUpdate: 'linear'
 };
@@ -100,7 +131,7 @@ export default defineComponent({
 });
 that.removeTimeoutHandlers(timeout);
 };
-timeout = window.setTimeout(timeoutCb, i * 5000);
+timeout = window.setTimeout(timeoutCb, i * 
animationDuration);
 that.timeoutHandlers.push(timeout);
 })(i);
 

[echarts] branch enhance-morph updated: feat(ut): remove the old transition code in custom series

2021-06-17 Thread shenyi
This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch enhance-morph
in repository https://gitbox.apache.org/repos/asf/echarts.git


The following commit(s) were added to refs/heads/enhance-morph by this push:
 new 3e6297c  feat(ut): remove the old transition code in custom series
3e6297c is described below

commit 3e6297cf5237d75ee85b4f12a177ed0982625261
Author: pissang 
AuthorDate: Thu Jun 17 14:55:42 2021 +0800

feat(ut): remove the old transition code in custom series
---
 src/animation/morphTransitionHelper.ts |  24 ---
 src/chart/custom/CustomSeries.ts   |   2 -
 src/chart/custom/CustomView.ts | 284 -
 src/chart/lines/LinesView.ts   |   2 -
 test/custom-hexbin.html|   8 +-
 test/custom-shape-morphing.html|  13 +-
 test/custom-shape-morphing2.html   |  66 +++-
 7 files changed, 102 insertions(+), 297 deletions(-)

diff --git a/src/animation/morphTransitionHelper.ts 
b/src/animation/morphTransitionHelper.ts
index 1890bfd..285e41c 100644
--- a/src/animation/morphTransitionHelper.ts
+++ b/src/animation/morphTransitionHelper.ts
@@ -215,28 +215,4 @@ export function getPathList(
 }
 });
 return pathList;
-}
-
-
-export function isPath(el: Element): el is Path {
-return el instanceof Path;
-}
-export function isDisplayable(el: Element) : el is Displayable {
-return el instanceof Displayable;
-}
-
-export function copyElement(sourceEl: Element, targetEl: Element) {
-targetEl.copyTransform(sourceEl);
-if (isDisplayable(targetEl) && isDisplayable(sourceEl)) {
-targetEl.setStyle(sourceEl.style);
-targetEl.z = sourceEl.z;
-targetEl.z2 = sourceEl.z2;
-targetEl.zlevel = sourceEl.zlevel;
-targetEl.invisible = sourceEl.invisible;
-targetEl.ignore = sourceEl.ignore;
-
-if (isPath(targetEl) && isPath(sourceEl)) {
-targetEl.setShape(sourceEl.shape);
-}
-}
 }
\ No newline at end of file
diff --git a/src/chart/custom/CustomSeries.ts b/src/chart/custom/CustomSeries.ts
index 9cfd263..5c87a59 100644
--- a/src/chart/custom/CustomSeries.ts
+++ b/src/chart/custom/CustomSeries.ts
@@ -299,8 +299,6 @@ export const customInnerStore = makeInner<{
 // customText: string;
 txConZ2Set: number;
 leaveToProps: ElementProps;
-// Can morph: "morph" specified in option and el is Path.
-morph: boolean;
 option: CustomElementOption;
 userDuring: CustomBaseElementOption['during'];
 }, Element>();
diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts
index f0caaf1..ed88d72 100644
--- a/src/chart/custom/CustomView.ts
+++ b/src/chart/custom/CustomView.ts
@@ -19,14 +19,14 @@
 
 import {
 hasOwn, assert, isString, retrieve2, retrieve3, defaults, each,
-keys, bind, eqNaN, indexOf, curry, filter, map
+keys, bind, eqNaN, indexOf
 } from 'zrender/src/core/util';
 import * as graphicUtil from '../../util/graphic';
 import { setDefaultStateProxy, enableHoverEmphasis } from '../../util/states';
 import * as labelStyleHelper from '../../label/labelStyle';
 import {getDefaultLabel} from '../helper/labelHelper';
 import {getLayoutOnAxis} from '../../layout/barGrid';
-import DataDiffer, { DataDiffMode } from '../../data/DataDiffer';
+import DataDiffer from '../../data/DataDiffer';
 import Model from '../../model/Model';
 import ChartView from '../../view/Chart';
 import {createClipPath} from '../helper/createClipPathFromCoordSys';
@@ -94,13 +94,6 @@ import CustomSeriesModel, {
 PrepareCustomInfo
 } from './CustomSeries';
 import {
-getPathList,
-applyMorphAnimation,
-isPath,
-isDisplayable,
-copyElement
-} from '../../animation/morphTransitionHelper';
-import {
 prepareShapeOrExtraAllPropsFinal,
 prepareShapeOrExtraTransitionFrom,
 prepareStyleTransitionFrom,
@@ -178,6 +171,27 @@ const prepareCustoms: Dictionary = {
 };
 
 
+function isPath(el: Element): el is graphicUtil.Path {
+return el instanceof graphicUtil.Path;
+}
+function isDisplayable(el: Element) : el is Displayable {
+return el instanceof Displayable;
+}
+function copyElement(sourceEl: Element, targetEl: Element) {
+targetEl.copyTransform(sourceEl);
+if (isDisplayable(targetEl) && isDisplayable(sourceEl)) {
+targetEl.setStyle(sourceEl.style);
+targetEl.z = sourceEl.z;
+targetEl.z2 = sourceEl.z2;
+targetEl.zlevel = sourceEl.zlevel;
+targetEl.invisible = sourceEl.invisible;
+targetEl.ignore = sourceEl.ignore;
+
+if (isPath(targetEl) && isPath(sourceEl)) {
+targetEl.setShape(sourceEl.shape);
+}
+}
+}
 export default class CustomChartView extends ChartView {
 
 static type = 'custom';
@@ -202,134 +216,39 @@ export default class CustomChartView extends ChartView {
 group.removeAll();
 }
 
-// By default, merge mode is applied. In