-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
39 lines (34 loc) · 1.08 KB
/
main.js
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
function main()
{
let width = 200
let height = 200
let svg = d3.select("body").selectAll("svg")
.data([null])
.enter().append("svg")
.attr("width", width)
.attr("height", height)
.style('position', 'absolute')
let rect = svg.append('rect')
.attr('id', 'Myrect')
.attr('width', 50)
.attr('height', 50)
.attr('opacity', 0.1)
.style('transform', 'translate(60px,30px)')
let icons = [{
icon: 'fa-arrows-h',
title: 'Horizontal',
click: function(){console.log('h')}
}, {
text: '2',
//icon: 'fa-arrows-v',
title: 'Vertical',
click: function(){console.log('v')}
}, {
icon: 'fa-sort-amount-desc',
title: 'Rank',
click: function(){console.log('r')}
}]
//$(rect.node()).d3_menu();
let menu = d3.menu().icons(icons).target(rect)/*.bind_event('click')*///.position({horizontal:'middle',vertical:'middle'})
rect.call(menu)
}