Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
cfg.style = {};
}
// const oriShapeAttrs = shape.attr();
// cfg.style.radius = cfg.style.radius || oriShapeAttrs.radius;
// cfg.style.offset = cfg.style.offset || oriShapeAttrs.offset;
cfg = this.getPathPoints(cfg);
const points = this.getControlPoints(cfg);
const path = this.getPath(points, this.routeCfg);
// 下面这些属性需要覆盖默认样式与目前样式,但若在 cfg 中有指定则应该被 cfg 的相应配置覆盖。
const strokeStyle = {
stroke: cfg.color,
path
};
const shapeStyle = deepMix({}, shape.attr(), strokeStyle, cfg.style);
shape.attr(shapeStyle);
this.updateLabel(cfg, item);
}
}, 'single-line');
const content = labelCfg.content;
if (isFunction(content)) {
labelCfg.content = content(origin, mappingData, index);
} else if (isUndefined(content)) {
// 用户未配置 content,则默认为映射的第一个字段的值
labelCfg.content = originText[0];
}
if (isFunction(labelCfg.position)) {
labelCfg.position = labelCfg.position(origin, mappingData, index);
}
if (type === 'polygon' || (labelCfg.offset < 0 && !['line', 'point', 'path'].includes(type))) {
// polygon 或者 offset 小于 0 时,文本展示在图形内部,将其颜色设置为 白色
labelCfg = deepMix({}, defaultLabelCfg, theme.innerLabels, labelCfg);
} else {
labelCfg = deepMix({}, defaultLabelCfg, theme.labels, labelCfg);
}
labelCfgs.push(labelCfg);
});
public getOptions(props: T) {
const options = super.getOptions(props);
// @ts-ignore
const defaultOptions = this.constructor.getDefaultOptions();
return _.deepMix({}, options, defaultOptions, props);
}
public _initBackground() {
const chart = this.view;
const geom = chart.get('elements')[0];
const shapes = geom.get('shapeContainer').get('children');
const chartData = shapes.length > 0 ? getFirstShapeData(shapes) : chart.get('data');
const data = (this.data = this.data || chartData);
const xScale = chart.getXScale();
const xAxis = this.view.xAxis || xScale.field;
const yAxis = this.view.yAxis || chart.getYScales()[0].field;
const scales = _.deepMix(
{
[`${xAxis}`]: {
range: [0, 1],
},
},
getColDefs(chart),
this.view.scales
); // 用户列定义
delete scales[xAxis].min;
delete scales[xAxis].max;
if (!data) {
// 没有数据,则不创建
throw new Error('Please specify the data!');
}
if (!xAxis) {
throw new Error('Please specify the xAxis!');
private _labelParser() {
const { style, ...restLabelProps } = this.localProps.label;
const labelConfig: DataPointType = { ...restLabelProps };
/** label style */
if (style) {
labelConfig.textStyle = this.localProps.label.style;
}
labelConfig.textStyle = _.deepMix({}, _.get(this.themeConfig, 'label.style'), labelConfig.textStyle);
this.config.label = labelConfig;
}
public static getDefaultOptions(): Partial {
return _.deepMix({}, super.getDefaultOptions(), {
xAxis: {
visible: true,
grid: {
visible: true,
},
},
yAxis: {
visible: true,
title: {
visible: false,
},
},
label: {
visible: true,
position: 'right',
offset: 8,
this.config.grid = (text: string, index: number, count: number) => {
const cfg = style(text, index, count);
return _.deepMix({}, _.get(this.themeConfig, `grid.style`), cfg);
};
} else if (style) {
constructor(cfg: NodesCfg) {
this.shapes = cfg.shapes;
this.nodes = [];
this._parserNodes();
this.origion_nodes = _.deepMix([], this.nodes);
}
getMarker(shapeType: string, markerCfg: ShapeMarkerCfg): ShapeMarkerAttrs {
let shape = this.getShape(shapeType);
if (!shape.getMarker) {
const defaultShapeType = this.defaultShapeType;
shape = this.getShape(defaultShapeType);
}
const theme = this.theme;
const shapeStyle = get(theme, [shapeType, 'default'], {});
const markerStyle = shape.getMarker(markerCfg);
return deepMix({}, { style: shapeStyle }, markerStyle);
},
/**
protected createLayers(props: T & { layers?: any }) {
this.globalOptions = deepMix({}, this.getDefaultOptions(), this.getGlobalOptions(props));
}
}