浮点axisLabel不起作用 [英] flot axisLabel not working

查看:287
本文介绍了浮点axisLabel不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在基本的Flot图上使用标签,我已将其简化为基本知识,但仍然无法使用;

I can't seem to get labels working on my basic Flot graph, I have stripped it down to the basics but I still can't get it to work;

<div id="graph" style="width:600px;height:300px;"></div>

<script type="text/javascript">
$(function () {
    var d1 = [[0, 13], [1, 13], [2, 13], [3, 0], [4, 17], [5, 17], [6, 13]];

    $.plot($("#graph"), [ 
        {
            data: d1,
            bars: {
                show: true
            },
            xaxis: {
                axisLabel: 'Hops'
            },
            yaxis: {
                axisLabel: 'Traceroute'
            }
       }
    ]);

});
</script>

下面是我得到的图表.如您所见,Chrome调试窗口中没有错误.我确实也包含以下简单的轴标签格式设置,但仍然无法使用:

Below is the graph I am getting. As you can see, no errors in the Chrome debug window. I did have the following simple axis label formatting settings included also but it still wouldn't work:

            axisLabelUseCanvas: true,
            axisLabelFontSizePixels: 12,
            axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
            axisLabelPadding: 5

推荐答案

我不知道如何解决此问题,但是通过使其更加复杂,我知道了.也许是错误?

I have no idea how I have fixed this, but by making it more complex, I have. Perhaps a bug?

现在它可以与以下代码一起使用:

Now it works with this code:

<div id="graph" style="width:600px;height:300px;"></div>

<script type="text/javascript">
$(function () {
    var d1 = [[0, 13]];
    var d2 = [[1, 13]]; 
    var d3 = [[2, 13]];
    var d4 = [[3, 30]];
    var d5 = [[4, 17]];
    var d6 = [[5, 17]];
    var d7 = [[6, 13]];

    var data1 = [
        {
            data: d1,
            bars: {
                show: true,
                fillColor:  "#CAFFD8"
            },
            color: "#CAFFD8"
        },
        {
            data: d2,
            bars: {
                show: true,
                fillColor:  "#CAFFD8"
            },
            color: "#CAFFD8"
        },
        {
            data: d3,
            bars: {
                show: true,
                fillColor:  "#CAFFD8"
            },
            color: "#CAFFD8"
        },
        {
            data: d4,
            bars: {
                show: true,
                fillColor:  "#FF7575"
            },
            color: "#FF7575"
        },
        {
            data: d5,
            bars: {
                show: true,
                fillColor:  "#FFFF75"
            },
            color: "#FFFF75"
        },
        {
            data: d6,
            bars: {
                show: true,
                fillColor:  "#FFFF75"
            },
            color: "#FFFF75"
        },
        {
            data: d7,
            bars: {
                show: true,
                fillColor:  "#CAFFD8"
            },
            color: "#CAFFD8"
        },
    ];

    $.plot($("#graph"), data1, { 
            xaxis: {
                axisLabel: 'Hops',
                axisLabelUseCanvas: true,
                axisLabelFontSizePixels: 12,
                axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
                axisLabelPadding: 5
            },
            yaxis: {
                min: 0,
                max: 30,
                axisLabel: 'Traceroute',
                axisLabelUseCanvas: true,
                axisLabelFontSizePixels: 12,
                axisLabelFontFamily: 'Verdana, Arial, Helvetica, Tahoma, sans-serif',
                axisLabelPadding: 5
            }
       });

});
</script>

这篇关于浮点axisLabel不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