'Graphs in HTML with data from given file
I have a simple program for displaying the data in a graph: *
> <!DOCTYPE html> <html lang="cs"> <script > src="https://cdn.plot.ly/plotly-latest.min.js"></script> <body> <div > id="mujGraf" style="width:100%;max-width:700px"></div> <script> > var xArray = [50,60,70,80,90,100,110,120,130,140,150]; > var yArray = [7,8,8,9,9,9,10,11,14,14,15]; > var x2Array = [60,70,80,100,110,120,150]; > var y2Array = [7,8,9,11,14,14,15]; > // Define Data > var data = [ > {x: xArray, y: yArray, mode:"lines"}, > {x: x2Array, y: y2Array, mode:"lines"} > ]; > // Define Layout > var layout = { > xaxis: {range: [40, 160], title: "hodnoty X"}, > yaxis: {range: [5, 16], title: "hodnoty Y"}, > title: "hodnoty nejakych dat..." > }; > // Display using Plotly > graf = Plotly.newPlot("mujGraf", data, layout); </script> </body> </html>
But I don't know, how to insert given values from .txt - here is example of y-values: 5; 8; 10; 12; 9; 16; 14
Then should be also generated the x-values from 1 to the number of y-values (in this case it is 7).
Could someone tell me how to insert data from file? Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
