dimanche 1 novembre 2020

Redraw graph based on user input

I'm just starting using javavscript and I need a script that let's the user input the function to graph. I'm using funtionplot of d3 to draw the graph. I have

let myChart = document.getElementById('myChart').getContext('2d')

let chart = functionPlot({
    target: '#root',
    data: [{
        fn: `${variableenterbyuser}`
    }],
    grid: true,
    yAxis: {domain: [-1, 1]},
    xAxis: {domain: [0, 2*Math.PI]}
});

I need to create a form that let the user enter a function ex: x*x and plot it in the graph.

How can I do that?

Thanks




Aucun commentaire:

Enregistrer un commentaire