1

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

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

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

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

谢谢

4

2 回答 2

3

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

.jqplot-xaxis {
    position: relative;
    top: -30px;
}
于 2014-01-20T16:56:17.877 回答
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了解一些选择思路。

于 2012-07-24T20:27:48.410 回答