Newer
Older
Benaka Moorthi
a validé
/**
* Piwik - free/libre analytics platform
Benaka Moorthi
a validé
*
* DataTable UI class for JqplotGraph/Pie.
*
* @link http://www.jqplot.com
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
(function ($, require) {
var exports = require('piwik/UI'),
JqplotGraphDataTable = exports.JqplotGraphDataTable;
Benaka Moorthi
a validé
exports.JqplotPieGraphDataTable = function (element) {
JqplotGraphDataTable.call(this, element);
Benaka Moorthi
a validé
};
$.extend(exports.JqplotPieGraphDataTable.prototype, JqplotGraphDataTable.prototype, {
Benaka Moorthi
a validé
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
_setJqplotParameters: function (params) {
JqplotGraphDataTable.prototype._setJqplotParameters.call(this, params);
this.jqplotParams.seriesDefaults = {
renderer: $.jqplot.PieRenderer,
rendererOptions: {
shadow: false,
showDataLabels: false,
sliceMargin: 1,
startAngle: 35
}
};
this.jqplotParams.piwikTicks = {
showTicks: false,
showGrid: false,
showHighlight: false,
tickColor: this.tickColor
};
this.jqplotParams.legend = {
show: false
};
this.jqplotParams.pieLegend = {
show: true,
labelColor: this.singleMetricColor
};
this.jqplotParams.canvasLegend = {
show: true,
singleMetric: true,
singleMetricColor: this.singleMetricColor
};
// pie charts have a different data format
if (!(this.data[0][0] instanceof Array)) { // check if already in different format
for (var i = 0; i < this.data[0].length; i++) {
this.data[0][i] = [this.jqplotParams.axes.xaxis.ticks[i], this.data[0][i]];
}
}
},
_showDataPointTooltip: function (element, seriesIndex, valueIndex) {
var value = this.formatY(this.data[0][valueIndex][1], 0);
var series = this.jqplotParams.series[0].label;
var percentage = this.tooltip.percentages[0][valueIndex];
var label = this.data[0][valueIndex][0];
var text = '<strong>' + NumberFormatter.formatPercent(percentage) + '</strong> (' + value + ' ' + series + ')';
Benaka Moorthi
a validé
$(element).tooltip({
track: true,
items: '*',
content: '<h3>' + label + '</h3>' + text,
show: false,
hide: false
}).trigger('mouseover');
Benaka Moorthi
a validé
});
})(jQuery, require);