图中未显示x轴标签

时间:2012-05-10 09:46:03

标签: ruby-on-rails-3.1 flot

我按如下方式绘制数据图,但似乎无法显示轴标签:

!function ($) {
      var options = {
        xaxis: {
                    mode: "time",
                    min: start_time,
                    // max: (new Date()).getTime(),
                    tickSize: [4, "hour"],
                    tickLength: 0,
                    axisLabel: 'Day',
                    axisLabelUseCanvas: true,
                    axisLabelFontSizePixels: 12,
                    axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
                    axisLabelPadding: 3
        },
        yaxis: {
                    axisLabel: 'Amount',
                    axisLabelUseCanvas: true,
                    axisLabelFontSizePixels: 12,
                    axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
                    axisLabelPadding: 5
                },
      }
      $.plot($("#placeholder"), [open_emails],options);


    }(window.jQuery

我在观看中包含以下内容并且正在加载

//= require jquery.flot
//= require jquery.flot.symbol.min
//= require jquery.flot.axislabels

结果如下:

enter image description here

如何显示标签?

1 个答案:

答案 0 :(得分:6)

Hiya 工作演示 http://jsfiddle.net/wuALT/

所以你需要的是添加这个:

<script type='text/javascript' src="https://raw.github.com/xuanluo/flot-axislabels/master/jquery.flot.axislabels.js"></script>

和其余代码将开始识别axisLabel。

阅读: http://codenachos.com/view/axis-labels-in-flot 已知问题http://code.google.com/p/flot/issues/detail?id=42

这将有助于看到DayAmount现在出现在X轴和Y轴上。

enter image description here