我对 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,日期是倒退的,结果是这样的:
我正在尝试一切,但我不知道如何修复它,我需要更改格式,因为 rangeSelector 带有 inputDateFormat: '%d/%m/%Y' 和 inputEditDateFormat: '%d/%m/%你不工作,有什么办法吗?
这是我的脚本
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.