primefaces barChart costum x-axes
我的应用程序中有p:barchart图,类似于showCase上的第二个条形图: http : //www.primefaces.org/showcase/ui/barChart.jsf
如何在X轴上自定义数字。 我想格式化x轴只使用整数。
提前致谢。
试试这个(未经测试) :
在你js添加这个
function ext() { this.cfg.seriesDefaults = { useSeriesColor: true, min: 0, max: 200, tickInterval: 20, tickOptions: { formatString: '%d' } }; }
或仅此x轴:
function ext() { this.cfg.axes = { xaxis: { tickInterval: 20, tickOptions: { formatString: '%d' } } }; }
您可以尝试使用tickInterval
…
直接来自PrimeFaces用户指南
扩展
图表提供对常用jqplot选项的高级访问,但jqplot中还有更多自定义选项可用。 扩展器function通过增强this.cfg对象提供对低级api的访问以进行高级自定义,这里是增加线系列阴影深度的示例;
function ext() { //this = chart widget instance //this.cfg = options this.cfg.seriesDefaults = { shadowDepth: 5 }; }
有关可用选项的文档,请参阅jqPlot文档; http://www.jqplot.com/docs/files/jqPlotOptions-txt.html转换器
你的扩展function可能是这样的
function customExtender() { this.cfg.axes.xaxis.tickOptions = { formatString : '%d' }; this.cfg.axes.xaxis.tickInterval = 1; }
我有同样的问题,这很有效,我基于丹尼尔的答案和其他一些代码。 这样它只是格式化所需的轴,而不是两者。
在你js添加这个
function ext() { this.cfg.axes.xaxis.tickOptions.formatString = '%d'; }
您可以使用以下代码从@ManagedBean类将格式设置为axis:
Axis xAxis = categoryModel.getAxis(AxisType.X); xAxis.setTickFormat("%.0f");