当我指定x轴选项时,为什么y轴系列标签会发生变化?

时间:2013-11-15 17:07:54

标签: primefaces jqplot

我有PrimeFaces生成的水平条形图,我已经扩展了它以进一步控制配置:

<h:inputHidden value="#{chartBean.chartHeight}" id="chartheight" />

<p:barChart id="chart" value="#{chartBean.chartModel}" orientation="horizontal"
    rendered="#{!empty chartBean.chartModel.series}" 
    title="Grades For Department" min="0" max="5" extender="my_ext" />  

<script type="text/javascript">
    function my_ext() {
        var val=$("#chartheight").val();
        $("#chart").height(val);
        this.cfg.seriesDefaults = {
            renderer:$.jqplot.BarRenderer,
            pointLabels: {show: true},
            rendererOptions: {
                barWidth: 20,
                barPadding: 10,
                barDirection: 'horizontal'
            }
        },
        this.cfg.axes = {
            xaxis: {
                renderer: $.jqplot.LinearAxisRenderer,
                tickInterval: 1
            }
        };
    }
</script>

如果没有脚本的'this.cfg.axes'部分,我的y轴系列标签会显示人物的名称(如预期的那样)。但是,一旦我添加此部分,系列标签就会改为增加数字。为什么会这样,以及在保留原始标签的同时指定x轴配置需要做什么?

顺便说一句,当悬停在任何一个条上时,会显示此数字而不是名称 - 无论我使用哪种版本的脚本。

非常感谢, 尼尔

1 个答案:

答案 0 :(得分:0)

经过更多调查后,我找到了解决方案,虽然我不确定PrimeFaces或jqplot是否存在问题:xaxis ticks需要在定制配置后再次重新设置....

this.cfg.axes.yaxis.ticks = this.cfg.categories;
相关问题