0

您好,我想使用图表容器在页面中显示两个图表。但我无法清除 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> 有人可以帮我吗?

4

2 回答 2

0

如果你想清除你的内容,div你可以使用:

$('#yourDivID').empty();
于 2013-10-29T17:23:07.057 回答
0

在您的代码中,您在两个 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>
于 2013-10-29T17:25:19.610 回答