|
1 | | -// import { Plotly } from '../deps.ts' |
2 | | - |
3 | | -// function editablePlot() { |
4 | | -// const trace1: Plotly.Data = { |
5 | | -// x: [0, 1, 2, 3, 4], |
6 | | -// y: [1, 5, 3, 7, 5], |
7 | | -// mode: 'lines+markers', |
8 | | -// type: 'scatter' |
9 | | -// } |
10 | | - |
11 | | -// const trace2: Plotly.Data = { |
12 | | -// x: [1, 2, 3, 4, 5], |
13 | | -// y: [4, 0, 4, 6, 8], |
14 | | -// mode: 'lines+markers', |
15 | | -// type: 'scatter' |
16 | | -// } |
17 | | - |
18 | | -// const data = [trace1, trace2] |
19 | | -// const layout: Partial<Plotly.Layout> = {title: 'Click Here<br>to Edit Chart Title'} |
20 | | - |
21 | | -// Plotly.newPlot('myDiv', data, layout, {editable: true}) |
22 | | -// } |
23 | | - |
24 | | -// async function barPlot() { |
25 | | -// const trace1: Plotly.Data = { |
26 | | -// x:['Zebras', 'Lions', 'Pelicans'], |
27 | | -// y: [90, 40, 60], |
28 | | -// type: 'bar', |
29 | | -// name: 'New York Zoo' |
30 | | -// } |
31 | | - |
32 | | -// const trace2: Plotly.Data = { |
33 | | -// x:['Zebras', 'Lions', 'Pelicans'], |
34 | | -// y: [10, 80, 45], |
35 | | -// type: 'bar', |
36 | | -// name: 'San Francisco Zoo' |
37 | | -// } |
38 | | - |
39 | | -// const data = [trace1, trace2] |
40 | | - |
41 | | -// const layout: Partial<Plotly.Layout> = { |
42 | | -// title: 'Hide the Modebar', |
43 | | -// showlegend: true |
44 | | -// } |
45 | | - |
46 | | -// console.log(await Plotly.newPlot('myDiv', data, layout, {displayModeBar: false})) |
47 | | -// } |
48 | | - |
49 | | -// editablePlot() |
50 | | -// barPlot() |
| 1 | +import { Deplot } from '../mod.ts'; |
| 2 | +import { Datas } from '../src/types.ts'; |
| 3 | + |
| 4 | +const deplot = new Deplot('Plotly'); |
| 5 | + |
| 6 | +function editablePlot() { |
| 7 | + const trace1: Plotly.Data = { |
| 8 | + x: [0, 1, 2, 3, 4], |
| 9 | + y: [1, 5, 3, 7, 5], |
| 10 | + mode: 'lines+markers', |
| 11 | + type: 'scatter', |
| 12 | + }; |
| 13 | + |
| 14 | + const trace2: Plotly.Data = { |
| 15 | + x: [1, 2, 3, 4, 5], |
| 16 | + y: [4, 0, 4, 6, 8], |
| 17 | + mode: 'lines+markers', |
| 18 | + type: 'scatter', |
| 19 | + }; |
| 20 | + |
| 21 | + const data = [trace1, trace2]; |
| 22 | + const layout: Partial<Plotly.Layout> = { |
| 23 | + title: 'Click Here<br>to Edit Chart Title', |
| 24 | + }; |
| 25 | + const datas: Datas = { data, layout, config: { editable: true } }; |
| 26 | + |
| 27 | + deplot.plot(datas, { title: 'ChartJs line plot', size: [800, 800] }); |
| 28 | +} |
| 29 | + |
| 30 | +function barPlot() { |
| 31 | + const trace1: Plotly.Data = { |
| 32 | + x: ['Zebras', 'Lions', 'Pelicans'], |
| 33 | + y: [90, 40, 60], |
| 34 | + type: 'bar', |
| 35 | + name: 'New York Zoo', |
| 36 | + }; |
| 37 | + |
| 38 | + const trace2: Plotly.Data = { |
| 39 | + x: ['Zebras', 'Lions', 'Pelicans'], |
| 40 | + y: [10, 80, 45], |
| 41 | + type: 'bar', |
| 42 | + name: 'San Francisco Zoo', |
| 43 | + }; |
| 44 | + |
| 45 | + const data = [trace1, trace2]; |
| 46 | + const layout: Partial<Plotly.Layout> = { |
| 47 | + title: 'Hide the Modebar', |
| 48 | + showlegend: true, |
| 49 | + }; |
| 50 | + const datas: Datas = { data, layout, config: { editable: true } }; |
| 51 | + |
| 52 | + deplot.plot(datas, { title: 'ChartJs line plot', size: [800, 600] }); |
| 53 | +} |
| 54 | + |
| 55 | +editablePlot(); |
| 56 | +barPlot(); |
0 commit comments