Welcome to mirror list, hosted at ThFree Co, Russian Federation.

jqplotPieGraph.js « javascripts « CoreVisualizations « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 61f0a22c84661fe1b9ef11d83cd011fb0e413a0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
70
71
72
73
74
75
76
77
78
79
80
81
/**
 * Piwik - Web Analytics
 *
 * 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;

    exports.JqplotPieGraphDataTable = function (element) {
        JqplotGraphDataTable.call(this, element);
    };

    $.extend(exports.JqplotPieGraphDataTable.prototype, JqplotGraphDataTable.prototype, {

        _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>' + percentage + '%</strong> (' + value + ' ' + series + ')';
            $(element).tooltip({
                track:   true,
                items:   '*',
                content: '<h3>' + label + '</h3>' + text,
                show: false,
                hide: false
            }).trigger('mouseover');
        }
    });

})(jQuery, require);