forked from mozilla/kitsune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Bug 663241] KB Helpfulvotes Metrics Frontend Graphing
- Loading branch information
Showing
9 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
======================== | ||
Licenses | ||
======================== | ||
|
||
The license for Kitsune's codebase can be found in LICENSE. | ||
|
||
|
||
License Exceptions | ||
================== | ||
|
||
The charting library included with the Wiki (HighCharts) is for non-commercial | ||
use only. It is not free for commercial use. For more information regarding | ||
commercial usage, visit `http://www.highcharts.com | ||
<http://www.highcharts.com/>`_. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* charts.js | ||
* Scripts to support charts. | ||
*/ | ||
|
||
(function ($) { | ||
function init() { | ||
$('#show-chart').unbind('click'); | ||
$('#show-chart').html(gettext('Loading...')); | ||
$('#show-chart').css('color', '#333333').css('cursor', 'auto').css('text-decoration', 'none'); | ||
initChart(); | ||
} | ||
|
||
function initChart() { | ||
var data, dateToRevID; | ||
$.ajax({ | ||
type: "GET", | ||
url: $('#helpful-chart').data('url'), | ||
data: null, | ||
success: function (response) { | ||
data = response['data']; | ||
dateToRevID = response['date_to_rev_id']; | ||
if(data.length > 0) { | ||
$('#helpful-chart').show('fast', function () { | ||
stockChart(data, dateToRevID); | ||
$('#helpful-chart').append('<div id="chart-footnote">' + gettext('Query took: ') + response['query'] + gettext(' seconds') + '</div>') | ||
}); | ||
} | ||
else { | ||
$('#show-chart').html(gettext('No votes data')); | ||
$('#show-chart').unbind('click'); | ||
} | ||
}, | ||
error: function () { | ||
$('#show-chart').html(gettext('Error loading chart')); | ||
$('#show-chart').unbind('click'); | ||
} | ||
}); | ||
} | ||
|
||
/* | ||
* stockChart() | ||
* Creates the StockChart object with the defined options. | ||
* Requires data, plotLines, and dateToRevID to be set prior via AJAX. | ||
* The graph is drawn upon creation of the StockChart object. | ||
* Returns: nothing | ||
*/ | ||
function stockChart(data, dateToRevID) { | ||
chart = new Highcharts.StockChart({ | ||
chart: { | ||
renderTo: 'helpful-chart' | ||
}, | ||
rangeSelector: { | ||
selected: 1 | ||
}, | ||
|
||
title: { | ||
text: gettext('Helpfulness Votes') | ||
}, | ||
xAxis: { | ||
type: 'datetime', | ||
maxZoom: 14 * 24 * 3600000, // fourteen days | ||
title: { | ||
text: null | ||
} | ||
}, | ||
yAxis: { | ||
title: { | ||
text: gettext('Votes') | ||
} | ||
}, | ||
tooltip: { | ||
style: { | ||
width: 200 | ||
} | ||
}, | ||
credits: { | ||
enabled: false | ||
}, | ||
plotOptions: { | ||
series: { | ||
cursor: 'pointer', | ||
point: { | ||
events: { | ||
mouseOver: function () { | ||
$('#rev-list-' + dateToRevID[this.x]).addClass('graph-hover'); | ||
}, | ||
mouseOut: function () { | ||
$('#rev-list-' + dateToRevID[this.x]).removeClass('graph-hover'); | ||
} | ||
} | ||
}, | ||
marker: { | ||
lineWidth: 1 | ||
}, | ||
stickyTracking: true, | ||
} | ||
}, | ||
series: data | ||
}, function () { | ||
$('#show-chart').hide(); // loading complete callback | ||
}); | ||
} | ||
|
||
$('#show-chart').click(init); | ||
|
||
}(jQuery)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters