【发布时间】:2018-10-20 21:52:39
【问题描述】:
我遇到了一个问题,即浮动图无法在选项卡式界面中呈现,因为占位符 div 是具有“显示:无”的 div 的子级。将显示轴,但没有图表内容。
为了解决这个问题,我编写了下面的 javascript 函数作为绘图函数的包装器。它可能对其他做类似事情的人有用。
function safePlot(placeholderDiv, data, options){
// Move the graph place holder to the hidden loader
// div to render
var parentContainer = placeholderDiv.parent();
$('#graphLoaderDiv').append(placeholderDiv);
// Render the graph
$.plot(placeholderDiv, data, options);
// Move the graph back to it's original parent
// container
parentContainer.append(placeholderDiv);
}
这是图形加载器 div 的 CSS,可以放置 页面上的任何位置。
#graphLoaderDiv{
visibility: hidden;
position: absolute;
top: 0px;
left: 0px;
width: 500px;
height: 150px;
}
【问题讨论】:
标签: javascript jquery flot