You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/06/19 02:29:40 UTC

[incubator-echarts-doc] branch live-example updated: example: restore after example changed

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch live-example
in repository https://gitbox.apache.org/repos/asf/incubator-echarts-doc.git


The following commit(s) were added to refs/heads/live-example by this push:
     new 13cdf5b  example: restore after example changed
13cdf5b is described below

commit 13cdf5b36f4bf579344dcafc5fb6028d382bd67b
Author: pissang <bm...@gmail.com>
AuthorDate: Fri Jun 19 10:29:28 2020 +0800

    example: restore after example changed
---
 src/components/DocContentItemCard.vue | 11 ++++++++---
 src/components/LiveExample.vue        | 37 +++++------------------------------
 src/store.js                          | 29 ++++++++++++++++++++++++++-
 zh/option/partial/mark-area.md        | 12 ++++++++++++
 zh/option/partial/mark-line.md        | 12 ++++++++++++
 zh/option/partial/mark-point.md       | 13 +++++++++++-
 6 files changed, 77 insertions(+), 37 deletions(-)

diff --git a/src/components/DocContentItemCard.vue b/src/components/DocContentItemCard.vue
index 33b275d..7ce4377 100644
--- a/src/components/DocContentItemCard.vue
+++ b/src/components/DocContentItemCard.vue
@@ -98,9 +98,6 @@ export default {
         }
     },
 
