Highstock不适用于日期格式%d /%m /%Y

时间:2012-10-16 22:54:47

标签: jquery date format highstock

我遇到了Highstock的问题。 好吧,我的数据库格式如下:(%d /%m /%Y)

fecha_emision neto
01/02/2012    22300
01/10/2012    17250
02/10/2012    105400
03/10/2012    52700
08/10/2012    322100

我正在使用highstock,日期是倒退的,结果就是:

This is the result

我正在尝试所有内容,但我不知道如何修复它,我需要更改格式,因为带有inputDateFormat的rangeSelector:'%d /%m /%Y'和inputEditDateFormat:'%d /% m /%Y'不起作用,有什么办法吗?

这是我的剧本

Highcharts.dateFormat('%d/%m/%Y');


});

var chart;

var options = {
                    chart: {
                        renderTo: 'container',
                        defaultSeriesType: 'line',
                        marginRight: 130,
                        marginBottom: 25
                    },


                    rangeSelector: {
                    inputDateFormat: '%d/%m/%Y',
                    inputEditDateFormat: '%d/%m/%Y',
                    enabled : true,
                    inputEnabled:true
                    },


                    navigator : {
                        enabled : true
                    },


                    scrollbar : {
                        enabled : true
                    },


                    title: {
                        text: 'Ventas Realizadas',
                        x: -20 //center
                    },


                    subtitle: {
                        text: 'Diariamente',
                        x: -20
                    },


                    xAxis: {
                        type: 'datetime',
                        //tickInterval: 1 * 24 * 3600000,
                        tickWidth: 0,
                        gridLineWidth: 1,
                        labels: {
                            align: 'center',
                            x: -3,
                            y: 20,

                        }
                    },


                    yAxis: {
                        title: {
                            text: 'Valores Netos Vendidos'
                        },
                        labels: {
                            formatter: function() {
                            return this.value;
                            }
                        },

                        plotLines: [{
                            value: 0,
                            width: 1,
                            color: '#808080'
                        }]
                    },


                    tooltip: {
                        xDateFormat: '%d/%m/%Y',

                        formatter: function() {
                            return Highcharts.dateFormat('%d/%m/%Y', this.x) +' Vendido<b>'+ Highcharts.numberFormat(this.y, 0)+ '</b>';
                        }
                    },


                    legend: {
                        layout: 'vertical',
                        align: 'right',
                        verticalAlign: 'top',
                        x: -10,
                        y: 100,
                        borderWidth: 0
                    },


                    series: [{
                        name: 'Valores Netos'
                    }]

                }




                // Load data asynchronously using jQuery. On success, add the data
                // to the options and initiate the chart.
                // This data is obtained by exporting a GA custom report to TSV.
                // http://api.jquery.com/jQuery.get/
                jQuery.get('clases/data.php', null, function(tsv) {
                    var lines = [];
                    traffic = [];
                    try {
                        // split the data return into lines and parse them
                        tsv = tsv.split(/\n/g);
                        jQuery.each(tsv, function(i, line) {
                            line = line.split(/\t/);
                            date = Date.parse(line[0]);
                            traffic.push([
                                date,
                                parseInt(line[1].replace(',', ''), 10)
                            ]);
                        });
                    } catch (e) {  }
                    options.series[0].data = traffic;
                    chart = new Highcharts.Chart(options);
                });

这是我的数据库文件“data.php”

<?php 

$con = mysql_connect("localhost","root",""); 

if (!$con) {   die('Could not connect: ' . mysql_error()); } 

mysql_select_db("pymesonline", $con); 

$result = mysql_query("SELECT fecha_emision, neto FROM facturas ORDER BY fecha_emision"); 

    while($row = mysql_fetch_array($result)) {
        echo $row['fecha_emision'] . "\t" . $row['neto']. "\n"; } 
    mysql_close($con); 

?>, i appreciate any kind of help.

0 个答案:

没有答案