-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_trace.html
138 lines (114 loc) · 4.43 KB
/
test_trace.html
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<head>
<!-- Plotly.js -->
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<!-- jquery -->
</head>
<div id="myDiv" style="width:100%;height:500px;"></div>
<script>
/// Do the animation independent of the object and use the .animate method. This way I can access it through scroll by simply calling.the function.
Plotly.d3.csv('https://raw.githubusercontent.com/arundhatibala/absalom/main/data/absalom_plot_chronology_52723.csv', function (err, rows) {
function unpack(rows, key) {
return rows.map(function (row) { return row[key]; });
}
var button_layer_2_height = 1.2
var y_narrated = unpack(rows, 'Narrated').map(x => parseInt(x))
var y_told = unpack(rows, 'Told').map(x => parseInt(x))
var y_remembered = unpack(rows, 'Remembered').map(x => parseFloat(x))
var y_hypothesized = unpack(rows, 'Hypothesized').map(x => parseInt(x))
var y_narratedconscious = unpack(rows, 'NarratedConscious').map(x => parseInt(x))
var plot_order = unpack(rows, 'values')
var y_other = unpack(rows, 'Other').map(x => parseFloat(x))
var y_all = unpack(rows, 'All').map(x => parseFloat(x))
/*y_narrated = narrated.filter((v, i) => i % 2) //This is the default y variable
y_hypothesized = hypothesized.filter((v, i) => i % 2)
y_narratedconscious = narratedconscious.filter((v, i) => i % 2)
y_remembered = remembered.filter((v, i) => i % 2)
y_told = told.filter((v, i) => i % 2)
plot_order = x_axis.filter((v, i) => !(i % 2))*/
/*var high_ave = arrAvg(high)
var high_max = Math.max(...high)
var low_ave = arrAvg(low)
var low_min = Math.min(...low)
*/
var frames = [
{
name: 'all',
data: [
{
type: "scatter",
mode: "markers",
x: plot_order,
y: y_all,
name: "All",
marker: { color: '#000066', opacity: .5 }
}]
},
{
name: 'narrated',
data: [
{
x: plot_order,
y: y_narrated,
mode: 'markers',
name: 'Narrated',
marker: { color: '#1b9e77', opacity: .5 }
}]
},
{name: 'told',
data: [
{
type: "scatter",
mode: "markers",
x: plot_order,
y: y_told,
name: "Told",
marker: { color: '#d95f02', opacity: .5 }
}]
},
{
name: 'other',
data: [
{
type: "scatter",
mode: "markers",
x: plot_order,
y: y_other,
name: "Other",
marker: { color: '#7570b3', opacity: .5 }
}]
}
]
console.log(frames[0].data[0].y)
console.log(y_all)
// console.log(frames[0].data[1].y)
Plotly.newPlot('myDiv', [{
x: plot_order,
y: y_all,
type: "scatter",
mode: "markers",
marker: { color: '#000099', opacity: .5 }
}], {
updatemenus: [
{
buttons: [
{ method: 'animate', args: [['all']], label: 'All' },
{ method: 'animate', args: [['narrated']], label: 'narrated' },
{ method: 'animate', args: [['told']], label: 'told' },
{ method: 'animate', args: [['other']], label: 'other' }
]
,
direction: 'left',
pad: { 'r': 10, 't': 10 },
showactive: true,
type: 'buttons',
x: 0.1,
xanchor: 'left',
y: button_layer_2_height,
yanchor: 'top'
}
]
}).then(function () {
Plotly.addFrames('myDiv', frames);
});
})
</script>