-
Notifications
You must be signed in to change notification settings - Fork 0
/
app_d3_albums.js
36 lines (32 loc) · 1 KB
/
app_d3_albums.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
var svgAppendAlbums = function(topAlbumsArray){
d3.select('.d3-data-album')
.selectAll('div')
.data(topAlbumsArray)
.enter().append('div')
.attr('class', 'chart')
.style('width', function(d) { return d.playcount + "px"; })
.style('opacity', .7)
.style('background-color', '#e31b23')
.text(function(d) { return d.artist + ' - ' + d.name; })
.on('mouseenter', function(d){
var plays = d.playcount;
d3.select(this).append('playcount')
.attr('class', 'addPlays')
.style('display', 'none')
.text(plays);
$('.chart').tipsy({
gravity: 'w',
html: true,
title: function(plays) {
var showPlays = $(this).find('.addPlays').text();
return showPlays;
}
});
})
.on('mouseout', function(d){
// d3.select('.text').remove();
d3.select(this)
.select('.addPlays')
.remove();
});
};