how to change the values of the x and y axis

0

I want to change the values of my x-axis graph and put other numbers but I do not know how

<script>
Highcharts.chart('container', {
chart: {
    type: 'column'
},
title: {
    text: 'TIEMPOS DE ENTREGA'
},
subtitle: {
    text: 'GRAFICA'
},
xAxis: {
    type: 'category'
},
yAxis: {
    title: {
        text: 'Entregas'
    }

},
legend: {
    enabled: false
},
plotOptions: {
    series: {
        borderWidth: 0,
        dataLabels: {
            enabled: true,
        }
    }
},

tooltip: {
    headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
    pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y}</b>Entregas<br/>'
},

series: [{
    name: 'columna',
    colorByPoint: true,
    data: [{
        name:<?php echo ($contat);?>,
        y: 6,
        drilldown: 'Entregas A Tiempo'
    }, {
        name:<?php echo ($contft);?>,
        y: 2,
        drilldown: 'Entregas Fuera de Tiempo'        
    },]
}],
drilldown: {
    series: [{
        name: 'Entregas A Tiempo',
        id: 'Entregas A Tiempo',
        data: [
            [
                'v7.0',
                6
            ]
        ]
    }, {
        name: 'Entregas Fuera de Tiempo',
        id: 'Entregas Fuera de Tiempo',
        data: [
            [
                'v30.0',
                2
            ]
        ]
    }, {
        name: 'Firefox',
        id: 'Firefox',
        data: [
            [
                'v35',
                5
            ]
        ]
    }, {
        name: 'Safari',
        id: 'Safari',
        data: [
            [
                'v8.0',
                4
            ]
        ]
    }, {
        name: 'Opera',
        id: 'Opera',
        data: [
            [
                'v12.x',
                1
            ]
        ]
    }]
}
});
</script>
    
asked by jasiel 05.10.2018 в 19:39
source

1 answer

0

Taking into account the data you send and if the data you bring from a MySQL database, I can offer you this possible solution:

<?php 
$con = new mysqli("localhost","user","password","base_datos");
$sql1 = "SELECT * FROM tiempos WHERE tiempo = 'at'";
$query1 = $con->query($sql1);
$sql2 = "SELECT * FROM tiempos WHERE tiempo = 'ft'";
$query2 = $con->query($sql2);

if ($result = $con->query($sql1)) {
    $at = $result->num_rows;
}
if ($result = $con->query($sql2)) {
    $ft = $result->num_rows;
}

?>

<!DOCTYPE html>
<html>
<head>
    <title>Tiempos</title>
    <script src="https://code.highcharts.com/highcharts.js"></script>
    <script src="https://code.highcharts.com/modules/data.js"></script>
    <script src="https://code.highcharts.com/modules/drilldown.js"></script>
</head>
<body>

    <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
    <script type="text/javascript">
        // Create the chart
        Highcharts.chart('container', {
            chart: {
                type: 'column'
            },
            title: {
                text: 'TIEMPOS DE ENTREGA'
            },
            subtitle: {
                text: 'GRAFICA'
            },
            xAxis: {
                type: 'category'
            },
            yAxis: {
                title: {
                    text: 'Entregas'
                }

            },
            legend: {
                enabled: false
            },
            plotOptions: {
                series: {
                    borderWidth: 0,
                    dataLabels: {
                        enabled: true,
                        //format: '{point.y:.1f}%'
                    }
                }
            },

            tooltip: {
                headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
                pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y}</b> <br/>'
            },

            "series": [
                {
                    "name": "Entregas",
                    "colorByPoint": true,
                    "data": [
                        {
                            "name": "Entregas a Tiempo",
                            "y": <?php echo $at;?>,

                        },
                        {
                            "name": "Entregas Fuera de Tiempo",
                            "y": <?php echo $ft;?>,

                        }
                    ]
                }
            ]
        });
    </script>
</body>

With that code, it shows you this graph:

Now, if the data is fixed, you omit all the PHP code and in series you put the data manually.

"series": [
                {
                    "name": "Entregas",
                    "colorByPoint": true,
                    "data": [
                        {
                            "name": "Entregas a Tiempo",
                            "y": 6,

                        },
                        {
                            "name": "Entregas Fuera de Tiempo",
                            "y": 2,

                        }
                    ]
                }
            ]
    
answered by 05.10.2018 в 22:50