gpt4 book ai didi

javascript - 清除 DIV 标签无效

转载 作者:行者123 更新时间:2023-11-28 12:07:07 24 4
gpt4 key购买 nike

您好,我想使用图表容器在一个页面中显示两个图表。但是我无法清除 DIV 标签。所以只显示最后一张图表。

<script type="text/javascript">
$(function () {
var dataSource =
[
{ status: "Placed", outsideindia: 6.7, india: 28.6 },
{ status: "Unplaced", unplaced: 9.6 }
];

$("#chartContainer").dxChart({
dataSource: dataSource,
commonSeriesSettings: {
argumentField: "status",
type: "stackedBar"
}
});
});

</script>



<div id="chartContainer" style="width: 100%; height: 440px;"></div>
<div style="clear: both;"></div>

<script type="text/javascript">
$(function () {
$("#chartContainer").dxChart({


series: {
argumentField: "st_status",
valueField: "oranges",
name: "Series 1",
type: "bar",
color: "blue"
}
});
});
</script>

<div id="chartContainer" style="width: 100%; height: 400px;"></div>有人可以帮我解决这个问题吗?

最佳答案

在您的代码中,您在两个 div 上使用相同的 ID。每个元素都应该有唯一的 ID。更改它并尝试以下操作:

<script type="text/javascript">
$(function (){
var dataSource = [
{ status: "Placed", outsideindia: 6.7, india: 28.6},
{ status: "Unplaced", unplaced: 9.6}
];

$("#chartContainer1").dxChart({
dataSource: dataSource,
commonSeriesSettings: {
argumentField: "status",
type: "stackedBar"
},

</script>


<div id="chartContainer1" style="width: 100%; height: 440px;" ></div>
<div style="clear:both;"></div>
<script type="text/javascript">
$(function ()
{
$("#chartContainer2").dxChart({


series: {
argumentField: "st_status",
valueField: "oranges",
name: "Series 1",
type: "bar",
color: "blue"
}
});
}

);
</script>


<div id="chartContainer2" style="width: 100%; height: 400px;" ></div>

关于javascript - 清除 DIV 标签无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19665070/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com