dataComponent.js
function () {
return
getSupportEvents: function () {
return ['render', 'click', 'mouseup', 'mousedown', 'mousemove', 'mouseover', 'mouseout', 'optionChange'].concat(this._getSupportEvents());
},
_getSupportEvents: function () {
return [];
},
/**
* 最小高度
* @type {number}
*/
minHeight: 10,
/**
* 最小宽度
* @type {number}
*/
minWidth: 10,
/**
* 初始化
* @param {string=} id
* @param {Object} serialize
* @returns {exports}
* @private
*/
_init: function (id, serialize) {
}
};
bar.js
import DataComponent from './dataComponent'
// 配置
var CONFIG = {
width: 900,
height: 700,
color: ['#106fe1']
};
// ECharts 配置
var defaultOptions = {
// 标题
title: {
text: '我的123'
},
tooltip: {},
legend: { // 图例
data:['销量']
},
xAxis: { // 直角坐标系 grid 中的 x 轴
data: ["衬衫12","羊毛衫35","雪纺衫67","裤子","高跟鞋","袜子"]
},
yAxis: {},
series: [{
name: '销量123',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
};
/**
* 加载数据
* @param type
* @param callback
*/
return DataComponent.extend({
/**
* 默认容器的长与宽
* @returns {*|{}}
* @private
*/
_getDefaultOptions: function () {
return _.extend(true, this._super(), {
width: 500,
height: 500
});
},
/**
* 初始化 ECharts 的组件
*/
initEChart: function () {
console.log('初始化ECharts的组件')
},
/**
* 初始化
* @private
*/
_init: function () {
this._super.apply(this, arguments);
// 克隆默认 ECharts 配置
this.defaultOptions = _.clone(defaultOptions);
// 初始化容器长与宽
// _.css(this.container, 'width', CONFIG.width+'px');
// _.css(this.container, 'height', CONFIG.height+'px');
_.css(this.container, 'width', '900px');
_.css(this.container, 'height', '900px');
// 初始化 ECharts 的组件
this.initEChart();
}
})
直接定义然后导出就好了: