Ver código fonte

修改

master
pengpeng.zhai 1 ano atrás
pai
commit
dbf7753f84

src/chart/CustomChartBar/CustomChartBar.js → src/chart/echarts/CustomChartBar/CustomChartBar.js Ver arquivo

@@ -1,5 +1,5 @@
1 1
 import utils from 'utils/index.js';
2
-import echarts from './echarts.min.js';
2
+import echarts from '../echarts.min.js';
3 3
 
4 4
 import styleConfig from './config/styleConfig';
5 5
 import dataConfig from './config/dataConfig';
@@ -28,34 +28,34 @@ export default class CustomChartBar{
28 28
     }
29 29
 
30 30
 
31
-    mergeOption(style, dataConfig){
32
-        style = utils.deepCopy(style);
33
-        style.xAxis.data = dataConfig.defaultData[dataConfig.configList[0].defaultKey];
34
-        style.color = style.color.color;
35
-        style.yAxis = {
36
-            type:'value'
37
-        }
31
+    // mergeOption(style, dataConfig){
32
+    //     style = utils.deepCopy(style);
33
+    //     style.xAxis.data = dataConfig.defaultData[dataConfig.configList[0].defaultKey];
34
+    //     style.color = style.color.color;
35
+    //     style.yAxis = {
36
+    //         type:'value'
37
+    //     }
38 38
 
39
-        style.series = [];
40
-        let series = dataConfig.configList[1].defaultKey;
41
-        if(Array.isArray(series) === true){
42
-            series.forEach( item => {
43
-                style.series.push({
44
-                    data:dataConfig.defaultData[item],
45
-                    type:'bar'
46
-                })
47
-            })
48
-        }else{
49
-            style.series = [
50
-                {
51
-                  data: dataConfig.defaultData[series],
52
-                  type: 'bar'
53
-                }
54
-              ]
55
-        }
39
+    //     style.series = [];
40
+    //     let series = dataConfig.configList[1].defaultKey;
41
+    //     if(Array.isArray(series) === true){
42
+    //         series.forEach( item => {
43
+    //             style.series.push({
44
+    //                 data:dataConfig.defaultData[item],
45
+    //                 type:'bar'
46
+    //             })
47
+    //         })
48
+    //     }else{
49
+    //         style.series = [
50
+    //             {
51
+    //               data: dataConfig.defaultData[series],
52
+    //               type: 'bar'
53
+    //             }
54
+    //           ]
55
+    //     }
56 56
         
57
-        return style;
58
-    }
57
+    //     return style;
58
+    // }
59 59
 
60 60
     getConfig(){
61 61
         return{

src/chart/CustomChartBar/config/dataConfig.js → src/chart/echarts/CustomChartBar/config/dataConfig.js Ver arquivo


src/chart/CustomChartBar/config/styleConfig.js → src/chart/echarts/CustomChartBar/config/styleConfig.js Ver arquivo


src/chart/CustomChartBar/echarts.min.js → src/chart/echarts/echarts.min.js Ver arquivo


+ 0
- 12
test/CustomChartBar/index.js Ver arquivo

@@ -1,12 +0,0 @@
1
-import chart from '../../src/chart/CustomChartBar/CustomChartBar.js';
2
-import Utils from '../utils.js';
3
-
4
-let config = new chart(document.querySelector('#container'), {getConfig:true}).getConfig();
5
-let current_chart = new chart(document.querySelector('#container'));
6
-
7
-
8
-let styleConfig = config.styleConfig;
9
-let dataConfig = config.dataConfig;
10
-console.log(123, Utils.parseStyle(styleConfig), dataConfig)
11
-current_chart.setOption(Utils.parseStyle(styleConfig), dataConfig);
12
-

test/CustomChartBar/index.html → test/echarts/CustomChartBar/index.html Ver arquivo


+ 10
- 0
test/echarts/CustomChartBar/index.js Ver arquivo

@@ -0,0 +1,10 @@
1
+import chart from '../../../src/chart/echarts/CustomChartBar/CustomChartBar.js';
2
+import Utils from '../../utils.js';
3
+
4
+let config = new chart(document.querySelector('#container'), {getConfig:true}).getConfig();
5
+let styleConfig = config.styleConfig;
6
+let dataConfig = config.dataConfig;
7
+
8
+let option = config.fun.themeMerge(Utils.parseStyle(styleConfig), Utils.parseData(dataConfig));
9
+new chart(document.querySelector('#container'), option)
10
+

+ 24
- 0
test/utils.js Ver arquivo

@@ -10,6 +10,30 @@ const Utils = {
10 10
             }
11 11
         }
12 12
 
13
+        return result;
14
+    },
15
+    parseData: function(dataConfig){
16
+        let result = {};
17
+
18
+        let { configList, defaultData } = dataConfig;
19
+        configList.forEach( item =>{
20
+            // if(item.comType == "single"){
21
+            //     result[item.type] = {
22
+            //         name:item.defaultKey,
23
+            //         data:defaultData[item.defaultKey]
24
+            //     }
25
+            // }
26
+
27
+            let columns = item.comType == "single" ? [item.defaultKey] : item.defaultKey;
28
+            result[item.type] = columns.map( key => {
29
+                return {
30
+                    name:key,
31
+                    data:defaultData[key]
32
+                }
33
+            })
34
+            
35
+        })
36
+
13 37
         return result;
14 38
     }
15 39
 }

Carregando…
Cancelar
Salvar