使用primefaces和jqplot在线形图中显示日期轴
我试着用primefaces和jqplot显示一个折线图。但我不明白。我的bean中有以下代码:使用primefaces和jqplot在线形图中显示日期轴,primefaces,jqplot,Primefaces,Jqplot,我试着用primefaces和jqplot显示一个折线图。但我不明白。我的bean中有以下代码: CartesianChartModel graphic = new CartesianChartModel(); LineChartSeries series = new LineChartSeries(); DateFormat dateFormat = new SimpleDateFormat("mm/dd/yy"); String date1 = "01/10/13"; String da
CartesianChartModel graphic = new CartesianChartModel();
LineChartSeries series = new LineChartSeries();
DateFormat dateFormat = new SimpleDateFormat("mm/dd/yy");
String date1 = "01/10/13";
String date2= "01/15/13";
String date3= "02/20/13";
p=dateFormat.parse(date1);
series.set(p.getTime(), 10);
p=dateFormat.parse(date2);
series.set(p.getTime(), 20);
p=dateFormat.parse(date3);
series.set(p.getTime(), 15);
graphic.addSeries(series);
我的扩展器函数中有以下代码:
function extender(){
this.cfg.axes = {
xaxis :{
renderer:$.jqplot.DateAxisRenderer,
rendererOptions : {
tickRenderer:$.jqplot.CanvasAxisTickRenderer
},
tickOptions : {
fontSize:'10pt',
fontFamily:'Tahoma',
angle:-40,
formatString:'%D'
}
};
this.cfg.axes.xaxis.ticks = this.cfg.categories;
}
问题
它不能正常工作,因为我比其他人先得到date3,并且日期没有显示在x轴上
我只是试着去做。我更改了时间格式,并添加了
tickInterval
元素。通过这些更改,我得到了一个空的图形。如果我删除tickInterval
元素,我会在x轴上得到类似于每个tick1110110000111100000000000-%y
的东西,我已经解决了创建这样一个新项目的问题,它可以工作。我不知道是什么问题。
但我有一个新问题。
我刚刚尝试绘制了2013年1月1日至2013年3月1日之间的一系列数据,我只在1月份获得数据。这意味着,我得到了一个1月和2月的数据打印在同一日期,1月。好的。我不确定你是否还需要这个,但我遇到了一个类似的问题,我就是这样解决的。我还需要放大日期 首先,primefaces不包含DateAxisRenderer。您需要下载它并将其单独添加到代码中。你可以在这里买到- 然后像这样将其添加到代码中-
<h:outputScript library="js/plugins" name="jqplot.dateAxisRenderer.min.js" target="head" />
然后它应该可以正常工作。您必须使用历元毫秒设置X轴值。我必须弄明白。您是否包含了所有需要的插件?(dateAxisRenderer)是否尝试为xaxis指定最小值和最大值?是的,但无效。如果在初始化绘图时使用console.log,是否有错误?能否发布console.log(this.cfg.axes.xaxis)的结果?您好,欢迎使用堆栈溢出。如果您用一些代码或解释来扩展这个答案,说明这是如何导致/解决问题的,这可能是一个很好的答案。
this.cfg.axes.xaxis.ticks = this.cfg.categories;