@alicloud/cloud-charts
Version:

112 lines (98 loc) • 3.03 kB
JavaScript
;
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose";
import Base from '../common/Base';
import errorWrap from '../common/errorWrap';
import rectXAxis from '../common/rectXAxis';
import rectYAxis from '../common/rectYAxis';
import rectTooltip from '../common/rectTooltip';
import rectLegend from '../common/rectLegend';
import label from '../common/label';
import geomStyle from '../common/geomStyle';
import polarLegendLayout from '../common/polarLegendLayout';
import updateChildrenPosition from '../common/updateChildrenPosition';
import themes from '../themes/index';
import "./index.css";
import { warn } from '../common/log'; // 3.x代码
export var Nightingale = /*#__PURE__*/function (_Base) {
_inheritsLoose(Nightingale, _Base);
function Nightingale() {
var _this;
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
_this = _Base.call.apply(_Base, [this].concat(args)) || this;
_this.chartName = 'G2Nightingale';
_this.legendField = 'x';
return _this;
}
var _proto = Nightingale.prototype;
_proto.getDefaultConfig = function getDefaultConfig() {
return {
// padding: [20, 20, 20, 20],
colors: themes.category_12,
xAxis: false,
yAxis: false,
cycle: false,
innerRadius: 0.5,
// 内环半径大小,仅cycle为true时可用
outerRadius: 1,
label: {
offset: -15
},
legend: {
position: 'bottom',
align: 'center',
nameFormatter: null
},
tooltip: {
nameFormatter: null,
valueFormatter: null
}
};
};
_proto.init = function init(chart, config, data) {
var _this2 = this;
var defs = {
type: {
type: 'cat'
}
};
chart.scale(defs);
chart.data(data);
chart.coordinate('polar', {
innerRadius: config.cycle ? Math.max(Math.min(config.innerRadius, 1), 0) : 0,
radius: Math.max(Math.min(config.outerRadius, 1), 0.01)
}); // 设置图例
rectLegend(this, chart, config, null, true); // tooltip
rectTooltip(this, chart, config, {
showMarkers: false,
showCrosshairs: false
}, null, {
showTitle: false,
showMarkers: false,
showCrosshairs: false
});
if (config.axis) {
warn('config.axis', '属性已废弃,请使用 config.xAxis 属性');
}
rectXAxis(this, chart, config);
rectYAxis(this, chart, config);
var geom = chart.interval().position('x*y').color('x', config.colors);
geomStyle(geom, config.geomStyle, {
lineWidth: 1,
stroke: themes['widgets-color-background']
});
label({
geom: geom,
config: config,
field: 'x'
});
polarLegendLayout(chart);
chart.on('afterpaint', function () {
updateChildrenPosition(chart, _this2.chartDom);
});
};
return Nightingale;
}(Base);
var Wnightingale = errorWrap(Nightingale);
export default Wnightingale;