Download:
child 305:b920a1f9267f
parent 303:cfaaf0b0ec71
304:e8895f37572b
Anton Shestakov <av6@dwimlabs.net>, Sat, 23 Sep 2017 13:07:47 +0800
viewer: the rest of the hover line bits for chart

1 файлов изменено, 19 вставок(+), 0 удалений(-) [+]
static/candolint.js file | annotate | diff | comparison | revisions
--- a/static/candolint.js Sat Sep 23 13:00:12 2017 +0800
+++ b/static/candolint.js Sat Sep 23 13:07:47 2017 +0800
@@ -120,6 +120,25 @@
.attr('cx', function(d) { return x(d.ordinal); })
.attr('cy', function(d) { return series.axis(d[series.name]); });
});
+
+ var rectW = x.step();
+ g.append('g')
+ .attr('fill-opacity', 0)
+ .selectAll('rect')
+ .data(data.points)
+ .enter()
+ .append('rect')
+ .attr('x', function(d) { return x(d.ordinal) - rectW / 2 + 0.5; })
+ .attr('y', -margin.top)
+ .attr('height', height + margin.top + margin.bottom)
+ .attr('width', rectW)
+ .on('mouseover', function(d) {
+ var hx = x(d.ordinal) + 0.5;
+ hover.attr('opacity', 1).attr('x1', hx).attr('x2', hx);
+ })
+ .on('mouseout', function(d) {
+ hover.attr('opacity', 0);
+ });
};
$(window).on('resize', function() {
if (+svg.attr('width') !== $container.width()) {