Reputation: 126
d3.select('svg')
.append('rect')
.attr('width', 50)
.attr('height', 50)
.style('fill', '#BFDEFF')
.on('mouseover', function () {
d3.select(this).transition().style('fill', '2B24FF');
})
.on('mouseout', function () {
d3.select(this).transition().style('fill', 'BFDEFF');
});
Transition seems to not be taken into account, the change happens instantly. What am I obviously missing here?
Upvotes: 1
Views: 206
Reputation: 109282
You're using two different types of strings to specify the colours (with and without #
). D3 doesn't know how to interpolate between those different types. Works if you use the same:
.style('fill', '#BFDEFF')
.on('mouseover', function () {
d3.select(this).transition().style('fill', '#2B24FF');
})
.on('mouseout', function () {
d3.select(this).transition().style('fill', '#BFDEFF');
});
Complete example here.
Upvotes: 1