在jqplot中,如何在顶部显示x轴,以及如何隐藏轴标签

时间:2012-07-24 04:25:08

标签: jqplot

我有一个jqplot对象,底部有x轴刻度标记/标签。基本上,有一堆图表,都使用相同的x轴。我想从图表线的中间图表中回收底部轴区域。

  • 如何动态地将x轴重新定位到顶部(即向北)
  • 如何让x轴标签消失?为此我尝试了

    plotobject.axes.xaxis.showLabel = false; 
    plotobject.replot(); 
    

但似乎没有明显效果。 plotobject是原始$.jqplot()调用返回的内容,我使用$.jqplot.DateAxisRenderer来表示xaxis.renderer。我只能访问绘图对象。

由于

2 个答案:

答案 0 :(得分:3)

这个简单的CSS解决方案让我可以将x轴标签放在图表的顶部。

.jqplot-xaxis {
    position: relative;
    top: -30px;
}

答案 1 :(得分:1)

好吧,每个轴的标签(轴标题)都有自己的渲染器,因此它有自己的选项。我使用插件一(http://www.jqplot.com/docs/files/plugins/jqplot-canvasAxisLabelRenderer-js.html)但默认情况下还有show:true / false设置。 (http://www.jqplot.com/docs/files/jqplot-axisLabelRenderer-js.html

看起来应该是这样的:

axes: {
    xaxis: {
        labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
        label: 'Dates',
        labelOptions: {
            show: true,
            fontSize: '10pt'
        },
    }
}

为了将x轴放在最上面,我不确定你的问题究竟是什么,但我尝试用jquery选择它并将它的z-index设置为高值以使其处于最佳位置。请查看http://www.jqplot.com/docs/files/jqPlotCssStyling-txt.html了解一些选择的想法。