-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplotly.ts
More file actions
67 lines (57 loc) · 1.34 KB
/
plotly.ts
File metadata and controls
67 lines (57 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { Datas, Deplot } from '../mod.ts'
function editablePlot() {
const trace1: Plotly.Data = {
x: [0, 1, 2, 3, 4],
y: [1, 5, 3, 7, 5],
mode: 'lines+markers',
type: 'scatter',
}
const trace2: Plotly.Data = {
x: [1, 2, 3, 4, 5],
y: [4, 0, 4, 6, 8],
mode: 'lines+markers',
type: 'scatter',
}
const data = [trace1, trace2]
const layout: Partial<Plotly.Layout> = {
title: 'Click Here<br>to Edit Chart Title',
}
const datas: Datas<'Plotly'> = { data, layout, config: { editable: true } }
new Deplot('Plotly', {
title: 'ChartJs line plot',
size: { width: 800, height: 800 },
}).plot(datas)
}
function barPlot() {
const trace1: Plotly.Data = {
x: ['Zebras', 'Lions', 'Pelicans'],
y: [90, 40, 60],
type: 'bar',
name: 'New York Zoo',
}
const trace2: Plotly.Data = {
x: ['Zebras', 'Lions', 'Pelicans'],
y: [10, 80, 45],
type: 'bar',
name: 'San Francisco Zoo',
}
const data = [trace1, trace2]
const layout: Partial<Plotly.Layout> = {
title: 'Hide the Modebar',
showlegend: true,
}
const datas: Datas<'Plotly'> = { data, layout, config: { editable: true } }
const deplot = new Deplot('Plotly', {
title: 'ChartJs line plot',
size: { width: 700 },
theme: 'auto',
})
deplot.plot(datas)
setTimeout(() => {
console.log(`closing plot`)
deplot.close()
}, 5000)
}
editablePlot()
barPlot()
Deplot.wait()