From 6b3f4b1033dbeda5d5306b6267acf9f5b5f00c19 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Wed, 20 Apr 2011 09:03:19 +0200 Subject: [PATCH] #3605: cleaning up burndown frontend code * removed unneeded ruby vars * moved dataset color setting into method * set min value on x axis so that 1 (first day) is min even if no series is plotted --- .../rb_burndown_charts/_burndown.html.erb | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/app/views/rb_burndown_charts/_burndown.html.erb b/app/views/rb_burndown_charts/_burndown.html.erb index 545f85883d..4ad43bd076 100644 --- a/app/views/rb_burndown_charts/_burndown.html.erb +++ b/app/views/rb_burndown_charts/_burndown.html.erb @@ -1,7 +1,3 @@ -<%- charts = burndown.is_a?(Array) ? burndown : [burndown] %> -<%- dataseries = charts[0].series(:all).keys %> -<%- chart = charts[0] %> - <%= stylesheet_link_tag 'jqplot.css', :plugin => 'redmine_backlogs' %> <%= javascript_include_tag_backlogs 'lib/jquery.js' %> @@ -13,13 +9,16 @@ jQuery(function ($) { var datasets; - datasets = { <%= burndown_dataseries(chart).join(', ') %> }; + datasets = { <%= burndown_dataseries(burndown).join(', ') %> }; - var i = 0; - $.each(datasets, function(key, val) { - val.color = i; - ++i; - }); + function setDatasetColor() { + var i = 0; + + $.each(datasets, function(key, val) { + val.color = i; + ++i; + }); + } function plotAccordingToChoices() { var data = []; @@ -43,17 +42,19 @@ if (data.length > 0){ $.plot($(".burndown_chart"), data, { yaxis: { min: 0, - ticks: [ <%= burndown_yaxis_labels([chart.max[:hours], chart.max[:points]].max) %> ] }, + ticks: [ <%= burndown_yaxis_labels([burndown.max[:hours], burndown.max[:points]].max) %> ] }, xaxis: { - ticks: [<%= burndown_xaxis_labels(chart) %>], + ticks: [<%= burndown_xaxis_labels(burndown) %>], tickDecimals: 0, - max: <%= chart.days.length + 1 %> + max: <%= burndown.days.length + 1 %>, + min: 1 } }); }; }; $(document).ready(function(){ + setDatasetColor(); $('#charts').height(470); //haven't figured out yet how to do this with css $('.burndown_control input').click(plotAccordingToChoices);