function ces(ori, eff, alpha, b) {
return 100 * Math.pow(alpha * Math.pow(ori/100, b) + (1 - alpha) * Math.pow(eff/100, b), 1/b);
}
function prob(L, thre, beta) {
return 1 / (1 + Math.exp(-beta * (L - thre)));
}
L = ces(ori, eff, alpha, b)
P = prob(L, thre, beta)
{
const width = 100;
const height = 50;
const y = d3.scaleLinear([100, 0], [0, height]);
const svg = d3.create("svg").attr("viewBox", [0, 0, width, height]);
svg.append("rect")
.attr("x", width / 3)
.attr("y", 0)
.attr("width", width / 3)
.attr("height", height)
.attr("fill", "#eee")
.attr("stroke", "none");
const water = svg.append("rect")
.attr("x", width / 3)
.attr("width", width / 3)
.attr("fill", "steelblue");
water.attr("y", y(L))
.attr("height", height - y(L));
svg.append("line")
.attr("x1", width / 3)
.attr("x2", width * 2 / 3)
.attr("y1", y(thre))
.attr("y2", y(thre))
.attr("stroke", "red")
.attr("stroke-width", 2);
svg.append("text")
.text(d3.format(".2f")(P))
.attr("x", width / 6)
.attr("y", height / 2)
.attr("text-anchor", "middle")
.attr("font-size", 14)
.attr("fill", "black");
return svg.node();
}