From 2f2547dd6034d2d4043e827e96447338d8203e0d Mon Sep 17 00:00:00 2001 From: Ben Hockey Date: Fri, 17 Feb 2012 10:39:43 -0500 Subject: [PATCH 01/10] remove redundant "tickets" from labels in legends. fixes #3. --- ticketgraph/htdocs/ticketgraph.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ticketgraph/htdocs/ticketgraph.js b/ticketgraph/htdocs/ticketgraph.js index 02d9925..bbccbe0 100644 --- a/ticketgraph/htdocs/ticketgraph.js +++ b/ticketgraph/htdocs/ticketgraph.js @@ -5,27 +5,27 @@ $(document).ready(function() { [ { data: closedTickets, - label: 'Closed tickets', + label: 'Closed', bars: barSettings, color: 1 }, { data: openedTickets, - label: 'New tickets', + label: 'New', bars: barSettings, color: 2, stack: true }, { data: reopenedTickets, - label: 'Reopened tickets', + label: 'Reopened', bars: barSettings, color: 3, stack: true }, { data: openTickets, - label: 'Open tickets', + label: 'Open', yaxis: 2, lines: { show: true }, color: 0 From c13b84e4118cce9518f712bd400c484b10c4f945 Mon Sep 17 00:00:00 2001 From: EffEPi Date: Thu, 17 Mar 2016 12:42:03 -0400 Subject: [PATCH 02/10] Update setup.py --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 536a771..dbd10a1 100644 --- a/setup.py +++ b/setup.py @@ -8,10 +8,10 @@ packages = ['ticketgraph'], package_data = { 'ticketgraph' : [ 'htdocs/*.*', 'templates/*.*' ] }, - author = 'Colin Snover', - author_email = 'tracplugins@zetafleet.com', + author = 'Fabrizio Parrella', + author_email = 'fabrizio@bibivu.com', description = 'Graphs Trac tickets over time', - long_description = 'A Trac plugin that displays a visual graph of ticket changes over time.', + long_description = 'A Trac plugin that displays a visual graph of ticket changes over time, based on Colin Snover version.', license = 'MIT', keywords = 'trac plugin ticket statistics graph', classifiers = [ From cf41cf358086c9c57f36a55ab76bd763851c6698 Mon Sep 17 00:00:00 2001 From: EffEPi Date: Thu, 17 Mar 2016 12:43:31 -0400 Subject: [PATCH 03/10] Update ticketgraph.py --- ticketgraph/ticketgraph.py | 45 +++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/ticketgraph/ticketgraph.py b/ticketgraph/ticketgraph.py index ffd1f63..07eb5e5 100644 --- a/ticketgraph/ticketgraph.py +++ b/ticketgraph/ticketgraph.py @@ -46,10 +46,13 @@ def process_request(self, req): today = datetime.datetime.combine(datetime.date.today(), datetime.time(tzinfo=utc)) days = int(req.args.get('days', 30)) + stack_graph={}; + stack_graph['stack_graph'] = bool(int(req.args.get('sg', 0))) # These are in microseconds; the data returned is in milliseconds # because it gets passed to flot ts_start = to_utimestamp(today - datetime.timedelta(days=days)) ts_end = to_utimestamp(today) + 86400000000; + ts_utc_delta = math.ceil((datetime.datetime.utcnow()-datetime.datetime.now()).total_seconds())*1000; db = self.env.get_read_db() cursor = db.cursor() @@ -57,49 +60,66 @@ def process_request(self, req): series = { 'openedTickets': {}, 'closedTickets': {}, + 'workedTickets': {}, 'reopenedTickets': {}, 'openTickets': {} } # number of created tickets for the time period, grouped by day (ms) - cursor.execute('SELECT COUNT(DISTINCT id), FLOOR(time / 86400000000) * 86400000 ' \ +# cursor.execute('SELECT COUNT(DISTINCT id), FLOOR(time / 86400000000) * 86400000 ' \ + cursor.execute('SELECT COUNT(DISTINCT id),( UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000) ' \ 'AS date FROM ticket WHERE time BETWEEN %s AND %s ' \ 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) for count, timestamp in cursor: series['openedTickets'][float(timestamp)] = float(count) # number of reopened tickets for the time period, grouped by day (ms) - cursor.execute('SELECT COUNT(DISTINCT ticket), FLOOR(time / 86400000000) * 86400000 ' \ +# cursor.execute('SELECT COUNT(DISTINCT ticket), FLOOR(time / 86400000000) * 86400000 ' \ + cursor.execute('SELECT COUNT(DISTINCT ticket), UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000 ' \ 'AS date FROM ticket_change WHERE field = \'status\' AND newvalue = \'reopened\' ' \ 'AND time BETWEEN %s AND %s ' \ 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) for count, timestamp in cursor: series['reopenedTickets'][float(timestamp)] = float(count) + # number of worked tickets for the time period, grouped by day (ms) + cursor.execute('SELECT COUNT(DISTINCT ticket), UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000 ' \ + 'AS date FROM ticket_change WHERE ' \ + 'time BETWEEN %s AND %s ' \ + 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) + for count, timestamp in cursor: + series['workedTickets'][float(timestamp)] = float((1 if stack_graph['stack_graph'] else -1)*count) + + # number of closed tickets for the time period, grouped by day (ms) - cursor.execute('SELECT COUNT(DISTINCT ticket), FLOOR(time / 86400000000) * 86400000 ' \ +# cursor.execute('SELECT COUNT(DISTINCT ticket), FLOOR(time / 86400000000) * 86400000 ' \ + cursor.execute('SELECT COUNT(DISTINCT ticket), UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000 ' \ 'AS date FROM ticket_change WHERE field = \'status\' AND newvalue = \'closed\' ' \ 'AND time BETWEEN %s AND %s ' \ 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) for count, timestamp in cursor: - series['closedTickets'][float(timestamp)] = float(count) + series['closedTickets'][float(timestamp)] = float((1 if stack_graph['stack_graph'] else -1)*count) # number of open tickets at the end of the reporting period cursor.execute('SELECT COUNT(*) FROM ticket WHERE status <> \'closed\'') open_tickets = cursor.fetchone()[0] - open_ts = math.floor(ts_end / 1000) + open_ts = math.floor((ts_end) / 1000)+ts_utc_delta while open_ts >= math.floor(ts_start / 1000): if open_ts in series['closedTickets']: - open_tickets += series['closedTickets'][open_ts] + open_tickets += (1 if stack_graph['stack_graph'] else -1)*series['closedTickets'][open_ts] if open_ts in series['openedTickets']: open_tickets -= series['openedTickets'][open_ts] if open_ts in series['reopenedTickets']: open_tickets -= series['reopenedTickets'][open_ts] - series['openTickets'][open_ts] = open_tickets - open_ts -= 86400000 + series['openTickets'][open_ts-86400000] = open_tickets + + new_ts_utc_delta = math.ceil((datetime.datetime.utcfromtimestamp(open_ts/1000)-datetime.datetime.fromtimestamp(open_ts/1000)).total_seconds())*1000; + + open_ts -= 86400000 + ts_utc_delta - new_ts_utc_delta + ts_utc_delta = new_ts_utc_delta data = {} for i in series: @@ -107,10 +127,15 @@ def process_request(self, req): keys.sort() data[i] = [ (k, series[i][k]) for k in keys ] + data['openTickets_ts'] = open_ts-86400000 + data['openTickets_tickets'] = open_tickets + data['openTickets_days'] = days + add_script(req, 'ticketgraph/jquery.flot.min.js') +# add_script(req, 'http://people.iola.dk/olau/flot/jquery.flot.js') add_script(req, 'ticketgraph/jquery.flot.stack.min.js') add_script(req, 'ticketgraph/ticketgraph.js') add_script_data(req, data) + add_script_data(req, stack_graph) - return 'ticketgraph.html', { 'days': days }, None - + return 'ticketgraph.html', { 'days': days, 'sg': stack_graph['stack_graph'] }, None From ccdd20f0f82904838ea154894cac5f3666ccf144 Mon Sep 17 00:00:00 2001 From: EffEPi Date: Thu, 17 Mar 2016 12:44:08 -0400 Subject: [PATCH 04/10] Update ticketgraph.html --- ticketgraph/templates/ticketgraph.html | 39 +++++++++++++++++--------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/ticketgraph/templates/ticketgraph.html b/ticketgraph/templates/ticketgraph.html index cb21ad5..008a9bb 100644 --- a/ticketgraph/templates/ticketgraph.html +++ b/ticketgraph/templates/ticketgraph.html @@ -4,18 +4,29 @@ - - - Ticket Graph - ${Markup('<!--[if lt IE 7]>')} - - ${Markup('<![endif]-->')} - - -

