Jquery Flot饼图中的左偏移不起作用
我想将Jquery Flot饼图中的左偏移不起作用,jquery,jquery-plugins,charts,flot,pie-chart,Jquery,Jquery Plugins,Charts,Flot,Pie Chart,我想将饼图放在图表的左上角,但left属性不可用 正在工作,top另一方面正在工作 代码: $(function () { var data = [ { label: "Read", data: 50, color: '#614E43' }, { label: "Unread", data: 150, color: '#F5912D' }]; $.plot($("#star"), data, { series: {
饼图
放在图表
的左上角,但left
属性不可用
正在工作,top
另一方面正在工作
代码:
$(function () {
var data = [
{ label: "Read", data: 50, color: '#614E43' },
{ label: "Unread", data: 150, color: '#F5912D' }];
$.plot($("#star"), data,
{
series: {
pie: {
radius: 0.2,
innerRadius: 0.125,
show: true,
stroke: {
width: 0.1,
color: '#808080'
},
offset: {
top: -70,
left: -30
}
}
}
});
});
问题在于
setupPie()
函数。我认为这是一个错误
饼图不允许左位置低于最大半径,即使实际半径较小
http://flot.googlecode.com/svn/trunk/jquery.flot.pie.js @第204行
if (centerLeft<maxRadius)
centerLeft = maxRadius;
else if (centerLeft>canvas.width-maxRadius)
centerLeft = canvas.width-maxRadius;
if(centerLeftcanvas.width maxRadius)
centerLeft=canvas.width-maxRadius;
如果设置了相对半径,则不应将左侧与最大宽度进行对比
相反,应该有如下内容:
//calculate the radius the same way drawPie() does
var radius = options.series.pie.radius;
if (options.series.pie.radius < 1)
radius *= maxRadius;
//and compare to that value
if (centerLeft < radius)
centerLeft = radius;
else if (centerLeft > canvas.width-radius)
centerLeft = canvas.width-radius;
//用drawPie()的方法计算半径
变量半径=options.series.pie.radius;
如果(options.series.pie.radius<1)
半径*=最大半径;
//并与该值进行比较
if(中心距<半径)
中心距=半径;
else if(左中>画布宽度半径)
centerLeft=画布宽度-半径;
编辑:
我已经完成了回购并尝试了我的代码,似乎正在完成工作
我的。正如@MasterAM正确指出的那样,该缺陷妨碍了左中锋的裁剪。一个稍微好一点的解决方案是简单地将其移动到检查width==“auto”中,因为剪辑只适用于这种情况
请注意,您正在使用的来自code.google.com的Flot版本非常旧;我们不久前搬去了。我已向master推送了一个修复程序,因此如果您从GH切换到最新版本,您将全部就绪。添加了一个拉取请求。希望你能考虑一下。