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 2021/03/31 08:02:26 UTC

[echarts] 02/04: fix(option): optimize component missing error

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

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

commit ac49c2b2e385cdc98a6f7144e20b6f6d7c0784e3
Author: pissang <bm...@gmail.com>
AuthorDate: Wed Mar 31 15:41:00 2021 +0800

    fix(option): optimize component missing error
---
 src/model/Global.ts | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/model/Global.ts b/src/model/Global.ts
index 3cfbc24..5a35ff3 100644
--- a/src/model/Global.ts
+++ b/src/model/Global.ts
@@ -99,9 +99,15 @@ const BUITIN_COMPONENTS_MAP = {
     markArea: 'MarkAreaComponent',
     legend: 'LegendComponent',
     dataZoom: 'DataZoomComponent',
-    visualMap: 'VisualMapComponent'
+    visualMap: 'VisualMapComponent',
     // aria: 'AriaComponent',
-    // dataset: 'DatasetComponent'
+    // dataset: 'DatasetComponent',
+
+    // Dependencies
+    xAxis: 'GridComponent',
+    yAxis: 'GridComponent',
+    angleAxis: 'PolarComponent',
+    radiusAxis: 'PolarComponent'
 } as const;
 
 const BUILTIN_CHARTS_MAP = {
@@ -303,12 +309,12 @@ class GlobalModel extends Model<ECUnitOption> {
 
             if (!ComponentModel.hasClass(mainType)) {
                 if (__DEV__) {
-                    const namedComponents = BUITIN_COMPONENTS_MAP[mainType as keyof typeof BUITIN_COMPONENTS_MAP];
-                    if (namedComponents && !componetsMissingLogPrinted[namedComponents]) {
+                    const componentImportName = BUITIN_COMPONENTS_MAP[mainType as keyof typeof BUITIN_COMPONENTS_MAP];
+                    if (componentImportName && !componetsMissingLogPrinted[componentImportName]) {
                         error(`Component ${mainType} is used but not imported.
-import { ${namedComponents} } from 'echarts/components';
-echarts.use([${namedComponents}]);`);
-                        componetsMissingLogPrinted[namedComponents] = true;
+import { ${componentImportName} } from 'echarts/components';
+echarts.use([${componentImportName}]);`);
+                        componetsMissingLogPrinted[componentImportName] = true;
                     }
                 }
 
@@ -393,19 +399,19 @@ echarts.use([${namedComponents}]);`);
                     const isSeriesType = mainType === 'series';
                     const ComponentModelClass = (ComponentModel as ComponentModelConstructor).getClass(
                         mainType, resultItem.keyInfo.subType,
-                        isSeriesType // Give a more detailed warn if series don't exists
+                        !isSeriesType // Give a more detailed warn later if series don't exists
                     );
 
                     if (!ComponentModelClass) {
                         if (__DEV__) {
                             const subType = resultItem.keyInfo.subType;
-                            const namedSeries = BUILTIN_CHARTS_MAP[subType as keyof typeof BUILTIN_CHARTS_MAP];
+                            const seriesImportName = BUILTIN_CHARTS_MAP[subType as keyof typeof BUILTIN_CHARTS_MAP];
                             if (!componetsMissingLogPrinted[subType]) {
                                 componetsMissingLogPrinted[subType] = true;
-                                if (namedSeries) {
+                                if (seriesImportName) {
                                     error(`Series ${subType} is used but not imported.
-import { ${namedSeries} } from 'echarts/charts';
-echarts.use([${namedSeries}]);`);
+import { ${seriesImportName} } from 'echarts/charts';
+echarts.use([${seriesImportName}]);`);
                                 }
                                 else {
                                     error(`Unkown series ${subType}`);

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