How to format a Highcharts date?

0

I need to format a date I just want to show the date nothing else without the hours

This is my answer in the query

 DIA
13/11/2018
12/11/2018
11/11/2018
10/11/2018
09/11/2018
08/11/2018
07/11/2018
06/11/2018

This is my code

<script type="text/javascript">

            chartCPU = new Highcharts.chart('graf', 
            {
                chart: {
                    type: 'spline'
                },
                title: {
                    text: 'AA'
                },
                xAxis: {
                    gridLineWidth: 1,
                    categories: 
                    [
                        <?php
                            foreach($param['DIA'] as $dia)
                            {
                                echo "'$dia',";
                            }
                        ?>
                    ]
                },
                yAxis: 
                [
                    {
                        min: 0,
                        title: 
                        {
                            text: '',
                        }
                    },

                    {
                        min: 0,
                        max: 100,
                        title: 
                        {
                            text: '',
                        },
                        opposite: true
                    }
                ],
                plotOptions: {
                    column: {
                        pointPadding: 0.2,
                        borderWidth: 0
                    }
                },
                credits: {
                  enabled: false
                },
                tooltip: {
                    split: true
                },
                series: 
                [
                    {
                        name: 'TOTAL',
                        yAxis: 0,
                        data: 
                        [
                            <?php 
                                for ($j=0; $j < count($param['TOTAL_MT']) ; $j++) 
                                { 
                                    echo $param['TOTAL_MT'][$j].','; 
                                }
                            ?>
                        ],
                        color: '#FF7F50',
                        cursor: 'pointer'
                    },{
                        name: 'RATE',
                        yAxis: 1,
                        data: 
                        [
                            <?php 
                                for ($k=0; $k < count($param['RATE_MT']) ; $k++) 
                                { 
                                    echo $param['RATE_MT'][$k].','; 
                                }
                            ?>
                        ],
                        color: '#5F9EA0',
                        cursor: 'pointer'
                    }
                ]
            });

        </script>
    
asked by Juan Perez 14.11.2018 в 20:02
source

1 answer

0

In the attribute xAxis add the tag dateTimeLabelFormats . Within it you can define the format in which you want these labels to be displayed. In your case, the labels show the seconds, modify the second tag:

xAxis: {
    type: 'datetime',
    dateTimeLabelFormats: {
        second: '%d-%m-%Y',
    }
}

In addition, you can also define different time intervals and how you want them to be displayed on the graph.

I leave the official reference link where you can find more information about it: link

    
answered by 14.11.2018 в 20:18