Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
protected _coord() {
const props = this.initialProps;
const coordConfig = {
type: 'polar' as CoordinateType,
cfg: {
radius: 1.0, // default radius值
},
};
if (_.has(props, 'radius')) {
coordConfig.cfg.radius = props.radius;
}
this.setConfig('coord', coordConfig);
}
_.each(mapper, (m) => {
if (_.has(props, m)) {
config[m] = props[m];
count++;
}
});
// 如用户没有设置offset,而label position又为middle时,则默认设置offset为0
_.each(originData, (d) => {
const sumField = d[yField];
if (!_.has(sum, sumField)) {
sum[sumField] = 0;
}
sum[sumField] += Number.parseFloat(d[xField]);
});
// step2: 获取每一条数据yField的值在对应xField数值总和的占比
protected scale() {
const { options } = this;
const scales = {};
/** 配置x-scale */
scales[options.xField] = {};
if (_.has(options, 'xAxis')) {
extractScale(scales[options.xField], options.xAxis);
}
/** 配置y-scale */
scales[options.yField] = {};
if (_.has(options, 'yAxis')) {
extractScale(scales[options.yField], options.yAxis);
}
this.setConfig('scales', scales);
super.scale();
}
public parseColor() {
const props = this.plot.initialProps;
const config: DataPointType = {};
if (props.seriesField) {
config.fields = [props.seriesField];
}
if (_.has(props, 'color')) {
const color = props.color;
if (_.isString(color)) {
config.values = [color];
} else if (_.isFunction(color)) {
config.callback = color;
} else {
config.values = color as [];
}
}
this.config.color = config;
}
protected addGeometry() {
const props = this.options;
const bar = getGeom('interval', 'main', {
positionFields: [props.yField, props.xField],
plot: this,
});
bar.adjust = [
{
type: 'stack',
},
];
if (_.has(props, 'animation')) {
bar.animate = props.animation;
}
this.setConfig('element', bar);
}
protected scale() {
const props = this.options;
const scales = {};
/** 配置x-scale */
scales[props.angleField] = {};
if (_.has(props, 'angleAxis')) {
extractScale(scales[props.angleField], props.angleAxis);
}
/** 配置y-scale */
scales[props.radiusField] = {};
if (_.has(props, 'radiusAxis')) {
extractScale(scales[props.radiusField], props.radiusAxis);
}
this.setConfig('scales', scales);
super.scale();
}
protected scale() {
const props = this.options;
const scales = {};
/** 配置x-scale */
scales[props.xField] = {};
if (_.has(props, 'xAxis')) {
extractScale(scales[props.xField], props.xAxis);
}
/** 配置y-scale */
scales[props.yField] = {};
if (_.has(props, 'yAxis')) {
extractScale(scales[props.yField], props.yAxis);
}
this.setConfig('scales', scales);
super.scale();
}
export function isSingleGraph(type: string, props: ViewLayerConfig) {
if (_.contains(SINGLE_TYPE, type)) {
if (type === 'line' && _.has(props, 'seriesField')) {
return false;
}
if (type === 'column' && _.has(props, 'colorField')) {
return false;
}
return true;
}
return false;
}
protected scale() {
const props = this.options;
const scales = {};
/** 配置x-scale */
scales[props.xField] = {};
if (_.has(props, 'xAxis')) {
extractScale(scales[props.xField], props.xAxis);
}
/** 配置y-scale */
scales[props.yField] = {};
if (_.has(props, 'yAxis')) {
extractScale(scales[props.yField], props.yAxis);
}
this.setConfig('scales', scales);
super.scale();
}