-    created() {
-    },
-
     watch: {
         enableUIControl(newVal) {
             if (!newVal) {
@@ -117,6 +114,14 @@ export default {
 
                 this.shared.showOptionExample = true;
             }
+        },
+
+        'shared.currentExampleName'(newVal, oldVal) {
+            // Reset after example changed.
+            // NOTE: it may be the first time example panel is opened. So need to check the old value.
+            if (newVal && oldVal) {
+                this.enableUIControl = false;
+            }
         }
     },
 
diff --git a/src/components/LiveExample.vue b/src/components/LiveExample.vue
index f377fe4..576e648 100644
--- a/src/components/LiveExample.vue
+++ b/src/components/LiveExample.vue
@@ -92,36 +92,10 @@ function diffUpdateCode(oldCode, newCode, cmInstance) {
 
     if (len) {
         setTimeout(() => {
-            // const existsEl = cmInstance.getWrapperElement().querySelector('.option-changed');
-            // if (existsEl) {
-            //     // If the element is near to the view and has been rendered.
-            //     scrollIntoView(existsEl, {
-            //         time: 400,
-            //         align: {
-            //             top: 0,
-            //             topOffset: -50
-            //         }
-            //     });
-            // }
-            // else {
-            if (window.scrollTo) {
-                const {top} = cmInstance.charCoords({line: changedLines[0], ch: 0});
-                const el = cmInstance.getScrollerElement();
-                // Because the
-                // el.style.top = oldTop + 'px';
-                el.scrollTo({
-                    top,
-                    left: 0,
-                    behavior: 'smooth'
-                });
-            }
-            else {
-                cmInstance.scrollIntoView({
-                    line: changedLines[0],
-                    ch: 0
-                }, cmInstance.getWrapperElement().clientHeight - 50);
-            }
-            // }
+            cmInstance.scrollIntoView({
+                line: changedLines[0],
+                ch: 0
+            }, cmInstance.getWrapperElement().clientHeight - 50);
         }, 20);
     }
 
@@ -423,8 +397,7 @@ export default {
 
                 .option-changed {
                     background: rgba(255, 255, 255, 0.1);
-                    border-left: 3px solid #32dde6;
-                    margin-left: -3px;
+                    // border-left: 3px solid #32dde6;
                 }
             }
         }
diff --git a/src/store.js b/src/store.js
index 89dbc1d..6dd52ea 100644
--- a/src/store.js
+++ b/src/store.js
@@ -45,6 +45,32 @@ export function isOptionDoc() {
 
 const componentCanHost = ['markPoint', 'markLine', 'markArea', 'tooltip', 'axisPointer'];
 
+function makeDefaultOption(key) {
+    if (key === 'markPoint') {
+        return {
+            data: [{
+                type: 'max'
+            }]
+        };
+    }
+    else if (key === 'markLine') {
+        return {
+            data: [{
+                type: 'average'
+            }]
+        };
+    }
+    else if (key === 'markArea') {
+        return {
+            data: [ [{
+                type: 'min'
+            }, {
+                type: 'max'
+            }] ]
+        };
+    }
+}
+
 export function changeOption(option, path, value) {
 
     function changeOptionRecursive(obj, pathParts, objKey, nodePath) {
@@ -77,7 +103,8 @@ export function changeOption(option, path, value) {
         // TODO: If prop not exists and it should be an array.
         if (obj[key] == null) {
             const outlineNode = getOutlineNode(nodePath);
-            obj[key] = (outlineNode && outlineNode.isArray) ? [] : {};
+            obj[key] = makeDefaultOption(key) ||
+                ((outlineNode && outlineNode.isArray) ? [] : {});
         }
         const prop = obj[key];
         if (Array.isArray(prop)) {
diff --git a/zh/option/partial/mark-area.md b/zh/option/partial/mark-area.md
index f8f5de7..ce405e0 100644
--- a/zh/option/partial/mark-area.md
+++ b/zh/option/partial/mark-area.md
@@ -124,6 +124,9 @@ data: [
 {{ target: mark-area-data-item-item }}
 {{ if: ${hasType} }}
 #${prefix} type(string)
+
+<ExampleUIControlEnum options="min,max,average" />
+
 特殊的标注类型,用于标注最大值最小值等。
 
 **可选:**
@@ -133,6 +136,9 @@ data: [
 {{ /if }}
 {{ if: ${hasCoord} }}
 #${prefix} valueIndex(number)
+
+<ExampleUIControlNumber min="0" max="1" step="1"  />
+
 在使用 [type](~series-${seriesType}.markArea.data.type) 时有效,用于指定在哪个维度上指定最大值最小值,可以是 `0`(xAxis, radiusAxis),`1`(yAxis, angleAxis),默认使用第一个数值轴所在的维度。
 
 #${prefix} valueDim(string)
@@ -147,9 +153,15 @@ data: [
 标注名称,将会作为文字显示。
 
 #${prefix} x(number)
+
+<ExampleUIControlPercent default="0" />
+
 相对容器的屏幕 x 坐标,单位像素,支持百分比形式,例如 `'20%'`。
 
 #${prefix} y(number)
+
+<ExampleUIControlPercent default="0" />
+
 相对容器的屏幕 y 坐标,单位像素,支持百分比形式,例如 `'20%'`。
 
 #${prefix} value(number)
diff --git a/zh/option/partial/mark-line.md b/zh/option/partial/mark-line.md
index 265ff54..a459cd4 100644
--- a/zh/option/partial/mark-line.md
+++ b/zh/option/partial/mark-line.md
@@ -165,6 +165,9 @@ data: [
 {{ target: mark-line-data-item-item }}
 {{ if: ${hasType} }}
 #${prefix} type(string)
+
+<ExampleUIControlEnum options="min,max,average" />
+
 特殊的标注类型,用于标注最大值最小值等。
 
 **可选:**
@@ -175,6 +178,9 @@ data: [
 {{ /if }}
 {{ if: ${hasCoord} }}
 #${prefix} valueIndex(number)
+
+<ExampleUIControlNumber min="0" max="1" step="1"  />
+
 在使用 [type](~series-${seriesType}.markLine.data.type) 时有效,用于指定在哪个维度上指定最大值最小值,可以是 `0`(xAxis, radiusAxis),`1`(yAxis, angleAxis),默认使用第一个数值轴所在的维度。
 
 #${prefix} valueDim(string)
@@ -191,9 +197,15 @@ data: [
 标注名称,将会作为文字显示。
 
 #${prefix} x(number)
+
+<ExampleUIControlPercent default="0" />
+
 相对容器的屏幕 x 坐标,单位像素。
 
 #${prefix} y(number)
+
+<ExampleUIControlPercent default="0" />
+
 相对容器的屏幕 y 坐标,单位像素。
 
 #${prefix} value(number)
diff --git a/zh/option/partial/mark-point.md b/zh/option/partial/mark-point.md
index 5325a0c..90a9eb3 100644
--- a/zh/option/partial/mark-point.md
+++ b/zh/option/partial/mark-point.md
@@ -76,6 +76,9 @@ data: [{{if: ${hasType} }}
 标注名称。
 {{ if: ${hasType} }}
 ###${prefix} type(string)
+
+<ExampleUIControlEnum options="min,max,average" />
+
 特殊的标注类型,用于标注最大值最小值等。
 
 **可选:**
@@ -85,6 +88,9 @@ data: [{{if: ${hasType} }}
 {{ /if }}
 {{ if: ${hasCoord} }}
 ###${prefix} valueIndex(number)
+
+<ExampleUIControlNumber min="0" max="1" step="1"  />
+
 在使用 [type](~series-${seriesType}.markPoint.data.type) 时有效,用于指定在哪个维度上指定最大值最小值,可以是 `0`(xAxis, radiusAxis),`1`(yAxis, angleAxis),默认使用第一个数值轴所在的维度。
 
 ###${prefix} valueDim(string)
@@ -95,12 +101,17 @@ data: [{{if: ${hasType} }}
 
 {{ use: marker-coord-explain }}
 
-**注:**在 ECharts 2.x 中会使用 `xAxis`,`yAxis` 标注直角坐标系上的位置,ECharts 3 中不再推荐使用。
 {{ /if }}
 ###${prefix} x(number)
+
+<ExampleUIControlPercent default="0" />
+
 相对容器的屏幕 x 坐标,单位像素。
 
 ###${prefix} y(number)
+
+<ExampleUIControlPercent default="0" />
+
 相对容器的屏幕 y 坐标,单位像素。
 
 ###${prefix} value(number)


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