Highcharts系列,x轴上有日期

时间:2014-07-07 08:58:38

标签: highcharts

首先,对不起我的英语,我是法国人^^

我想显示4个系列的30分。 在xAxis上,我想显示这样的日期:14/06/23 14/06/24 ......

数据来自:

$from = strftime("%Y/%m/%d", mktime(0, 0, 0, date('m'), date('d')-30, date('Y')));
$to = date('Y/m/d');
$i=0;
$dates = getDatesBetween($from, $to);
foreach($dates as $date){
    $sql = "SELECT id FROM parti_autres WHERE DATE(date)='$date'";
    $reponse = $bdd->query($sql) or die(print_r($bdd->errorInfo()));
    while ($donnees = $reponse->fetch())
        {$i++;
        }
        $compteur_autres[]=$i;
$i=0;
}

使用:

            <script type="text/javascript">
                $(function() {
                    $('#container_graphe_partis').highcharts({
                        chart: {backgroundColor: {
                        linearGradient: [0, 0, 400, 500],
                        stops: [
                            [0, 'rgb(255, 255, 255)'],
                            [1, 'rgb(240, 240, 255)']
                            ]
                    },
                    borderWidth: 0,
                    plotBackgroundColor: 'rgba(255, 255, 255, .9)',
                    plotShadow: true,
                    plotBorderWidth: 1,
                            renderTo: 'container',
                            type: 'spline',
                            zoomType: 'x'
                        },
                        title: {
                            text: 'Les partis politiques dans l\'actu',
                            x: -20 //center
                        },
                        subtitle: {
                            text: '',
                            x: -20
                        },
                        xAxis: {
                        },
                        yAxis: {
                            title: {
                                text: 'QN Score'
                            },
                            plotLines: [{
                                value: 0,
                                width: 1,
                                color: '#808080'
                            }]
                        },
                        tooltip: {
                            valueSuffix: ''
                        },
                        legend: {
                            layout: 'vertical',
                            borderWidth: 0
                        },
                        series: [{
                            name: 'Autres partis',
                            data: [<?php echo join($dates, ',')?>,<?php echo join($compteur_autres, ',')?>]
                        },
                        {
                            name: 'PS',
                            data: [<?php echo join($dates, ',')?>,<?php echo join($compteur_ps, ',')?>]
                        },
                        {
                            name: 'UMP',
                            data: [<?php echo join($dates, ',')?>,<?php echo join($compteur_ump, ',')?>]
                        },
                        {
                            name: 'FN',
                            data: [<?php echo join($dates, ',')?>,<?php echo join($compteur_fn, ',')?>]
                        }]
                    });
                });
        </script>
    <div id="container_graphe_partis" style="width: 100%; height: 600px;"></div>

0 个答案:

没有答案