【问题标题】:Jquery flot pie chart going crazyJquery Flot饼图发疯了
【发布时间】:2014-01-30 22:21:01
【问题描述】:

我有一个非常简单的图表,幕后没有有趣的代码,但每次加载图表的方式都不同,在两种放置标签的方式之间交替,如下所示:

所有标签似乎都被推到不同的位置。我正在使用:

  • jquery v 1.7.1(我后来更新到 v 1.11,但没有任何改变)
  • jquery flot v 0.7(我后来更新到 v 0.8,但没有任何改变)
  • jquery flot pie v 1.1

这背后的代码是:

var options = 
{
    series: {
        pie: {
            show: true,
            label: {
                show: true,
                formatter: function (label, series)
                {
                    return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;background-color:#000">' + label + '<br/>' + Math.round(series.data[0][1]) + '%</div>';
                }
            }
        }
    },

    legend: {
        show: false
    }
};

$.plot($('#chart'), data, options);

paceholder div的html:

<div id="#chart" style="margin: 40px 20px 20px 0px; padding: 0px; 
                        position: relative; width:400px; height: 300px;"></div>

【问题讨论】:

  • 你能显示占位符 div 的 html 吗?它会随着浏览器窗口的大小而改变吗?
  • @Mark 已按要求更新
  • @AndriusNaruševičius 你能为它准备一把小提琴吗?
  • 升级到新版本的 Flot 是否解决了这个问题,就像在您的其他问题 (stackoverflow.com/questions/21421614/…) 中所做的那样?
  • @DNS 是的,抱歉,我完全忘记了这个问题 :(

标签: jquery label flot pie-chart


【解决方案1】:

显然,这已通过更新的插件组合得到解决(就像我的另一个问题 here):

v0.7 to v0.8 of jquery.flot.js 

v1.0 to v1.1 of jquery.flot.pie.js

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多