Published
Edited
Feb 26, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = {
const D = propeller.D;
const [beta1, beta2] = [propeller.beta1, propeller.beta1];
const [gamma1, gamma2] = [propeller.gamma1, propeller.gamma2];
let result = [];

var kt = J => {
return beta1 - beta2 * J;
};

var kq = J => {
return gamma1 - gamma2 * J;
};

var eff = (J, kt, kq) => {
return (kt * J) / (2 * Math.PI * kq);
};

var calculateOutput = J => {
const KT = kt(J);
const KQ = kq(J);
const EFF = eff(J, KT, KQ);

return { x: J, y: KT, z: 10 * KQ, w: EFF };
};

let j = 0;

do {
result.push(calculateOutput(j));
j = j + 0.01;
} while (j <= 1.0);

return result;
}
Insert cell
line1 = d3
.line()
.x(d => x(d.x))
.y(d => y(d.y))
Insert cell
line2 = d3
.line()
.x(d => x(d.x))
.y(d => y(d.z))
Insert cell
line3 = d3
.line()
.x(d => x(d.x))
.y(d => y(d.w))
Insert cell
x = d3
.scaleLinear()
.domain(d3.extent(data, d => d.x))
.range([margin.left, width - margin.right])
Insert cell
y = d3
.scaleLinear()
.domain([0, d3.max(data, d => d3.max([d.z, d.z]))])
.nice()
.range([height - margin.bottom, margin.top])
Insert cell
xAxis = g =>
g.attr("transform", `translate(0,${height - margin.bottom})`).call(
d3
.axisBottom(x)
.ticks(width / 100)
.tickSizeOuter(0)
)
Insert cell
yAxis = g =>
g
.attr("transform", `translate(${margin.left},0)`)
.call(d3.axisLeft(y))
.call(g => g.select(".domain").remove())
.call(g =>
g
.select(".tick:last-of-type text")
.clone()
.attr("x", 3)
.attr("text-anchor", "start")
.attr("font-weight", "bold")
.text(data.z)
)
.call(d3.axisLeft(y).tickSizeOuter(0))
Insert cell
margin = ({ top: 20, right: 30, bottom: 30, left: 40 })
Insert cell
height = width / 2
Insert cell
appendLabel = e => g => {
e.forEach((el, i) => {
g.append("circle")
.attr("cx", width - 150)
.attr("cy", .1 * height + 30 * i)
.attr("r", 6)
.style("fill", el.color);

g.append("text")
.attr("x", width - 130)
.attr("y", .1 * height + 30 * i)
.text(el.title)
.style("font-size", "15px")
.attr("alignment-baseline", "middle");
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more