【问题标题】:Extjs 3 How to remove chart and display new chart without refreshing the screenExtjs 3 如何在不刷新屏幕的情况下删除图表并显示新图表
【发布时间】:2021-08-02 20:49:03
【问题描述】:

Flash Player 将消失,我需要找到一个修复程序来显示图表项。我找到了 extjs3-chartjs-extension。我能够创建饼图,但我遇到了删除图表并将其替换为新饼图的问题。

我将以下内容添加到 php demo.v.php

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Demo Report</title>
  </head>

    <body>
      <div id="container"></div>
    </body>
</html>

demo.js

    function showChart(category, type){
      var container = new Ext.Container({ 
        items: [
          new Ext.Panel({
            title: category,
            height: 320,
            width: 600,
            layout: "fit",
              items: [
              new Ext.ux.Chartjs({
               type: "Pie",
               data: [
                 {
                   value: 300,
                   color:"#F7464A",
                   highlight: "#FF5A5E",
                   label: "Red"
                 },
                 {
                   value: 50,
                   color: "#46BFBD",
                   highlight: "#5AD3D1",
                   label: "Green"
                 },
                 {
                   value: 100,
                   color: "#FDB45C",
                   highlight: "#FFC870",
                   label: "Yellow"
                 }
               })
             ]
           })
          ],
            renderTo: "container"
        });

我尝试过使用

document.getElementById('container').remove();

继续构建新的饼图。 我在 console.log 中收到以下错误 错误:

Uncaught TypeError: Cannot read property 'dom' of null

【问题讨论】:

  • 您确定问题是由移除容器引起的吗?
  • 我认为当您尝试构建图表时会出现问题

标签: php extjs3


【解决方案1】:

试试这个document.getElementById('container').parentElement.innerHTML = ""

它应该删除容器元素的父元素内的所有内容

如果你体内有其他元素,那么只需用一个元素包围容器即可

【讨论】:

  • 谢谢!我需要使用我的容器 firstElementChild。
猜你喜欢
  • 2019-11-25
  • 1970-01-01
  • 2022-01-25
  • 2020-02-26
  • 2011-07-07
  • 2017-08-05
  • 2019-10-05
  • 1970-01-01
  • 2020-03-11
相关资源
最近更新 更多