1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8"/>
- <title>SPM Plot</title>
- <script src="js/plotly.min.js"></script>
- </head>
- <body>
- <div id="plotly" style="height: 650px;width: 800px;"></div>
- <script type="text/javascript">
- var queries = location.search.split("?")[1];
- if (typeof(queries) === "undefined") {
- alert("No data!");
- }
- var query = queries.split("&");
- for (var i = 0; i < query.length; i++) {
- var datatype = query[i].split("=")[0];
- var filename = query[i].split("=")[1];
- var ext = filename.split('.').pop();
- if (ext === "js") {
- var firstScript = document.getElementsByTagName('script')[0];
- var js = document.createElement('script');
- js.src = filename;
- var data = {}, layout = {title: ""}, options = {};
- js.onload = function () {
- Plotly.plot("plotly", data, layout, options);
- }
- firstScript.parentNode.insertBefore(js, firstScript);
- } else {
- Plotly.d3.json(filename, function(err, fig) {
- if (err) alert("Could not read data!");
- if (fig.layout === "undefined") {
- fig.layout = {title: ""};
- }
- if (fig.options === "undefined") {
- fig.options = {};
- }
- Plotly.plot("plotly", fig.data, fig.layout, fig.options);
- });
- }
- }
- </script>
- </body>
- </html>
|