@alicloud/cloud-charts
Version:

118 lines (102 loc) • 3.1 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 guide from '../common/guide';
import { propertyAssign, propertyMap } from '../common/common';
import legendFilter from '../common/legendFilter';
import drawLine from '../common/drawLine';
import polarLegendLayout from '../common/polarLegendLayout';
import autoTimeMask from '../common/autoTimeMask';
import themes from '../themes';
import "./index.css"; // 3.x代码
export var Radar = /*#__PURE__*/function (_Base) {
_inheritsLoose(Radar, _Base);
function Radar() {
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 = 'G2Radar';
return _this;
}
var _proto = Radar.prototype;
_proto.getDefaultConfig = function getDefaultConfig() {
return {
colors: themes.category_12,
areaColors: [],
xAxis: {
labelFormatter: null
},
yAxis: {
labelFormatter: null,
// 可以强制覆盖,手动设置label
min: 0
},
legend: {
position: 'bottom',
align: 'center',
nameFormatter: null
},
tooltip: {
titleFormatter: null,
nameFormatter: null,
valueFormatter: null
},
area: false,
symbol: false,
label: false,
spline: false,
radius: 1
};
};
_proto.init = function init(chart, config, data) {
var defs = {
x: propertyAssign(propertyMap.axis, {// type: 'time',
// 折线图X轴的范围默认覆盖全部区域,保证没有空余
// range: [0, 1],
}, config.xAxis),
y: propertyAssign(propertyMap.axis, {
type: 'linear',
tickCount: 5,
nice: true
}, config.yAxis),
type: {
type: 'cat'
}
};
autoTimeMask(defs, this.rawData);
chart.scale(defs);
chart.data(data); // 极坐标配置
chart.coordinate('polar', {
radius: config.radius
}); // 设置X轴
rectXAxis(this, chart, config); // 设置单个Y轴
rectYAxis(this, chart, config); // 设置图例
rectLegend(this, chart, config, null, false, 'type', true);
legendFilter(this, chart); // tooltip
rectTooltip(this, chart, config, {}, null, {
showCrosshairs: true,
crosshairs: {
type: 'xy' // line: {
// style: {
// stroke: '#565656',
// lineDash: [4],
// },
// },
// follow: true
}
}); // 绘制辅助线,辅助背景区域
guide(chart, config);
drawLine(chart, config);
polarLegendLayout(chart);
};
return Radar;
}(Base);
var Wradar = errorWrap(Radar);
export default Wradar;