Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private _textWrapper() {
const width = this.wrapperWidth;
const style = this.style;
const textContent: string = this.text;
const tShape = new Text({
attrs: {
text: '',
x: 0,
y: 0,
...style,
},
});
const textArr = textContent.split('\n');
const wrappedTextArr = textArr.map((wrappedText) => {
let text = '';
const chars = wrappedText.split('');
const breakIndex: number[] = [];
for (let i = 0; i < chars.length; i++) {
const item = chars[i];
tShape.attr('text', (text += item));
const currentWidth = tShape.getBBox().width - 1;
private _getLabelBbox(text) {
const plot: ViewLayer = this.get('labelOptions').plot;
const labelStyle = _.clone(plot.getTheme().label.textStyle);
labelStyle.fontSize = DEFAULT_SIZE;
const tShape = new Text({
attrs: {
text,
x: 0,
y: 0,
...labelStyle,
},
});
return tShape.getBBox();
}
private _getLabelBbox(text) {
const plot: ViewLayer = this.get('labelOptions').plot;
const labelStyle = _.clone(plot.theme.label.textStyle);
labelStyle.fontSize = DEFAULT_SIZE;
const tShape = new Text({
attrs: {
text,
x: 0,
y: 0,
...labelStyle,
},
});
return tShape.getBBox();
}