2011-07-28 135 views
4

获取日志消息:饼图的直径太小,不能渲染。jqplot饼图无法正确显示。

然后,似乎当我将鼠标悬停或点击网页我进去:遗漏的类型错误:无法读取的不确定

<link href="/Content/jqPlot/jquery.jqplot.css" rel="stylesheet" type="text/css" /> 
    <script src="/Scripts/jquery.jqplot.js" type="text/javascript"></script> 
    <script src="/Scripts/jqplot.pieRenderer.js" type="text/javascript"></script> 

    <script type="text/javascript"> 
     $(function() { 
      //GetWeeklyProjectSummary(); 
      Test(); 
     }); 

     function Test() { 
      var data = [["987 Project",74],["ABC Project",68],["XYZ project",26]]; 
      var plot1 = jQuery.jqplot('weeklyProjectSummary', [data], 
       { 
        seriesDefaults: { 
         // Make this a pie chart. 
         renderer: jQuery.jqplot.PieRenderer, 
         rendererOptions: { 
          // Put data labels on the pie slices. 
          // By default, labels show the percentage of the slice. 
          showDataLabels: true 
         } 
        }, 
        legend: { show: true, location: 'e' } 
       } 
      ); 
     } 
    </script> 

这里财产“0”是其进入股利:

<div id="weeklyProjectSummary"></div> 

这是我在页面上得到的:page output

让我知道你是否需要任何更多的细节。

回答

11

我在使用jpgplot和blueprintcss时出现了类似的问题 - 基于你的屏幕截图我相信你正在使用blueprintcss。

尝试删除以下行:

legend: { show: true, location: 'e' } 

,看看它是否正确地呈现。

(编辑:点击此处了解详情:

https://bitbucket.org/cleonello/jqplot/issue/48/legends-doesnt-look-nice-when-using

+0

这个工作,但我怎么得到的传说? – Justin

+0

呵呵,阅读链接! – Justin

+0

一切都很好,谢谢。 – Justin

0

您的JQPlot图表定义似乎正确。馅饼在我的屏幕上呈现正确。

我没有看到包含jquery.js或jquery.min.js。你能确认你的代码中有这个文件的引用吗?

此外,请确认您所有的js/css文件都被正确引用(您可以使用JSView Firefox Extension快速确认它们确实包含在内)。

0

包括canvas.min.js。你可以在下载的例子中找到它。它与传奇一起为我工作。

3

我添加下面的行我的CSS文件

.jqplot表,传说{宽度:自动; }

从jqplot css文件重载属性。

为我工作。

+0

这可以解决与现场Foundation CSS相同的错误。 – skobaljic

0

我只是想答案从Amaud T扩展:

我面临着同样的问题,我用上面的回答,有一些小的修改:

<style type="text/css"> 
    #chartComponentId table.jqplot-table-legend { width: auto !important;} 
</style> 
<div id="chartComponentId" class="chartComponent"> 
... 
</div> 

由于需要使用的!重要的,在特定的div对象上绑定这个样式表可以防止对其他元素产生任何副作用。