@alicloud/cloud-charts
Version:

87 lines (69 loc) • 2.56 kB
JavaScript
;
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import React from 'react';
import classNames from 'classnames';
import Dashboard from './dashboard';
import "./index.css";
import chartLog from "../common/log";
import { FullCrossName, PrefixName } from '../constants';
var prefix = PrefixName + "-wdashboard";
var Wdashboard = /*#__PURE__*/function (_React$Component) {
_inheritsLoose(Wdashboard, _React$Component);
// static defaultProps = {
// range: [0, 100],
// pointCount: 6,
// };
function Wdashboard(props) {
var _this;
_this = _React$Component.call(this, props) || this; // 图表初始化时记录日志
chartLog('Wdashboard', 'init');
return _this;
}
var _proto = Wdashboard.prototype;
_proto.componentDidMount = function componentDidMount() {
var _this$props = this.props,
data = _this$props.data,
config = _this$props.config;
if (!this.dom) {
return;
}
this.dashboard = new Dashboard(this.dom, Object.assign({}, config));
this.dashboard.setData(data);
};
_proto.componentDidUpdate = function componentDidUpdate(prevProps) {
var _this$props2 = this.props,
newData = _this$props2.data,
newOptions = _this$props2.config;
var oldData = prevProps.data,
oldOptions = prevProps.config;
if (newOptions !== oldOptions) {
this.dashboard.setOption(Object.assign({}, newOptions));
}
if (newData !== oldData && this.dashboard) {
this.dashboard.setData(newData);
}
};
_proto.render = function render() {
var _classNames,
_this2 = this;
var _this$props3 = this.props,
className = _this$props3.className,
otherProps = _objectWithoutPropertiesLoose(_this$props3, ["className"]);
var mainClasses = classNames((_classNames = {}, _classNames[FullCrossName] = true, _classNames[prefix] = true, _classNames[className] = !!className, _classNames));
return /*#__PURE__*/React.createElement("div", {
className: "doa-dashoboard-out"
}, /*#__PURE__*/React.createElement("div", {
ref: function ref(s) {
return _this2.dom = s;
},
className: mainClasses
}));
};
return Wdashboard;
}(React.Component); // Wdashboard.propTypes = {
// range: PropTypes.array, //取值范围
// pointCount: PropTypes.number, // 刻度个数
// };
Wdashboard.displayName = 'Wdashboard';
export { Wdashboard as default };