【发布时间】:2016-07-03 12:50:45
【问题描述】:
Pie1 默认显示。单击 Pie2 或 Pie3 的下拉菜单将 DIV 留空,再次选择 Pie1 将返回 echarts_Pie1。我的 pie2 和 pie3 下拉菜单不起作用。
<script language="javascript">
ivan = {};
ivan.showhide = function(val1)
{
if(val1 == 1)
{
document.getElementById('echart_pie1').style.display = "";
document.getElementById('echart_pie2').style.display = "none";
document.getElementById('echart_pie3').style.display = "none";
}
else if (val1 == 2)
{
document.getElementById('echart_pie1').style.display = "none";
document.getElementById('echart_pie2').style.display = "";
document.getElementById('echart_pie3').style.display = "none";
}
else if (val1 == 3)
{
document.getElementById('echart_pie1').style.display = "none";
document.getElementById('echart_pie2').style.display = "none";
document.getElementById('echart_pie3').style.display = "";
}
}
</script>
Pie1 默认显示。单击 Pie2 或 Pie3 的下拉菜单将 DIV 留空,再次选择 Pie1 将返回 echarts_Pie1。我的 pie2 和 pie3 下拉菜单不起作用。
<div class="col-md-3 col-sm-4 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Storage</h2>
<ul class="nav navbar-right panel_toolbox">
<li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
<ul class="dropdown-menu" role="menu">
<option onclick="ivan.showhide(1)">Pie1</option>
<option onclick="ivan.showhide(2)">Pie2</option>
<option onclick="ivan.showhide(3)">Pie3</option>
</ul>
</li>
<li><a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<div id="echart_pie1" style="height:180px;"></div>
<div id="echart_pie2" style="height:180px; display:none;"></div>
<div id="echart_pie3" style="height:180px; display:none;"></div>
</div>
【问题讨论】:
-
echart_pie2有什么内容?您提供的 HTML 没有任何内容,因此我假设您有为其提供内容的脚本。您能否将该脚本添加到问题中或解释该元素如何获取其内容? -
请注意,
option元素不允许作为ul元素的子元素出现。允许的父母是optgroup,select, ordatalist。 -
这一定是我渲染需要重新生成的图形的方式,
-
我听不懂你在说什么?
-
@trincot 页面加载时,我在 div 上使用 display:none,我认为它需要重新生成要显示的图形。我可能不得不隐藏起来,但是然后divs堆叠在彼此的下方。默认图形加载,但是当我选择其他图形时- div 是空白的。我需要一个加载所有 3 个图形的函数,然后将 2 设置为隐藏。只是不确定这是否是正确的方法,或者 tbh - 如何做到这一点。
标签: javascript html echarts