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]]) {
|
||||
const depsEl = deps.map(document.querySelector.bind(document));
|
||||
|
||||
const data = () => fns(...(depsEl.map(el => parseFloat(el.value)))).map(fn => ({
|
||||
fn, graphType: 'polyline'
|
||||
}));
|
||||
|
||||
const opts = {
|
||||
target,
|
||||
width: 600,
|
||||
height: 400,
|
||||
xAxis: { domain: xDomain },
|
||||
yAxis: { domain: yDomain },
|
||||
grid: true
|
||||
};
|
||||
|
||||
const plot = () => {
|
||||
functionPlot({
|
||||
target,
|
||||
width: 600,
|
||||
height: 400,
|
||||
xAxis: { domain: xDomain },
|
||||
yAxis: { domain: yDomain },
|
||||
grid: true,
|
||||
data: fns(...(depsEl.map(el => parseFloat(el.value)))).map(fn => ({
|
||||
fn, graphType: 'polyline'
|
||||
}))
|
||||
});
|
||||
opts.data = data();
|
||||
functionPlot(opts);
|
||||
}
|
||||
|
||||
depsEl.forEach(el => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue