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/29 07:41:23 UTC

[incubator-echarts-doc] branch live-example updated: example: support other languages

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 d93b0fc  example: support other languages
d93b0fc is described below

commit d93b0fc604452a6d87126344ed048de9d5d9fa19
Author: pissang <bm...@gmail.com>
AuthorDate: Mon Jun 29 15:41:09 2020 +0800

    example: support other languages
---
 build.js                              | 61 ++++++++++++++++++++++++++++++++---
 en/option/series/graph.md             |  2 --
 src/components/DocContent.vue         |  2 ++
 src/components/DocContentItemCard.vue |  9 ++++--
 zh/option/component/calendar.md       |  5 ---
 zh/option/component/timeline.md       |  3 --
 zh/option/series/graph.md             |  2 --
 zh/option/series/scatter.md           |  8 ++---
 8 files changed, 68 insertions(+), 24 deletions(-)

diff --git a/build.js b/build.js
index f65cc09..dbce179 100644
--- a/build.js
+++ b/build.js
@@ -253,16 +253,69 @@ function writeSingleSchemaPartioned(schema, language, docName, format) {
     );
     // console.log(chalk.green('generated: ' + outlineDestPath));
 
-    for (let partKey in descriptions) {
-        let partDescriptions = descriptions[partKey];
-        let descDestPath = path.resolve(config.releaseDestDir, `${language}/documents/${docName}-parts/${partKey}.json`);
+    function copyUIControlConfigs(source, target) {
+        for (let key in source) {
+            if (target[key]) {
+                if (source[key].uiControl) {
+                    target[key].uiControl = source[key].uiControl;
+                }
+                if (source[key].exampleBaseOptions) {
+                    target[key].exampleBaseOptions = source[key].exampleBaseOptions;
+                }
+            }
+            else {
+                console.error(`Unmatched option path ${key}`);
+            }
+        }
+    }
+
+    function readOptionDesc(language, partKey) {
+        const descDestPath = path.resolve(config.releaseDestDir, `${language}/documents/${docName}-parts/${partKey}.json`);
+        try {
+            const text = fs.readFileSync(descDestPath, 'utf-8');
+            return JSON.parse(text);
+        }
+        catch(e) {
+            return;
+        }
+    }
+
+    function writeOptionDesc(language, partKey, json) {
+        const descDestPath = path.resolve(config.releaseDestDir, `${language}/documents/${docName}-parts/${partKey}.json`);
         fse.ensureDirSync(path.dirname(descDestPath));
+
         fse.outputFile(
             descDestPath,
             // format ? JSON.stringify(partDescriptions, null, 2) : JSON.stringify(partDescriptions),
-            JSON.stringify(partDescriptions, null, 2),
+            JSON.stringify(json, null, 2),
             'utf-8'
         );
+    }
+
+    for (let partKey in descriptions) {
+        let partDescriptions = descriptions[partKey];
+
+        // Copy ui control config from zh to english.
+        if (language === 'zh') {
+            languages.forEach(function (otherLang) {
+                if (otherLang === 'zh') {
+                    return;
+                }
+                const json = readOptionDesc(otherLang, partKey);
+                if (json) {
+                    copyUIControlConfigs(partDescriptions, json);
+                    writeOptionDesc(otherLang, partKey, json);
+                }
+            });
+        }
+        else {
+            const json = readOptionDesc('zh', partKey);
+            if (json) {
+                copyUIControlConfigs(json, partDescriptions);
+            }
+        }
+
+        writeOptionDesc(language, partKey, partDescriptions);
         // console.log(chalk.green('generated: ' + descDestPath));
     }
 };
diff --git a/en/option/series/graph.md b/en/option/series/graph.md
index 70c8a83..389da59 100644
--- a/en/option/series/graph.md
+++ b/en/option/series/graph.md
@@ -5,8 +5,6 @@
 
 Graph is a diagram to represent [nodes](~series-graph.nodes) and the [links](~series-graph.links) connecting nodes.
 
-**Tips: ** In ECharts 2.x , the diagram of `force` type will not be available in ECharts 3 any more, which has been changed to use `graph` to show graph data. If you want to use force to lead the layout, you can set the  [layout](~series-graph.layout) configuration as `'force'`.
-
 **Example: **
 
 ~[600x400](${galleryViewPath}graph&reset=1&edit=1)
diff --git a/src/components/DocContent.vue b/src/components/DocContent.vue
index 57c52ce..f23cdc3 100644
--- a/src/components/DocContent.vue
+++ b/src/components/DocContent.vue
@@ -287,6 +287,8 @@ export default {
 
 .doc-content {
     text-align: left;
+    // color: #59636f;
+    color: #4d555e;
 
     // transition: margin-right 500ms cubic-bezier(0.215, 0.610, 0.355, 1);
 
diff --git a/src/components/DocContentItemCard.vue b/src/components/DocContentItemCard.vue
index e2bfbbb..3b4d90a 100644
--- a/src/components/DocContentItemCard.vue
+++ b/src/components/DocContentItemCard.vue
@@ -31,7 +31,7 @@
             v-if="uiControl && shared.allOptionExamples"
             @click="toggleUIControl"
         >
-            &#xe900; {{$t('example.tryDesc')}}
+            <i>&#xe900;</i> {{$t('example.tryDesc')}}
             <!-- <el-switch :active-text="$t('example.tryDesc')" v-model="enableUIControl"></el-switch> -->
         </span>
     </h4>
@@ -330,11 +330,16 @@ $hierarchy-guider-color: #C592A0;
         .control-toggle {
             float: right;
             font-size: 14px;
-            font-family: iconfont;
             cursor: pointer;
 
             color: #555;
 
+            i {
+                font-family: iconfont;
+                font-style: normal;
+                vertical-align: middle;
+            }
+
             &:hover {
                 color: #999;
             }
diff --git a/zh/option/component/calendar.md b/zh/option/component/calendar.md
index 7ed14af..ac7f70c 100644
--- a/zh/option/component/calendar.md
+++ b/zh/option/component/calendar.md
@@ -61,11 +61,6 @@ function getVirtulData(year) {
 }
 
 const option = {
-    title: {
-        top: 30,
-        left: 'center',
-        text: '2016年某人每天的步数'
-    },
     tooltip: {},
     visualMap: {
         min: 0,
diff --git a/zh/option/component/timeline.md b/zh/option/component/timeline.md
index 571f470..3a798d1 100644
--- a/zh/option/component/timeline.md
+++ b/zh/option/component/timeline.md
@@ -22,9 +22,6 @@ myChart.setOption(
                 ...,
                 data: ['2002-01-01', '2003-01-01', '2004-01-01']
             },
-            title: {
-                subtext: '数据来自国家统计局'
-            },
             grid: {...},
             xAxis: [...],
             yAxis: [...],
diff --git a/zh/option/series/graph.md b/zh/option/series/graph.md
index 580342a..9d8bb24 100644
--- a/zh/option/series/graph.md
+++ b/zh/option/series/graph.md
@@ -5,8 +5,6 @@
 
 用于展现节点以及节点之间的关系数据。
 
-**注意:** ECharts 2.x 中 `force` 类型的图表不再在 ECharts 3 中提供支持,转为统一使用 `graph` 去展现关系数据。如果要使用力引导布局,可以将 [layout](~series-graph.layout) 配置项设为`'force'`。
-
 **示例:**
 
 ~[600x400](${galleryViewPath}graph&reset=1&edit=1)
diff --git a/zh/option/series/scatter.md b/zh/option/series/scatter.md
index d9f697c..ff4f6e2 100644
--- a/zh/option/series/scatter.md
+++ b/zh/option/series/scatter.md
@@ -9,11 +9,7 @@
 
 <ExampleBaseOption name="scatter" title="基础散点图">
 const option = {
-    title: {
-        text: '身高体重分布',
-        subtext: '抽样调查来自: Heinz  2003',
-        left: 'center'
-    },
+    legend: {},
     grid: {
         left: '3%',
         right: '7%',
@@ -42,7 +38,7 @@ const option = {
     },
     series: [
         {
-            name: '男性',
+            name: 'Male',
             type: 'scatter',
             data: [[174.0, 65.6], [175.3, 71.8], [193.5, 80.7], [186.5, 72.6], [187.2, 78.8],[181.5, 74.8], [184.0, 86.4], [184.5, 78.4], [175.0, 62.0], [184.0, 81.6],[180.0, 76.6], [177.8, 83.6], [192.0, 90.0], [176.0, 74.6], [174.0, 71.0],[184.0, 79.6], [192.7, 93.8], [171.5, 70.0], [173.0, 72.4], [176.0, 85.9],[176.0, 78.8], [180.5, 77.8], [172.7, 66.2], [176.0, 86.4], [173.5, 81.8],[178.0, 89.6], [180.3, 82.8], [180.3, 76.4], [164.5, 63.2], [173.0, 60.9],[183.5, 74.8], [175.5, 70.0], [...]
             ]


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