jqPlot-Y轴上的时间值 [英] jqPlot - time values on Y axis
本文介绍了jqPlot-Y轴上的时间值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要创建一个图表,其中X轴上的日期和Y轴上的时间.
I need to create graph with dates on X axis and times on Y axis.
我的JS代码是:
jQuery(document).ready(function ($) {
var data = [["2013-04-25","00:11.557"],["2013-04-25","00:15.569"],["2013-04-25","00:11.733"],["2013-04-25","00:13.023"],["2014-04-26","00:22.333"]];
var plot1 = $.jqplot('chartdiv', [data], {
title:'Default Date Axis',
axes:{xaxis:{renderer:$.jqplot.DateAxisRenderer}},
series:[{lineWidth:4, markerOptions:{style:'square'}}]
});
});
日期在X轴上正确显示,但是我不知道如何在Y轴上显示值.
The dates are showing correctly on the X axis, but I don't know how to display the values on Y axis.
这在jqPlot插件中如何完成?
How is this done in jqPlot plugin?
推荐答案
我在这里发现了问题.
这里的主要问题是y-axis
仅采用numeric
值,例如11.557
,15.569
,...等.
The main issue here is y-axis
take only numeric
values like 11.557
, 15.569
, ... and so on.
此外,我需要为x-axis
添加额外的属性tickOptions
:
Also, I need to add extra attribute tickOptions
for x-axis
as:
tickOptions:{formatString:'%Y-%m-%d'}
这就是我要工作的地方:
Here is what I got to work:
jQuery(document).ready(function($){
var data = [["2013-04-25",11.557],["2013-04-25",15.569],["2013-04-25",11.733],["2013-04-25",13.023],["2013-04-26",22.333]];
var plot1 = $.jqplot('chartdiv', [data], {
title: 'Default Date Axis',
axes:{
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
tickOptions:{formatString:'%Y-%m-%d'}
}
},
series: [{ lineWidth: 4, markerOptions: { style:'square' }}]
});
});
Working DEMO Link
这篇关于jqPlot-Y轴上的时间值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文