我的数据格式为[[x1,y1],[x2,y2],..]。 x值从1到31.它表示每月的天数。 y值是这些天的温度。
当我用jqPlot绘制这些数据时,我得到了这个:
这是代码:
$.post('php/database2json.php', function(data) {
var options = {
title: 'Месечна температура',
series: [
{ label: 'Ниш'}
],
axes:{
xaxis:{
label:'Дани',
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
},
yaxis:{
label:'Температура',
labelRenderer: $.jqplot.CanvasAxisLabelRenderer
}
},
legend: {
show: $legenda
},
highlighter: {
show: $hover
},
cursor:{
show: $zoom,
zoom: $zoom,
false)
showTooltip: true
}
};
$('#placeholder').empty();
var plot1 = $.jqplot ('placeholder', [data], options);
},
'json'
);
如何缩短此图表以适应线?
编辑:我从帖子中获取json数组: [[ “1”, “ - 1”],[ “2”, “0”],[ “3”, “0”],[ “4”, “0”],[ “5”, “4” ],[ “6”, “5”],[ “7”, “3”],[ “8”, “2”],[ “9”, “2”],[ “10”, “1” ],[ “11”, “ - 2”],[ “12”, “ - 2”],[ “13”, “0”],[ “14”, “1”],[ “15”,” -2 “],[” 16" , “ - 1”],[ “17”, “ - 1”],[ “18”, “ - 2”],[ “19”, “ - 1”],[ “20”, “3”],[ “21”, “ - 1”],[ “22”, “0”],[ “23”, “1”],[ “24”, “3”], [ “25”, “1”],[ “26”, “1”],[ “27”, “ - 1”],[ “28”, “ - 1”],[ “29”, “4” ],[ “30”, “5”],[ “31”, “5”]]
答案 0 :(得分:1)
您的数组值是字符串。它们应该是数值。修改PHP脚本以返回数字(int或float)点对。 Once you do that your plot will scale properly: