flot异常flot高度=0的维度无效

flot exception invalid dimention for flot height = 0

本文关键字:flot 无效 异常 高度      更新时间:2023-09-26

这是我的图表flot选项

var chartOptions = {
               xaxis: {
                   min: 0,
                   max: result.length + 1,
                   ticks: ticks
               },
               grid: {
                   hoverable: true,
                   clickable: false,
                   borderWidth: 0
               },
               bars: {
                   show: true,
                   barWidth: 1,
                   //barWidth:null,
                   fill: true,
                   lineWidth: 1,
                   order: true,
                   lineWidth: 0,
                   fillColor: { colors: [{ opacity: 1 }, { opacity: 1 }] }
               },
               tooltip: true,
               tooltipOpts: {
                   content: '%s: %y'
               },
               colors: App.chartColors
           };
           var holder = $('#vertical-chart');
           if (holder.length) {
               $.plot(holder, data, chartOptions);
           }

我得到了例外:

invalid dimention for flot hieght =0

  1. html没有问题,因为我可以使用相同的html绘制另一个图表

请帮忙

更新

这是HTML

<div style="width: 45%; height:300px; float: left; margin-left:5%">                      
    <div id="vertical-chart" class="chart-holder" style="border:1px solid #D5D5D5; margin-top:2px">
        <canvas class="overlay" width="479" height="265"></canvas>
    </div>
</div>

这可能会解决您的问题:将画布类从overlay更改为flot-overlay

类名由于以下请求而更改:

https://code.google.com/p/flot/issues/detail?id=540

你会看到API的变化描述在这里的第二段:

https://code.google.com/p/flot/source/browse/trunk/NEWS.txt

如果没有此更改,画布将在plot调用期间被删除,从而使vertical-chart没有高度。

如果这不能解决您的问题,那么查看data对象会很有用。