How to use the @antv/g.Text function in @antv/g

To help you get started, we’ve selected a few @antv/g examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github antvis / G2Plot / src / components / description.ts View on Github external
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;
github antvis / G2Plot / src / plots / stack-area / component / label / area-label.ts View on Github external
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();
  }
github antvis / G2Plot / src / plots / stack-area / component / label / area-label.ts View on Github external
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();
  }