From 4944dc947326f58a548ff8430889162e6f9339be Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 20 Apr 2011 23:00:23 +0200 Subject: [PATCH] improving burndown series functionality * points are displayed to depict series points * hovering over a point shows tooltip with precise value --- .../rb_burndown_charts/_burndown.html.erb | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/app/views/rb_burndown_charts/_burndown.html.erb b/app/views/rb_burndown_charts/_burndown.html.erb index 4d133b1ab8..22ad990039 100644 --- a/app/views/rb_burndown_charts/_burndown.html.erb +++ b/app/views/rb_burndown_charts/_burndown.html.erb @@ -9,12 +9,15 @@ jQuery(function ($) { var Burndown = { datasets: { <%= dataseries(burndown).join(', ') %> }, + previousPoint: null, setDatasetColor: function () { var i = 0; $.each(Burndown.datasets, function (key, val) { val.color = i; + val.points = {show: true, radius: 2}; + val.lines = {show: true}; ++i; }); }, @@ -47,15 +50,51 @@ tickDecimals: 0, max: <%= burndown.days.length + 1 %>, min: 1 - } + }, + grid: { hoverable: true, clickable: true } }); } }, + showTooltip: function(x, y, contents) { + $('
' + contents + '
').css( { + position: 'absolute', + display: 'none', + top: y + 5, + left: x + 5, + border: '1px solid #fdd', + padding: '2px', + 'background-color': '#fee', + opacity: 0.80 + }).appendTo("body").css('z-index', 2000).fadeIn(200); + }, + + + showTooltipOnHover: function (event, pos, item) { + + if (item) { + if (Burndown.previousPoint != item.dataIndex) { + Burndown.previousPoint = item.dataIndex; + + $("#tooltip").remove(); + var x = item.datapoint[0].toFixed(0), + y = item.datapoint[1].toFixed(0); + + Burndown.showTooltip(item.pageX, item.pageY, + item.series.label + ": " + y); + } + } + else { + $("#tooltip").remove(); + Burndown.previousPoint = null; + } + }, + init: function () { Burndown.setDatasetColor(); $('.burndown_control input').click(Burndown.plotAccordingToChoices); + $(".burndown_chart").bind("plothover", Burndown.showTooltipOnHover); Burndown.plotAccordingToChoices(); }