Ticket Graph

-
-

Last ${days} days

-
-
- + + + Ticket Graph + ${Markup('<!--[if lt IE 7]>')} + + ${Markup('<![endif]-->')} + + +

Ticket Graph

+
+

Last ${days} days

+

+

+ Days Back: + + + +
+

+
+
+
+ From 6d186e4558ba253eb9294bda905b1304c695bf3d Mon Sep 17 00:00:00 2001 From: EffEPi Date: Thu, 17 Mar 2016 12:44:53 -0400 Subject: [PATCH 05/10] Update ticketgraph.js --- ticketgraph/htdocs/ticketgraph.js | 153 ++++++++++++++++++++++-------- 1 file changed, 115 insertions(+), 38 deletions(-) diff --git a/ticketgraph/htdocs/ticketgraph.js b/ticketgraph/htdocs/ticketgraph.js index d27708c..68f8658 100644 --- a/ticketgraph/htdocs/ticketgraph.js +++ b/ticketgraph/htdocs/ticketgraph.js @@ -1,40 +1,117 @@ +var plot = null; +var line_tick = 86400000; +if(typeof stack_graph!=='undefined'&&stack_graph==true){ + line_tick /= 3.5; + for(var k in closedTickets){ + closedTickets[k][0] += line_tick+5000000; + } + for(var k in workedTickets){ + workedTickets[k][0] += (line_tick+5000000)*2; + } +} $(document).ready(function() { - var graph = $('#placeholder').width(640).height(400), - barSettings = { show: true, barWidth: 86400000 }; - $.plot($('#placeholder'), - [ - { - data: closedTickets, - label: 'Closed', - bars: barSettings, - color: 1 - }, - { - data: openedTickets, - label: 'New', - bars: barSettings, - color: 2, - stack: true - }, - { - data: reopenedTickets, - label: 'Reopened', - bars: barSettings, - color: 3, - stack: true - }, - { - data: openTickets, - label: 'Open', - yaxis: 2, - lines: { show: true }, - color: 0 - } - ], - { - xaxis: { mode: 'time', minTickSize: [1, "day"] }, - yaxis: { min: 0, label: 'Tickets' }, - y2axis: { min: 0 }, - legend: { position: 'nw' } - }); + var graph = $('#placeholder').width(800).height(500), + barSettings = { show: true, barWidth: line_tick, align: 'center', stack: false}; + plot = $.plot($('#placeholder'), + [ + { + data: openedTickets, + label: 'New tickets', + color: '#66cd00', + stack: true, + idx: 0 + }, + { + data: reopenedTickets, + label: 'Reopened tickets', + color: '#458b00', + stack: true, + idx: 1 + }, + { + data: closedTickets, + label: 'Closed tickets', + color: '#8b0000', + idx: 2 + }, { + data: workedTickets, + label: 'Worked tickets', + color: '#45458b', + idx: 3 + }, + { + data: openTickets, + label: 'Open tickets', + yaxis: 2, + lines: { show: true, steps: false }, + bars: {show: false}, + shadowSize: 0, + color: '#333', + idx: 4 + } + ], + { + series:{ + bars: barSettings + }, + xaxis: { mode: 'time', minTickSize: [1, "day"] }, + grid: { hoverable: true }, + yaxis: { label: 'Tickets' }, + y2axis: { min: 0 }, + legend: { + container:$("#legend-container"), + position: 'ne', + labelFormatter: function(label, series){ + return ''+label+''; + } + } + }); + + $("
").css({ + position: "absolute", + display: "none", + border: "1px solid #fdd", + padding: "2px", + "background-color": "#fee", + opacity: 0.80 + }).appendTo("body"); + + + $("#placeholder").bind("plothover", function (event, pos, item) { + if (item) { + var x = item.datapoint[0], + y = Math.abs(item.datapoint[1]); + $("#tooltip").html(tracGraphTimeConverter(x) + '
' + item.series.label + " : " + y) + .css({top: item.pageY+5, left: item.pageX+5}) + .fadeIn(200); + } else { + $("#tooltip").hide(); + } + }); +// setTimeout(function(){tracGraphTogglePlot(2);},500); }); +function tracGraphTimeConverter(timestamp){ + var a = new Date(timestamp); + var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; + var year = a.getFullYear(); + var month = months[a.getMonth()]; + var date = a.getDate(); +// var hour = a.getHours(); +// var min = a.getMinutes(); +// var sec = a.getSeconds(); + var time = month + ' ' + date + ', ' + year; + return time; +} +function tracGraphTogglePlot(seriesIdx){ + var someData = plot.getData(); + if(typeof someData[seriesIdx].data_old === 'undefined'){ + someData[seriesIdx].data_old=someData[seriesIdx].data; + someData[seriesIdx].data=[]; + }else{ + someData[seriesIdx].data=someData[seriesIdx].data_old; + delete(someData[seriesIdx].data_old); + } + plot.setData(someData); +// plot.setupGrid(); + plot.draw(); +} From 7fda57de02c82a9a279f60234c6d096ecc1fa246 Mon Sep 17 00:00:00 2001 From: EffEPi Date: Wed, 23 Mar 2016 11:03:56 -0400 Subject: [PATCH 06/10] Reverting authorship information --- setup.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index dbd10a1..412e97a 100644 --- a/setup.py +++ b/setup.py @@ -8,10 +8,10 @@ packages = ['ticketgraph'], package_data = { 'ticketgraph' : [ 'htdocs/*.*', 'templates/*.*' ] }, - author = 'Fabrizio Parrella', - author_email = 'fabrizio@bibivu.com', + author = 'Colin Snover', + author_email = 'tracplugins@zetafleet.com', description = 'Graphs Trac tickets over time', - long_description = 'A Trac plugin that displays a visual graph of ticket changes over time, based on Colin Snover version.', + long_description = 'A Trac plugin that displays a visual graph of ticket changes over time, modified by Fabrizio Parrella (fabrizio@bibivu.com).', license = 'MIT', keywords = 'trac plugin ticket statistics graph', classifiers = [ From c3ed5d4b31fea32886163f4e852d225a5bd5d1af Mon Sep 17 00:00:00 2001 From: EffEPi Date: Wed, 23 Mar 2016 11:06:49 -0400 Subject: [PATCH 07/10] Update to allow a user to be selected --- ticketgraph/ticketgraph.py | 50 ++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/ticketgraph/ticketgraph.py b/ticketgraph/ticketgraph.py index 07eb5e5..9d533c5 100644 --- a/ticketgraph/ticketgraph.py +++ b/ticketgraph/ticketgraph.py @@ -46,6 +46,7 @@ def process_request(self, req): today = datetime.datetime.combine(datetime.date.today(), datetime.time(tzinfo=utc)) days = int(req.args.get('days', 30)) + owner = req.args.get('owner', "%") stack_graph={}; stack_graph['stack_graph'] = bool(int(req.args.get('sg', 0))) # These are in microseconds; the data returned is in milliseconds @@ -64,48 +65,64 @@ def process_request(self, req): 'reopenedTickets': {}, 'openTickets': {} } + args = [ts_start, ts_end]; + tix_args = [ts_start, ts_end]; + where = ''; + tix_where = ''; + if owner=="" : + owner = "%" + + if owner!="%" : + where += 'AND author LIKE %s '; + tix_where += 'AND reporter LIKE %s '; + args.append(owner) + tix_args.append(owner) + # number of created tickets for the time period, grouped by day (ms) -# cursor.execute('SELECT COUNT(DISTINCT id), FLOOR(time / 86400000000) * 86400000 ' \ cursor.execute('SELECT COUNT(DISTINCT id),( UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000) ' \ - 'AS date FROM ticket WHERE time BETWEEN %s AND %s ' \ - 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) + 'AS date FROM ticket WHERE time BETWEEN %s AND %s ' + tix_where + + 'GROUP BY date ORDER BY date ASC', tix_args) for count, timestamp in cursor: series['openedTickets'][float(timestamp)] = float(count) # number of reopened tickets for the time period, grouped by day (ms) -# cursor.execute('SELECT COUNT(DISTINCT ticket), FLOOR(time / 86400000000) * 86400000 ' \ cursor.execute('SELECT COUNT(DISTINCT ticket), UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000 ' \ 'AS date FROM ticket_change WHERE field = \'status\' AND newvalue = \'reopened\' ' \ - 'AND time BETWEEN %s AND %s ' \ - 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) + 'AND time BETWEEN %s AND %s ' + where + + 'GROUP BY date ORDER BY date ASC', args) for count, timestamp in cursor: series['reopenedTickets'][float(timestamp)] = float(count) # number of worked tickets for the time period, grouped by day (ms) cursor.execute('SELECT COUNT(DISTINCT ticket), UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000 ' \ 'AS date FROM ticket_change WHERE ' \ - 'time BETWEEN %s AND %s ' \ - 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) + 'time BETWEEN %s AND %s ' + where + + 'GROUP BY date ORDER BY date ASC', args) for count, timestamp in cursor: series['workedTickets'][float(timestamp)] = float((1 if stack_graph['stack_graph'] else -1)*count) # number of closed tickets for the time period, grouped by day (ms) -# cursor.execute('SELECT COUNT(DISTINCT ticket), FLOOR(time / 86400000000) * 86400000 ' \ cursor.execute('SELECT COUNT(DISTINCT ticket), UNIX_TIMESTAMP(DATE(FROM_UNIXTIME(time/1000000)))*1000 ' \ 'AS date FROM ticket_change WHERE field = \'status\' AND newvalue = \'closed\' ' \ - 'AND time BETWEEN %s AND %s ' \ - 'GROUP BY date ORDER BY date ASC', (ts_start, ts_end)) + 'AND time BETWEEN %s AND %s ' + where + + 'GROUP BY date ORDER BY date ASC', args) for count, timestamp in cursor: series['closedTickets'][float(timestamp)] = float((1 if stack_graph['stack_graph'] else -1)*count) # number of open tickets at the end of the reporting period - cursor.execute('SELECT COUNT(*) FROM ticket WHERE status <> \'closed\'') + if owner!='%' : + cursor.execute('SELECT COUNT(*) FROM ticket WHERE status <> \'closed\' AND owner LIKE %s ', [owner]) + else: + cursor.execute('SELECT COUNT(*) FROM ticket WHERE status <> \'closed\' ') + open_tickets = cursor.fetchone()[0] open_ts = math.floor((ts_end) / 1000)+ts_utc_delta +# series['openTickets'][open_ts] = open_tickets + while open_ts >= math.floor(ts_start / 1000): if open_ts in series['closedTickets']: open_tickets += (1 if stack_graph['stack_graph'] else -1)*series['closedTickets'][open_ts] @@ -127,9 +144,12 @@ def process_request(self, req): keys.sort() data[i] = [ (k, series[i][k]) for k in keys ] - data['openTickets_ts'] = open_ts-86400000 - data['openTickets_tickets'] = open_tickets - data['openTickets_days'] = days + data['owner'] = owner + data['users']={} + i=0; + for user in self.env.get_known_users(): + data['users'][i] = user + i=i+1 add_script(req, 'ticketgraph/jquery.flot.min.js') # add_script(req, 'http://people.iola.dk/olau/flot/jquery.flot.js') From dcb255f28d6a45082bdb5777d3b18fb9a6b1dc96 Mon Sep 17 00:00:00 2001 From: EffEPi Date: Wed, 23 Mar 2016 11:07:26 -0400 Subject: [PATCH 08/10] Update to allow a user to be selected --- ticketgraph/templates/ticketgraph.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ticketgraph/templates/ticketgraph.html b/ticketgraph/templates/ticketgraph.html index 008a9bb..4c578c9 100644 --- a/ticketgraph/templates/ticketgraph.html +++ b/ticketgraph/templates/ticketgraph.html @@ -21,6 +21,8 @@

Last ${days} days

+ User: + From f531fc9f4d12296d1c75d237f4cd382f177c5bf7 Mon Sep 17 00:00:00 2001 From: EffEPi Date: Wed, 23 Mar 2016 11:14:05 -0400 Subject: [PATCH 09/10] Update to allow a user to be selected --- ticketgraph/htdocs/ticketgraph.js | 41 +++++++++++++++++-------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/ticketgraph/htdocs/ticketgraph.js b/ticketgraph/htdocs/ticketgraph.js index 68f8658..82c0798 100644 --- a/ticketgraph/htdocs/ticketgraph.js +++ b/ticketgraph/htdocs/ticketgraph.js @@ -1,6 +1,6 @@ -var plot = null; +var tracGraphPlot = null; var line_tick = 86400000; -if(typeof stack_graph!=='undefined'&&stack_graph==true){ +if(typeof stack_graph !== 'undefined' && stack_graph == true){ line_tick /= 3.5; for(var k in closedTickets){ closedTickets[k][0] += line_tick+5000000; @@ -10,10 +10,17 @@ if(typeof stack_graph!=='undefined'&&stack_graph==true){ } } $(document).ready(function() { + $('#owner')[0].options.add(new Option("All","%")); + for(var i in users){ + if(users[i][1]==""||users[i][1]==null){ + users[i][1] = users[i][0]; + } + $('#owner')[0].options.add(new Option(users[i][1],users[i][0])); + } + $('#owner').val(owner); var graph = $('#placeholder').width(800).height(500), barSettings = { show: true, barWidth: line_tick, align: 'center', stack: false}; - plot = $.plot($('#placeholder'), - [ + var data = [ { data: openedTickets, label: 'New tickets', @@ -38,8 +45,10 @@ $(document).ready(function() { label: 'Worked tickets', color: '#45458b', idx: 3 - }, - { + } + ]; + if(owner==="" || owner==="%"){ + data.push({ data: openTickets, label: 'Open tickets', yaxis: 2, @@ -48,9 +57,9 @@ $(document).ready(function() { shadowSize: 0, color: '#333', idx: 4 - } - ], - { + }); + } + var options = { series:{ bars: barSettings }, @@ -65,7 +74,8 @@ $(document).ready(function() { return ''+label+''; } } - }); + }; + tracGraphPlot = $.plot($('#placeholder'), data, options); $("
").css({ position: "absolute", @@ -88,7 +98,6 @@ $(document).ready(function() { $("#tooltip").hide(); } }); -// setTimeout(function(){tracGraphTogglePlot(2);},500); }); function tracGraphTimeConverter(timestamp){ var a = new Date(timestamp); @@ -96,14 +105,11 @@ function tracGraphTimeConverter(timestamp){ var year = a.getFullYear(); var month = months[a.getMonth()]; var date = a.getDate(); -// var hour = a.getHours(); -// var min = a.getMinutes(); -// var sec = a.getSeconds(); var time = month + ' ' + date + ', ' + year; return time; } function tracGraphTogglePlot(seriesIdx){ - var someData = plot.getData(); + var someData = tracGraphPlot.getData(); if(typeof someData[seriesIdx].data_old === 'undefined'){ someData[seriesIdx].data_old=someData[seriesIdx].data; someData[seriesIdx].data=[]; @@ -111,7 +117,6 @@ function tracGraphTogglePlot(seriesIdx){ someData[seriesIdx].data=someData[seriesIdx].data_old; delete(someData[seriesIdx].data_old); } - plot.setData(someData); -// plot.setupGrid(); - plot.draw(); + tracGraphPlot.setData(someData); + tracGraphPlot.draw(); } From ad7ca53f4da6129549aaf6493a4742a98bfd5b94 Mon Sep 17 00:00:00 2001 From: EffEPi Date: Wed, 23 Mar 2016 11:22:38 -0400 Subject: [PATCH 10/10] reformatting --- ticketgraph/htdocs/ticketgraph.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/ticketgraph/htdocs/ticketgraph.js b/ticketgraph/htdocs/ticketgraph.js index 82c0798..6360c3d 100644 --- a/ticketgraph/htdocs/ticketgraph.js +++ b/ticketgraph/htdocs/ticketgraph.js @@ -1,15 +1,15 @@ var tracGraphPlot = null; -var line_tick = 86400000; -if(typeof stack_graph !== 'undefined' && stack_graph == true){ - line_tick /= 3.5; - for(var k in closedTickets){ - closedTickets[k][0] += line_tick+5000000; - } - for(var k in workedTickets){ - workedTickets[k][0] += (line_tick+5000000)*2; - } -} $(document).ready(function() { + var lineTick = 86400000; + if(typeof stack_graph !== 'undefined' && stack_graph == true){ + lineTick /= 3.5; + for(var k in closedTickets){ + closedTickets[k][0] += lineTick+5000000; + } + for(var k in workedTickets){ + workedTickets[k][0] += (lineTick+5000000)*2; + } + } $('#owner')[0].options.add(new Option("All","%")); for(var i in users){ if(users[i][1]==""||users[i][1]==null){ @@ -18,8 +18,7 @@ $(document).ready(function() { $('#owner')[0].options.add(new Option(users[i][1],users[i][0])); } $('#owner').val(owner); - var graph = $('#placeholder').width(800).height(500), - barSettings = { show: true, barWidth: line_tick, align: 'center', stack: false}; + var graph = $('#placeholder').width(800).height(500); var data = [ { data: openedTickets, @@ -61,7 +60,7 @@ $(document).ready(function() { } var options = { series:{ - bars: barSettings + bars: { show: true, barWidth: lineTick, align: 'center', stack: false} }, xaxis: { mode: 'time', minTickSize: [1, "day"] }, grid: { hoverable: true },