0
我在弹出窗口中打开nvd3饼图。我创建弹出窗口是这样的:在弹出窗口中显示nvd3 pieChart时的问题?
function openPopup(html,pos,style) {
var newWindow = window.open('');
newWindow.document.write(html);
return newWindow;
}
function openChartPopup(chartID,chartTitle) {
divId = "div" + chartID;
html = "<p>"+chartTitle+"</p><div id= \""+divId+"\"><svg id=\""+chartID+"\"></svg></div>";
newWindow = openPopup(html,"_blank","");
return d3.select(newWindow.document.getElementById(chartID));
}
然后创建使用饼图下面的代码:
de_select = openChartPopup("test_chart","TEst Chart");
var chart = nv.models.pieChart()
.x(function(d) { return d.label })
.y(function(d) { return d.value })
.showLabels(true)
.growOnHover(true);
de_select.datum(exampleData());
de_select.style({"width":"400px", "height":"500px"});
de_select.transition().duration(350);
de_select.call(chart);
nv.addGraph(chart);
我执行按钮点击上面的代码中打开一个图表中弹出,但有时它不”牛逼正确显示,看起来像这样:
然而,所有的图表属性仍然无法正常工作,例如“growOnHover”但同样的代码工作正常,当我在一个普通的HTML页面,而不是弹出显示的图表,我想它是与弹出式窗口,这是NVD3的问题吗?任何人都可以指出这个问题吗?
虽然这个代码片断可以解决的问题,[包括说明](// meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)确实有助于提高您的帖子的质量。请记住,您将来会为读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要使用解释性注释来挤占代码,因为这会降低代码和解释的可读性! – FrankerZ
@FrankerZ感谢您的评论。我更新 – programmer1490
@ programmer1490,我使用相同的代码,你提到openPopup是一个功能,我已经更新了,你可以看到帖子的答案。此外,我想你的窗口大小调整的建议,但没有奏效 – TechMaster