function recompute_scale()

in src/plotxy.tsx [201:262]


    function recompute_scale(force: boolean = false) {
      if (!force && !me.isEnabled()) {
        return;
      }
      const insideGraphMargin = Math.max(me.props.dots_thickness, me.props.dots_highlighed_thickness, 0);
      x_scale_orig = x_scale = create_scale(me.state.axis_x, [margin.left + insideGraphMargin, me.state.width - margin.right - insideGraphMargin]);
      y_scale_orig = y_scale = create_scale(me.state.axis_y, [me.state.height - margin.bottom - insideGraphMargin, margin.top + insideGraphMargin]);
      zoom_brush = d3.brush().extent([[margin.left, margin.top], [me.state.width - margin.right, me.state.height - margin.bottom]]).on("end", brushended);

      yAxis = g => g
        .attr("transform", `translate(${margin.left - 10},0)`)
        .call(d3.axisLeft(y_scale).ticks(1+me.state.height / 40).tickSizeInner(margin.left + margin.right - me.state.width))
        .call(g => g.select(".domain").remove())
        .call(g => g.select(".tick:last-of-type").append(function(this: SVGGElement) {
          const label = foCreateAxisLabel(me.props.params_def[me.state.axis_y], me.props.context_menu_ref);
          d3.select(label).attr("y", `${-this.transform.baseVal[0].matrix.f + 10}`);
          return label;
        })
            .attr("x", 3)
            .attr("text-anchor", "start")
            .attr("font-weight", "bold")
            .classed("plotxy-label", true))
        .attr("font-size", null)
        .call(g => g.selectAll(".plotxy-label").each(function() { foDynamicSizeFitContent(this); }));
      xAxis = g => g
        .attr("transform", `translate(0,${me.state.height - margin.bottom})`)
        .call(d3.axisBottom(x_scale).ticks(1+me.state.width / 80).tickSizeInner(margin.bottom + margin.top - me.state.height))
        .call(g => g.select(".tick:last-of-type").each(function(this: SVGGElement) {
          const fo = foCreateAxisLabel(me.props.params_def[me.state.axis_x], me.props.context_menu_ref, /* label */ null);
          d3.select(fo)
            .attr("y", 40)
            .attr("text-anchor", "end")
            .attr("font-weight", "bold")
            .classed("plotxy-label", true);
          const clone = this.cloneNode(false);
          clone.appendChild(fo);
          this.parentElement.appendChild(clone);
        }))
        // Make odd ticks below (to prevent overlap when very long labels)
        .call(g => g
          .selectAll(".tick")
          .each(function(this: SVGGElement, d: string, i: number) {
            const line = this.children[0] as SVGLineElement;
            if (this.childElementCount == 2 && (this.children[1] as SVGTextElement).textLength.baseVal.value && line.nodeName == "line") {
              this.transform.baseVal.getItem(0).matrix.f += 20 * (i % 2);
              line.setAttribute("y2", `${parseFloat(line.getAttribute("y2")) - 20 * (i % 2)}`);
            }
          })
        )
        .attr("font-size", null)
        .call(g => g.selectAll(".plotxy-label").each(function() { foDynamicSizeFitContent(this); }));
      div.selectAll("canvas")
        .attr("width", me.state.width - margin.left - margin.right)
        .attr("height", me.state.height - margin.top - margin.bottom);
      div.selectAll("svg")
        .attr("width", me.state.width)
        .attr("height", me.state.height);
      div.style("height", me.state.height + "px");
      div.selectAll('canvas').style('margin', margin.top + 'px ' + margin.right + 'px ' + margin.bottom + 'px ' + margin.left + 'px');

      redraw_axis();
    }