Skip to content

Commit babe22f

Browse files
author
Nikita Stepochkin
committed
add index.html
0 parents  commit babe22f

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Default ignored files
2+
/shelf/
3+
/workspace.xml
4+
# Editor-based HTTP Client requests
5+
/httpRequests/
6+
# Datasource local storage ignored files
7+
/dataSources/
8+
/dataSources.local.xml
9+
# Zeppelin ignored files
10+
/ZeppelinRemoteNotebooks/

index.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Plotly</title>
6+
<script src="https://cdn.plot.ly/plotly-2.32.0.min.js"></script>
7+
</head>
8+
<body>
9+
<h1>Plotly json visualizer</h1>
10+
<div id="div-plotly"></div>
11+
<div>
12+
<label for="json-input">JSON Data:</label><br>
13+
<textarea id="json-input" rows="10" cols="50"></textarea><br>
14+
<label for="json-path">JSON Path (optional):</label><br>
15+
<input type="text" id="json-path" placeholder="e.g., data.chart"><br><br>
16+
<button onclick="reloadPlot()">Reload Plot</button>
17+
</div>
18+
<script>
19+
20+
function reloadPlot() {
21+
const jsonData = document.getElementById('json-input').value;
22+
const jsonPath = document.getElementById('json-path').value;
23+
24+
try {
25+
let plotData = JSON.parse(jsonData);
26+
27+
if (jsonPath) {
28+
const pathParts = jsonPath.split('.');
29+
for (const part of pathParts) {
30+
plotData = plotData[part];
31+
}
32+
}
33+
34+
Plotly.newPlot(document.getElementById('div-plotly'), plotData);
35+
} catch (error) {
36+
console.error('Error:', error);
37+
alert('Invalid JSON data or JSON path');
38+
}
39+
}
40+
41+
</script>
42+
</body>
43+
</html>

0 commit comments

Comments
 (0)