-
Notifications
You must be signed in to change notification settings - Fork 7
more functionalities and some eye candies #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 7 commits
2f2547d
51488f5
f1fc435
c13b84e
cf41cf3
ccdd20f
6d186e4
7fda57d
c3ed5d4
dcb255f
f531fc9
ad7ca53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,117 @@ | ||
| var plot = null; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not expose globals.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case this is necessary because the |
||
| var line_tick = 86400000; | ||
| if(typeof stack_graph!=='undefined'&&stack_graph==true){ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please follow the code style convention used by this code. |
||
| 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 tickets', | ||
| bars: barSettings, | ||
| color: 1 | ||
| }, | ||
| { | ||
| data: openedTickets, | ||
| label: 'New tickets', | ||
| bars: barSettings, | ||
| color: 2, | ||
| stack: true | ||
| }, | ||
| { | ||
| data: reopenedTickets, | ||
| label: 'Reopened tickets', | ||
| bars: barSettings, | ||
| color: 3, | ||
| stack: true | ||
| }, | ||
| { | ||
| data: openTickets, | ||
| label: 'Open tickets', | ||
| 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 '<a href="#" onClick="tracGraphTogglePlot('+series.idx+'); return false;">'+label+'</a>'; | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| $("<div id='tooltip'></div>").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) + '<br />' + item.series.label + " : " + y) | ||
| .css({top: item.pageY+5, left: item.pageX+5}) | ||
| .fadeIn(200); | ||
| } else { | ||
| $("#tooltip").hide(); | ||
| } | ||
| }); | ||
| // setTimeout(function(){tracGraphTogglePlot(2);},500); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clean up your commented out code before you submit a pull request please. |
||
| }); | ||
| 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(); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replacing authorship information like this is not appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I initially meant to create a new plugin all together that is why I did change it. reverting that change