jqplot和图例选项问题

发布于 2024-10-02 15:01:31 字数 949 浏览 2 评论 0原文

我的代码中有以下内容。拥有该选项

 legend: {show:true}  

会严重扰乱图表。图例部分好长 并且没有图表。 我已将图表的外观图像粘贴到此处: http://tinypic.com/view.php?pic=2eqgbgy&s=7

虽然没有图例选项,它显示得很好,但图表当然没有图例。

在 Chrome 中我看到以下异常 未捕获的错误:INDEX_SIZE_ERR:DOM 异常 1

<script type="text/javascript"> 
        line2 = [['Living Expenses',1000], ['Loans',2000], ['Credit 
Card',500]]; 
    $j(document).ready(function() { 
        $j.jqplot.config.enablePlugins = true; 
        $j.jqplot('piechartdiv', [line2], { 
            title: 'Where is my money going?', 
            seriesDefaults:{renderer:$j.jqplot.PieRenderer, 
rendererOptions:{sliceMargin:8}}, legend:{show:true} 
        }); 
}); 

</script> 

<div style="width: 450px;margin: 0px auto;"> 
    <div id='piechartdiv'></div> 
</div> 

感谢任何帮助。

I have the following in my code. Having the option

 legend: {show:true}  

messes up the chart badly. The legend section is so long
and there is no chart.
I have pasted the image here of how the chart looks :
http://tinypic.com/view.php?pic=2eqgbgy&s=7

It shows fine without the legend option though, but chart is of course without the legend.

In Chrome I see the following exception
Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1

<script type="text/javascript"> 
        line2 = [['Living Expenses',1000], ['Loans',2000], ['Credit 
Card',500]]; 
    $j(document).ready(function() { 
        $j.jqplot.config.enablePlugins = true; 
        $j.jqplot('piechartdiv', [line2], { 
            title: 'Where is my money going?', 
            seriesDefaults:{renderer:$j.jqplot.PieRenderer, 
rendererOptions:{sliceMargin:8}}, legend:{show:true} 
        }); 
}); 

</script> 

<div style="width: 450px;margin: 0px auto;"> 
    <div id='piechartdiv'></div> 
</div> 

Any help appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

淡紫姑娘! 2024-10-09 15:01:31

您是否使用 Bootstrap 或其他 CSS 重置库?

如果您进入 firebug,并选择 元素,您可能会看到有一个 width:100 % 默认属性设置table 元素。您可以在 CSS 布局中修复它:

#piechartdiv table.jqplot-table-legend {
    width:auto;
}

Are you using Bootstrap or some other CSS reset library?

If you go into firebug, and select the <table class="jqplot-table-legend" ...> element, you'll probably see that there is a width:100% default property set the table elements. You can fix it in your CSS layout:

#piechartdiv table.jqplot-table-legend {
    width:auto;
}
花想c 2024-10-09 15:01:31

对我来说唯一奇怪的是:

$j.jqplot

为什么你的代码上有一些J?除此之外,一切似乎都很好,也许尝试在图例上放置一个位置,看看是否解决这个问题,这是一个例子:

plot = $.jqplot('chart2', [arr], {
        grid: {
            drawBorder: true,
            drawGridlines: false,
            background: '#FFFFFF',
            shadow: true
        },
        seriesDefaults: {
            renderer: $.jqplot.PieRenderer,
            rendererOptions: {
                showDataLabels: true
            }
        },
        legend: {
            show: true,
            location: 'e'
        }
    });

The only thing that seems weird to me is this:

$j.jqplot

Why are there some J's on your code?, besides that, everything seems to be fine, maybe try putting a location on the legend to see if that fix the issue, here is an example:

plot = $.jqplot('chart2', [arr], {
        grid: {
            drawBorder: true,
            drawGridlines: false,
            background: '#FFFFFF',
            shadow: true
        },
        seriesDefaults: {
            renderer: $.jqplot.PieRenderer,
            rendererOptions: {
                showDataLabels: true
            }
        },
        legend: {
            show: true,
            location: 'e'
        }
    });
能怎样 2024-10-09 15:01:31

我遇到过类似的事情。
尝试检查 css 属性 text-align:left

<div id='piechartdiv' style="text-align:left;"></div> 

恐怕我不知道为什么,但这些为我修复了错误

I came across something similar.
try checking css property text-align:left

<div id='piechartdiv' style="text-align:left;"></div> 

I'm afraid I don't know why but these fixed the error for me

天冷不及心凉 2024-10-09 15:01:31

您是否在代码中包含了 jqplot.css 文件?

确保它包含在代码中,并且该文件也存在于您引用的目录中。

谢谢

Have you included the jqplot.css file in your code.

Make sure that it is included in the code, and that the file is also present in the directory you are referring to.

Thank you

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文