RenderPieChart

Continuando con el hola mundo ahora les voy a presentar a una función casi mágica que me ayudó muchísimo, es una función para crear un gráfico de pastel, sin más aquí les va.



 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
function RenderPieChart(elementId, title, dataList) {
        new Highcharts.Chart({
            chart: {
                renderTo: elementId,
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            }, title: {
                text: title
            },
            tooltip: {
                backgroundColor: '#FCFFC5',
                borderColor: 'black',
                borderRadius: 10,
                borderWidth: 1,
                formatter: function() {
                    return this.percentage + ' %';
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        formatter: function() {
                            return '<b>' + this.point.name + '</b>: ';
                        }
                    },
                    showInLegend: false
                }
            },
            series: [{
                    type: 'pie',
                    name: 'Browser share',
                    data: dataList
                }]
        });
    }
    ;
No tengo palabras para describir todo lo que me ayudó, disfrutenla.

Comentarios

Entradas más populares de este blog

Entornos virtuales en python (venv)