提交 25ae5528 编写于 作者: K kener

【重要】图表类型自注册,按需加载

上级 3fd43984
...@@ -65,6 +65,7 @@ require.config({ ...@@ -65,6 +65,7 @@ require.config({
{ {
name: 'zrender', name: 'zrender',
location: 'http://ecomfe.github.io/zrender/src', location: 'http://ecomfe.github.io/zrender/src',
//location: '../../../zrender/src',
main: 'zrender' main: 'zrender'
} }
] ]
...@@ -72,7 +73,15 @@ require.config({ ...@@ -72,7 +73,15 @@ require.config({
var echarts; var echarts;
require( require(
['echarts/echarts'], [
'echarts/echarts',
'echarts/chart/line',
'echarts/chart/bar',
'echarts/chart/scatter',
'echarts/chart/k',
'echarts/chart/pie',
'echarts/chart/map'
],
function(ec) { function(ec) {
echarts = ec; echarts = ec;
if (myChart && myChart.dispose) { if (myChart && myChart.dispose) {
......
...@@ -28,20 +28,5 @@ define(function(require) { //chart ...@@ -28,20 +28,5 @@ define(function(require) { //chart
return _chartLibrary[name]; return _chartLibrary[name];
}; };
// 内置图表注册
self.define('island', require('./chart/island'));
self.define('pie', require('./chart/pie'));
self.define('bar', require('./chart/bar'));
self.define('line', require('./chart/line'));
self.define('map', require('./chart/map'));
self.define('k', require('./chart/k'));
self.define('scatter', require('./chart/scatter'));
return self; return self;
}); });
\ No newline at end of file
...@@ -760,5 +760,8 @@ define(function(require) { ...@@ -760,5 +760,8 @@ define(function(require) {
init(option, component); init(option, component);
} }
// 图表注册
require('../chart').define('bar', Bar);
return Bar; return Bar;
}); });
\ No newline at end of file
...@@ -233,5 +233,8 @@ define(function (require) { ...@@ -233,5 +233,8 @@ define(function (require) {
self.ondragend = ondragend; self.ondragend = ondragend;
} }
// 图表注册
require('../chart').define('island', Island);
return Island; return Island;
}); });
\ No newline at end of file
...@@ -433,9 +433,11 @@ define(function(require) { ...@@ -433,9 +433,11 @@ define(function(require) {
init(option, component); init(option, component);
} }
var shape = require('zrender/shape'); // 动态扩展zrender shape:candle
var Candle = require('../util/shape/candle'); require('../util/shape/candle');
shape.define('candle', new Candle());
// 图表注册
require('../chart').define('k', K);
return K; return K;
}); });
\ No newline at end of file
...@@ -797,5 +797,8 @@ define(function(require) { ...@@ -797,5 +797,8 @@ define(function(require) {
init(option, component); init(option, component);
} }
// 图表注册
require('../chart').define('line', Line);
return Line; return Line;
}); });
\ No newline at end of file
...@@ -515,5 +515,8 @@ define(function(require) { ...@@ -515,5 +515,8 @@ define(function(require) {
init(option, component); init(option, component);
} }
// 图表注册
require('../chart').define('map', Map);
return Map; return Map;
}); });
\ No newline at end of file
...@@ -876,5 +876,8 @@ define(function(require) { ...@@ -876,5 +876,8 @@ define(function(require) {
init(option, component); init(option, component);
} }
// 图表注册
require('../chart').define('pie', Pie);
return Pie; return Pie;
}); });
\ No newline at end of file
...@@ -420,9 +420,11 @@ define(function(require) { ...@@ -420,9 +420,11 @@ define(function(require) {
init(option, component); init(option, component);
} }
var shape = require('zrender/shape'); // 动态扩展zrender shape:symbol
var Symbol = require('../util/shape/symbol'); require('../util/shape/symbol');
shape.define('symbol', new Symbol());
// 自注册
require('../chart').define('scatter', Scatter);
return Scatter; return Scatter;
}); });
\ No newline at end of file
...@@ -29,26 +29,5 @@ define(function(require) { //component ...@@ -29,26 +29,5 @@ define(function(require) { //component
return _componentLibrary[name]; return _componentLibrary[name];
}; };
// 内置组件注册
self.define('axis', require('./component/axis'));
self.define('categoryAxis', require('./component/categoryAxis'));
self.define('valueAxis', require('./component/valueAxis'));
self.define('grid', require('./component/grid'));
self.define('dataZoom', require('./component/dataZoom'));
self.define('legend', require('./component/legend'));
self.define('dataRange', require('./component/dataRange'));
self.define('tooltip', require('./component/tooltip'));
self.define('toolbox', require('./component/toolbox'));
self.define('dataView', require('./component/dataView'));
return self; return self;
}); });
\ No newline at end of file
...@@ -184,5 +184,7 @@ define(function (require) { ...@@ -184,5 +184,7 @@ define(function (require) {
init(option, component, axisType); init(option, component, axisType);
} }
require('../component').define('axis', Axis);
return Axis; return Axis;
}); });
\ No newline at end of file
...@@ -639,5 +639,7 @@ define(function (require) { ...@@ -639,5 +639,7 @@ define(function (require) {
init(option, grid); init(option, grid);
} }
require('../component').define('categoryAxis', CategoryAxis);
return CategoryAxis; return CategoryAxis;
}); });
\ No newline at end of file
...@@ -1130,6 +1130,8 @@ define(function (require) { ...@@ -1130,6 +1130,8 @@ define(function (require) {
init(option); init(option);
} }
require('../component').define('dataRange', DataRange);
return DataRange; return DataRange;
}); });
......
...@@ -433,5 +433,7 @@ define(function (require) { ...@@ -433,5 +433,7 @@ define(function (require) {
_init(); _init();
} }
require('../component').define('dataView', DataView);
return DataView; return DataView;
}); });
\ No newline at end of file
...@@ -679,5 +679,7 @@ define(function (require) { ...@@ -679,5 +679,7 @@ define(function (require) {
init(option); init(option);
} }
require('../component').define('dataZoom', DataZoom);
return DataZoom; return DataZoom;
}); });
\ No newline at end of file
...@@ -132,5 +132,7 @@ define(function (require) { ...@@ -132,5 +132,7 @@ define(function (require) {
init(option); init(option);
} }
require('../component').define('grid', Grid);
return Grid; return Grid;
}); });
\ No newline at end of file
...@@ -498,6 +498,8 @@ define(function (require) { ...@@ -498,6 +498,8 @@ define(function (require) {
init(option); init(option);
} }
require('../component').define('legend', Legend);
return Legend; return Legend;
}); });
......
...@@ -633,5 +633,10 @@ define(function (require) { ...@@ -633,5 +633,10 @@ define(function (require) {
self.resetMagicType = resetMagicType; self.resetMagicType = resetMagicType;
} }
// 动态扩展zrender shape:icon
require('../util/shape/icon');
require('../component').define('toolbox', Toolbox);
return Toolbox; return Toolbox;
}); });
\ No newline at end of file
...@@ -778,5 +778,7 @@ define(function (require) { ...@@ -778,5 +778,7 @@ define(function (require) {
init(option, dom); init(option, dom);
} }
require('../component').define('tooltip', Tooltip);
return Tooltip; return Tooltip;
}); });
\ No newline at end of file
...@@ -790,6 +790,8 @@ define(function (require) { ...@@ -790,6 +790,8 @@ define(function (require) {
init(option, grid, series); init(option, grid, series);
} }
require('../component').define('valueAxis', ValueAxis);
return ValueAxis; return ValueAxis;
}); });
...@@ -92,17 +92,27 @@ define(function(require) { ...@@ -92,17 +92,27 @@ define(function(require) {
_zr.on(zrConfig.EVENT.DROP, _ondrop); _zr.on(zrConfig.EVENT.DROP, _ondrop);
var shape = require('zrender/shape'); // 内置图表注册
var Icon = require('./util/shape/icon');
shape.define('icon', new Icon());
// 孤岛
var chartLibrary = require('./chart'); var chartLibrary = require('./chart');
require('./chart/island');
// 孤岛
var Island = chartLibrary.get('island'); var Island = chartLibrary.get('island');
_island = new Island(_messageCenter, _zr); _island = new Island(_messageCenter, _zr);
// 工具箱
// 内置组件注册
var componentLibrary = require('./component'); var componentLibrary = require('./component');
require('./component/axis');
require('./component/categoryAxis');
require('./component/valueAxis');
require('./component/grid');
require('./component/dataZoom');
require('./component/legend');
require('./component/dataRange');
require('./component/tooltip');
require('./component/toolbox');
require('./component/dataView');
// 工具箱
var Toolbox = componentLibrary.get('toolbox'); var Toolbox = componentLibrary.get('toolbox');
_toolbox = new Toolbox(_messageCenter, _zr, dom); _toolbox = new Toolbox(_messageCenter, _zr, dom);
} }
......
...@@ -183,9 +183,9 @@ define( ...@@ -183,9 +183,9 @@ define(
} }
}; };
var base = require('zrender/shape/base'); require('zrender/shape/base').derive(Candle);
base.derive(Candle); require('zrender/shape').define('candle', new Candle());
return Candle; return Candle;
} }
); );
\ No newline at end of file
...@@ -328,9 +328,9 @@ define( ...@@ -328,9 +328,9 @@ define(
} }
}; };
var base = require('zrender/shape/base'); require('zrender/shape/base').derive(Icon);
base.derive(Icon); require('zrender/shape').define('icon', new Icon());
return Icon; return Icon;
} }
); );
\ No newline at end of file
...@@ -206,9 +206,9 @@ define( ...@@ -206,9 +206,9 @@ define(
} }
}; };
var base = require('zrender/shape/base'); require('zrender/shape/base').derive(Symbol);
base.derive(Symbol); require('zrender/shape').define('symbol', new Symbol());
return Symbol; return Symbol;
} }
); );
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册