Incubator-echarts: 中国地图无法按需加载,需要手动修改china.js

Created on 24 May 2018  ·  2Comments  ·  Source: apache/incubator-echarts

One-line summary [问题简述]

按需加载echart中国地图,发现只要引入了china.js,按需加载无效,所有的内容都被引用进来

Version & Environment [版本及环境]

"webpack": "^3.6.0"

  • ECharts version [ECharts 版本]:
    "echarts": "^4.0.4"

china.js 源码:

(function (root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['exports', 'echarts'], factory);
    } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
        // CommonJS
        factory(exports, require('echarts'));
    } else {
        // Browser globals
        factory({}, root.echarts);
    }
}(this, function (exports, echarts) {
   echarts.registerMap()
})

修改后:

const echarts = require('echarts/lib/echarts')
 echarts.registerMap()

Expected behaviour [期望结果]

无需手动修改配置

ECharts option [ECharts配置项]


const echarts = require('echarts/lib/echarts')

require('echarts/lib/chart/line')

require('echarts/lib/chart/bar')

require('echarts/lib/chart/pictorialBar')

require('echarts/lib/chart/pie')

require('echarts/lib/chart/scatter')

require('echarts/lib/chart/effectScatter')

require('echarts/lib/chart/map')

require('echarts/lib/component/grid')

require('echarts/lib/component/tooltip')

require('echarts/lib/component/axisPointer')

require('echarts/lib/component/geo')

require('echarts/lib/component/visualMap')

require('echarts/lib/component/toolbox')

export default echarts

Other comments [其他信息]


Most helpful comment

可以通过动态引入json类型的数据实现。

All 2 comments

文档中也确实没有表明china.js可以按需加载:可以按需引入的模块列表

不知能否做增强

可以通过动态引入json类型的数据实现。

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jxffly picture jxffly  ·  3Comments

Thinkpad93 picture Thinkpad93  ·  3Comments

kirazxyun picture kirazxyun  ·  3Comments

771752687 picture 771752687  ·  3Comments

akvaliya picture akvaliya  ·  3Comments