Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const offset = labelOptions.offset;
return offset === undefined ? DEFAULT_OFFSET : offset <= CROOK_DISTANCE ? 1 : offset - CROOK_DISTANCE;
}
public getDefaultOffset(point) {
const offset = super.getDefaultOffset(point);
return offset === undefined ? DEFAULT_OFFSET : offset <= CROOK_DISTANCE ? 1 : offset - CROOK_DISTANCE;
}
private getCrookDistance(): number {
const offset = this.getOffsetOfLabel();
return offset > CROOK_DISTANCE ? CROOK_DISTANCE : 0;
}
}
registerElementLabels('outer', OuterPieLabel);
}
}
public _mappingColor(band, gray) {
let reflect;
_.each(band, (b) => {
const map = b as Point;
if (gray >= map.from && gray < map.to) {
reflect = map.color;
}
});
return reflect;
}
}
registerElementLabels('matrixLabel', MatrixLabels);
const labels = renderer.get('group').get('children');
const view = this.get('element').get('view');
_.each(labels, (label, index) => {
const scaleFactor = this.scaleFactor[index];
label.attr('fontSize', DEFAULT_SIZE);
label.transform([
['t', -label.attr('x'), -label.attr('y')],
['s', scaleFactor, scaleFactor],
['t', label.attr('x'), label.attr('y')],
]);
});
view.get('canvas').draw();
}
}
registerElementLabels('area', AreaLabel);
label.attr('fill', 'black');
}
}
public _mappingColor(band, gray) {
let reflect;
_.each(band, (b) => {
const map = b as Point;
if (gray >= map.from && gray < map.to) {
reflect = map.color;
}
});
return reflect;
}
}
registerElementLabels('barLabel', BarLabels);
const anchorsBBox = renderer.get('items').map((item: Item) => {
return {
x: item.start.x - 4,
y: item.start.y - 4,
width: 8,
height: 8,
};
});
/*layout(labels, anchorsBBox, view.get('panelRange'), {
nsweeps: 10,
});*/
view.get('canvas').draw();
}
}
registerElementLabels('point', LinePointLabels);
const labels = renderer.get('group').get('children');
const view = this.get('element').get('view');
_.each(labels, (label, index) => {
const scaleFactor = this.scaleFactor[index];
label.attr('fontSize', DEFAULT_SIZE);
label.transform([
['t', -label.attr('x'), -label.attr('y')],
['s', scaleFactor, scaleFactor],
['t', label.attr('x'), label.attr('y')],
]);
});
view.get('canvas').draw();
}
}
registerElementLabels('area', AreaLabel);
import { BarLabels } from '../../../bar/component/label/bar-label';
class StackBarLabels extends BarLabels {
public adjustPosition(label, shape) {
const labelRange = label.getBBox();
const shapeRange = shape.getBBox();
if (shapeRange.width <= labelRange.width) {
label.attr('opacity', 0);
label.attr('fillOpacity', 0);
label.attr('strokeOpacity', 0);
label.set('capture', false);
}
}
}
registerElementLabels('stackBarLabel', StackBarLabels);
import { ColumnLabels } from '../../../column/component/label/column-label';
class StackColumnLabels extends ColumnLabels {
public adjustPosition(label, shape) {
const labelRange = label.getBBox();
const shapeRange = shape.getBBox();
if (shapeRange.height <= labelRange.height) {
label.attr('opacity', 0);
label.attr('fillOpacity', 0);
label.attr('strokeOpacity', 0);
label.set('capture', false);
}
}
}
registerElementLabels('stackColumnLabel', StackColumnLabels);
return originItems;
}
/** 获取label offset, 不允许 <= 0 */
public getOffsetOfLabel(labelItem?: LabelItem): number {
const offset = (labelItem && labelItem.offset) || DEFAULT_OFFSET;
return offset > 0 ? offset : 1;
}
/** 获取offset betwee label-text and label-line */
private getTextLineOffset(labelItem?: LabelItem): number {
return Math.min(this.getOffsetOfLabel(labelItem), DEFAULT_TEXT_LINE_OFFSET);
}
}
registerElementLabels('upgrade-pie', UpgradePieLabels);
view.get('canvas').draw();
}
public _adjustColor(shapeId, shapes) {
let color;
each(shapes, (shape) => {
const id = shape.id;
if (id === shapeId) {
color = shape.attr('fill');
}
});
return color;
}
}
registerElementLabels('areaLine', AreaLineElementLabels);