日期格式jqplot categoryaxisrenderer在滴答添加后 [英] Date format jqplot categoryaxisrenderer after ticks add
问题描述
我想为CategoryAxis使用日期格式化程序(日期以毫秒为单位)。
我在Stack上发现了不同的解决方案,但问题似乎是我的蜱虫:它们是在创建之后添加的,选项/格式没有考虑到。
勾号:this.cfg.categories,
我使用了datetickformatter,一个自定义datetickformatter,CanvasAxisTickRenderer和CanvasAxisTickRenderer版本进行了测试。徒然。
this.cfg.axes = {
xaxis:{
渲染器:$ .jqplot.CategoryAxisRenderer,
rendererOptions:{
tickRenderer:$ .jqplot.CanvasAxisTickRenderer
},
tickOptions:{
formatString:'%a。',
fontSize:' 7pt',
},
ticks:this.cfg.categories,
},
感谢,
Ju。
我发现了使用CategoryAxisRenderer和CanvasTickRenderer。我想出了用JavaScript手动分类的解决方案,然后将它们传递给渲染器。在你的情况下,你可以使用下面的extender作为你的primefaces图表:
function extender(){
var millis = this.cfg.categories;
var dates = new Array(categories.length);
for(var i = 0; i< categories.length; i ++){
dates [i] = new Date(categories [i])。toLocaleDateString();
}
this.cfg.axes = {
xaxis:{
renderer:$ .jqplot.CategoryAxisRenderer,
rendererOptions:{
tickRenderer:$ .jqplot.CanvasAxisTickRenderer,
tickOptions:{
fontSize:'7pt'
},
ticks:dates
}
}
};
}
I use jQplot with primeFaces.
I would like a date formatter for the CategoryAxis (dates are in millis).
I found different solutions on Stack but the problem seems to be my ticks : they are adds "after" the creation and options/format are not taking into consideration.
ticks: this.cfg.categories,
I tested with datetickformatter, a custom datetickformatter, CanvasAxisTickRenderer, and edition of CanvasAxisTickRenderer. In vain.
this.cfg.axes = {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
rendererOptions: {
tickRenderer: $.jqplot.CanvasAxisTickRenderer
},
tickOptions: {
formatString: '%a.',
fontSize:'7pt',
},
ticks: this.cfg.categories,
},
Thanks, Ju.
I have discovered the same problem using a combination of CategoryAxisRenderer and CanvasTickRenderer. I came up with the solution of formating the categories by hand in javascript and then passing them to the Renderer. In your case you could use the following as extender for your primefaces chart:
function extender() {
var millis = this.cfg.categories;
var dates = new Array(categories.length);
for (var i = 0; i < categories.length; i++) {
dates[i] = new Date(categories[i]).toLocaleDateString();
}
this.cfg.axes = {
xaxis : {
renderer : $.jqplot.CategoryAxisRenderer,
rendererOptions : {
tickRenderer : $.jqplot.CanvasAxisTickRenderer,
tickOptions : {
fontSize:'7pt'
},
ticks : dates
}
}
};
}
这篇关于日期格式jqplot categoryaxisrenderer在滴答添加后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!