Don't move graph when replotting
This commit is contained in:
parent
f2421426fc
commit
fce4a30e99
1 changed files with 16 additions and 11 deletions
|
@ -29,18 +29,23 @@ function defineVars(vars) {
|
||||||
|
|
||||||
function plot(target, fns, deps, [xDomain, yDomain] = [[-1, 9], [-1, 9]]) {
|
function plot(target, fns, deps, [xDomain, yDomain] = [[-1, 9], [-1, 9]]) {
|
||||||
const depsEl = deps.map(document.querySelector.bind(document));
|
const depsEl = deps.map(document.querySelector.bind(document));
|
||||||
const plot = () => {
|
|
||||||
functionPlot({
|
const data = () => fns(...(depsEl.map(el => parseFloat(el.value)))).map(fn => ({
|
||||||
|
fn, graphType: 'polyline'
|
||||||
|
}));
|
||||||
|
|
||||||
|
const opts = {
|
||||||
target,
|
target,
|
||||||
width: 600,
|
width: 600,
|
||||||
height: 400,
|
height: 400,
|
||||||
xAxis: { domain: xDomain },
|
xAxis: { domain: xDomain },
|
||||||
yAxis: { domain: yDomain },
|
yAxis: { domain: yDomain },
|
||||||
grid: true,
|
grid: true
|
||||||
data: fns(...(depsEl.map(el => parseFloat(el.value)))).map(fn => ({
|
};
|
||||||
fn, graphType: 'polyline'
|
|
||||||
}))
|
const plot = () => {
|
||||||
});
|
opts.data = data();
|
||||||
|
functionPlot(opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
depsEl.forEach(el => {
|
depsEl.forEach(el => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue