我正在使用jqplot渲染一些脚本来创建图形,页面上的脚本最终会像这样:
<script>
$.jqplot('chartdiv', [[['13/11/2013', 38.25],['14/11/2013', -11.70],['15/11/2013', 5930.15],['16/11/2013', 4139.13],['17/11/2013', 207.92],['18/11/2013', -103.53],['19/11/2013', 635.81],['20/11/2013', 559.16],['21/11/2013', 253.53],['22/11/2013', 183.53],['23/11/2013', 183.53],['24/11/2013', 183.53],['25/11/2013', 54.62],['26/11/2013', 67.62],['27/11/2013', 67.62],['28/11/2013', 47.62],['29/11/2013', -32.38],['30/11/2013', -32.38],['1/12/2013', -32.38],['2/12/2013', -82.33],['3/12/2013', 364.07],['4/12/2013', 254.45],['5/12/2013', 186.95],['6/12/2013', 114.05],['7/12/2013', 57.05],['8/12/2013', 53.36],['9/12/2013', 50.51],['10/12/2013', 30.51],['11/12/2013', 30.51],['12/12/2013', -86.43],['13/12/2013', 5922.89],['14/12/2013', 5720.82],['15/12/2013', 5468.87],['16/12/2013', 4742.57],['17/12/2013', 896.11],['18/12/2013', 680.69],['19/12/2013', 425.07],['20/12/2013', 323.07],['21/12/2013', 228.42],['22/12/2013', 113.42],['23/12/2013', -20.82],['24/12/2013', -20.82],['25/12/2013', -20.82],['26/12/2013', -47.82],['27/12/2013', -47.82],['28/12/2013', -47.82],['29/12/2013', -47.82],['30/12/2013', -59.30],['31/12/2013', 1004.02],['1/01/2014', 767.00],['2/01/2014', 663.15],['3/01/2014', 302.16],['4/01/2014', 231.66],['5/01/2014', 223.16],['6/01/2014', 12.60],['7/01/2014', -27.40],['8/01/2014', -27.40],['9/01/2014', -27.40],['10/01/2014', -27.40],['11/01/2014', -27.40],['12/01/2014', -27.40],['13/01/2014', -39.60],['14/01/2014', 803.29],['15/01/2014', 6709.11],['16/01/2014', 4968.20],['17/01/2014', 1381.55],['18/01/2014', 296.86],['19/01/2014', 285.61],['20/01/2014', 161.77],['21/01/2014', 47.80],['22/01/2014', 70.90],['23/01/2014', 56.30]]], {
title: 'Your financial control',
axes: { yaxis: { renderer: $.jqplot.LogAxisRenderer } },
series: [{
lineWidth: 1,
color: '#5FAB78',
showMarker: false
}] });</script>
这会呈现一个空白图表 - 没有线条。但是,Y轴显示总计,但x轴为空白。
但是,如果我使用JUST值来渲染它 - 它可以工作:
$.jqplot('chartdiv', [[38.25,-11.70,5930.15,4139.13,207.92,-103.53,635.81,559.16,253.53,183.53,183.53,183.53,54.62,67.62,67.62,47.62,-32.38,-32.38,-32.38,-82.33,364.07,254.45,186.95,114.05,57.05,53.36,50.51,30.51,30.51,-86.43,5922.89,5720.82,5468.87,4742.57,896.11,680.69,425.07,323.07,228.42,113.42,-20.82,-20.82,-20.82,-47.82,-47.82,-47.82,-47.82,-59.30,1004.02,767.00,663.15,302.16,231.66,223.16,12.60,-27.40,-27.40,-27.40,-27.40,-27.40,-27.40,-39.60,803.29,6709.11,4968.20,1381.55,296.86,285.61,161.77,47.80,70.90,56.30]],
{
title: 'Your financial control',
axes: { yaxis: { renderer: $.jqplot.LogAxisRenderer } },
series: [{
lineWidth: 1,
color: '#5FAB78',
showMarker: false
}]
});
我试图按照他们网页上提供的示例进行操作 - 但似乎只要我将标签添加到数据中 - 它就不起作用了。你可以窥探一个问题吗?
答案 0 :(得分:1)
您需要指定xaxis日期渲染器
xaxis: {
renderer: $.jqplot.DateAxisRenderer
}
如果使用默认渲染器,则还需要更改日期格式。
如示例所示,日期格式为mm/dd/yyyy
,代码中的日期格式为dd/mm/yyyy
-
更改输入日期格式,应该会很好 - ['11 / 13/2013',38.25],['11/14/2013', - 11.70],....
jqplot本身可能有一些util接受其他日期格式。
编辑 - 这是接受其他日期格式的选项 - http://www.jqplot.com/docs/files/plugins/jqplot-dateAxisRenderer-js.html
您需要设置tickOptions.formatString = ‘%Y-%m-%d’