-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbar.view.ts
More file actions
101 lines (84 loc) · 2.19 KB
/
bar.view.ts
File metadata and controls
101 lines (84 loc) · 2.19 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
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
namespace $.$$ {
const Payload = $mol_data_record({
x: $mol_data_array( $mol_data_number ),
dx: $mol_data_number,
y: $mol_data_array( $mol_data_number ),
xtitle: $mol_data_optional( $mol_data_string ),
ytitle: $mol_data_optional( $mol_data_string ),
})
export const $mpds_visavis_plot_bar_json = $mol_data_record({
payload: Payload,
payload2: $mol_data_optional( Payload ),
})
export class $mpds_visavis_plot_bar extends $.$mpds_visavis_plot_bar {
json() {
return $mpds_visavis_plot_bar_json( this.plot_raw().jsons()[0] )
}
@ $mol_mem
subscribe_click() {
const plotly_root = this.Plotly_root()
if (! plotly_root ) return
const json = this.json() as any
if (json.payload2 && json.p1ayload2.x && json.payload2.y) return
const paths = $mpds_visavis_lib_plotly.d3.select( plotly_root ).selectAll( 'g.point path' )
const that = this
paths.on('click', function(this: any, event: MouseEvent){
const selection = $mpds_visavis_lib_plotly.d3.select(this)
const value = selection.data()[0].x
that.bar_click( { facet: "years", value } )
});
}
@ $mol_mem
layout() {
const json = this.json()
return {
showlegend: json.payload2 ? true : false,
legend: {
x: 0,
y: 1,
font: {
size: 17,
},
},
xaxis: {
autorange: true,
showgrid: false,
showline: true,
showticklabels: true,
zeroline: false,
ticklen: 4,
dtick: json.payload.dx || 0.05,
title: json.payload.xtitle
//rangemode: "nonnegative"
},
yaxis: {
fixedrange: true,
autorange: true,
showgrid: true,
showline: false,
showticklabels: true,
ticklen: 0,
title: json.payload.ytitle,
rangemode: "nonnegative",
type: "log",
tickfont: {
size: 17,
},
},
font: {
family: 'inherit',
size: 13,
}
}
}
@ $mol_mem
data() {
const json = this.json()
const payload = [ { type: "bar", x: json.payload.x, y: json.payload.y, name: 'bar' } ]
if (json.payload2 && json.payload2.x && json.payload2.y){
payload.push( { type: "bar", x: json.payload2.x, y: json.payload2.y, name: 'bar' } );
}
return payload
}
}
}