【问题标题】:jqPlot bar chart widthjqPlot条形图宽度
【发布时间】:2011-10-19 19:04:22
【问题描述】:

我目前在 jquery 中有一个条形图。如果结果仅显示 1 个条形,则问题是条形填充了整个图表的空间。如何调整条的宽度,使其看起来不像原木。

【问题讨论】:

    标签: width jqplot bar-chart


    【解决方案1】:

    尝试在 BarRenderer 中设置 barWidth:

    http://www.jqplot.com/docs/files/plugins/jqplot-barRenderer-js.html

    【讨论】:

      【解决方案2】:

      如果您仍然希望图表条的大小随条数/图表大小动态调整,请使用 barMargin 和 barPadding 值来调整条的宽度。

      seriesDefaults: {
        renderer: $.jqplot.BarRenderer,
        rendererOptions: { 
          barPadding: 4,
          barMargin: 5
      },
      

      默认值分别为 8 和 10,因此上述值实际上会使您的条形变大。使值大于默认值以减小条形的大小。

      barMargin 是条之间的宽度。如果您的条形图表示多个系列,则 barPadding 是类别中条形之间的宽度。

      请参阅http://www.jqplot.com/docs/files/plugins/jqplot-barRenderer-js.html 了解更多信息。

      【讨论】: