yylib-quick-mobile
Version:
yylib-quick-mobile
107 lines (90 loc) • 4.74 kB
JavaScript
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _classnames = require('classnames');
var _classnames2 = _interopRequireDefault(_classnames);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var YYChart = function (_Component) {
_inherits(YYChart, _Component);
function YYChart() {
_classCallCheck(this, YYChart);
return _possibleConstructorReturn(this, (YYChart.__proto__ || Object.getPrototypeOf(YYChart)).apply(this, arguments));
}
_createClass(YYChart, [{
key: 'componentDidMount',
value: function componentDidMount() {
var _props = this.props,
RunInDesign = _props.RunInDesign,
uikey = _props.uikey;
if (window.echarts) {
this.myChart = echarts.init(document.getElementById(uikey));
} else {
console.error("项目中未引入图表组件,请手动引入或联系管理员");
}
if (RunInDesign) {
if (this.myChart) {
this.myChart.setOption({
title: {
text: 'EChart',
subtext: "此数据只是设计态展示,开发者需要在运行态实现图表的设置数据部分"
},
tooltip: {},
legend: {
data: ['销量']
},
xAxis: {
data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
},
yAxis: {},
series: [{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}]
});
}
}
}
}, {
key: 'getechart',
value: function getechart() {
if (!this.myChart) {
console.error("当前未引入百度图表或者初始化失败!");
}
return this.myChart;
}
}, {
key: 'componentWillReceiveProps',
value: function componentWillReceiveProps() {
if (this.myChart) {
this.myChart.resize();
}
}
}, {
key: 'render',
value: function render() {
var _props2 = this.props,
RunInDesign = _props2.RunInDesign,
uititle = _props2.uititle,
height = _props2.height,
uikey = _props2.uikey,
visible = _props2.visible,
className = _props2.className;
var wrapClz = (0, _classnames2.default)({
'yy-chart': true,
'hidden': !visible,
className: className
});
return _react2.default.createElement('div', { id: uikey, style: { height: height, backgroundColor: "#FFFFFF" }, className: wrapClz });
}
}]);
return YYChart;
}(_react.Component);
YYChart.defaultProps = {
visible: true
};
module.exports = YYChart;
;