this.drawSelf = function()

in frontend/src/components/jfr/flame-graph.js [537:612]


    this.drawSelf = function () {
      if (!this.isRoot) {
        // generate information and text
        this.infomation = this.fg.$$diff
          ? {
              selfWeight: this.selfWeight,
              weight: this.weight,
              totalWeight: this.fg.$totalWeight,

              selfWeightOfBaseline1: this.selfWeightOfBaseline1,
              weightOfBaseline1: this.weightOfBaseline1,
              totalWeightOfBaseline1: this.fg.$totalWeightOfBaseline1,

              selfWeightOfBaseline2: this.selfWeightOfBaseline2,
              weightOfBaseline2: this.weightOfBaseline2,
              totalWeightOfBaseline2: this.fg.$totalWeightOfBaseline2,

              diffPercent: this.diffPercent()
            }
          : {
              selfWeight: this.selfWeight,
              weight: this.weight,
              totalWeight: this.fg.$totalWeight
            };

        this.text = this.fg.$$textGenerator(flameGraph.$dataSource, raw, this.infomation);

        this.infomation.text = this.text;
      }
      if (!this.color) {
        this.color = this.fg.$$colorSelector(this.fg.dataSource, this.raw, this.infomation);
      }

      this.fg.$context.fillStyle = this.color[0];
      this.fg.$context.fillRect(this.x, this.y, this.width, this.height);

      this.visibleText = null;
      if (this.width > this.fg.$showTextWidthThreshold && this.text.length > 0) {
        this.fg.$context.font = this.isRoot ? this.fg.$rootFont : this.fg.$font;
        this.fg.$context.fillStyle = this.color[1];
        this.fg.$context.textBaseline = 'middle';
        let w = this.fg.$context.measureText(this.text).width;
        let leftW = this.width - 2 * this.fg.$textGap;
        if (w <= leftW) {
          this.fg.$context.fillText(
            this.text,
            this.x + this.fg.$textGap,
            this.y + this.height / 2 + 1
          );
          this.visibleText = this.text;
        } else {
          // truncate text and append suffix
          let len = Math.floor(
            (this.text.length * (leftW - this.fg.$context.measureText(this.fg.$moreText).width)) / w
          );
          let text = null;
          for (let i = len; i > 0; i--) {
            text = this.text.substring(0, len) + this.fg.$moreText;
            if (this.fg.$context.measureText(text).width <= leftW) {
              break;
            }
            text = null;
          }
          if (text != null) {
            this.fg.$context.fillText(
              text,
              this.x + this.fg.$textGap,
              this.y + this.height / 2 + 1
            );
          }
          this.visibleText = text;
        }
      }
      this.fg.$stackTraceMaxDrawnDepth = Math.max(this.depth, this.fg.$stackTraceMaxDrawnDepth);
      this.fg.$sibling[this.depth].push(this);
    };