Skip to content

Uncaught TypeError: Cannot read property 'appendChild' #23

@ctaity

Description

@ctaity

When the controller destroys (change to another view) i get:

Uncaught TypeError: Cannot read property 'appendChild' of null
at Object.AAF (eval at (http://localhost:3000/bower_components/zingchart/client/zingchart.min.js:8:1), :1:70276)
at Object.HB (eval at (http://localhost:3000/bower_components/zingchart/client/zingchart.min.js:8:1), :1:69912)
at c.paint (eval at (http://localhost:3000/bower_components/zingchart/client/zingchart.min.js:8:1), :1:257198)
at c.f.(anonymous function) [as paint] (eval at (http://localhost:3000/bower_components/zingchart/client/zingchart.min.js:8:1), :1:17736)
at eval (eval at (http://localhost:3000/bower_components/zingchart/client/zingchart.min.js:8:1), :1:278976)
at c.OG (eval at (http://localhost:3000/bower_components/zingchart/client/zingchart.min.js:8:1), :1:249889)
at eval (eval at (http://localhost:3000/bower_components/zingchart/client/zingchart.min.js:8:1), :1:278950)
AAF @ VM4969:1
HB @ VM4969:1
paint @ VM4969:1
f.(anonymous function) @ VM4969:1
(anonymous) @ VM4969:1
OG @ VM4969:1
(anonymous) @ VM4969:1
setTimeout (async)
XS @ VM4969:1
(anonymous) @ VM4969:1
zingchart.A0G @ VM4969:1
JN @ VM4969:1
zingchart.AAD @ VM4969:1
zingchart.ABS @ VM4969:1
zingchart.exec @ VM4969:1
(anonymous) @ zingchart-angularjs.js:84
$digest @ angular.js:18210
$apply @ angular.js:18480
(anonymous) @ angular.js:14373
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3

The code of the controller is:



angular.module('videoPlatformApp-stats-controllers', [])
    .controller('DashBoardController', function ($scope, __env, $document, $http) {
        $scope.myJson = {
            type: 'line',
            backgroundColor: '#2C2C39',
            title: {
                text: 'Eventos',
                adjustLayout: true,
                fontColor: "#E3E3E5",
                marginTop: 7
            },
            legend: {
                align: 'center',
                verticalAlign: 'top',
                backgroundColor: 'none',
                borderWidth: 0,
                item: {
                    fontColor: '#E3E3E5',
                    cursor: 'hand'
                },
                marker: {
                    type: 'circle',
                    borderWidth: 0,
                    cursor: 'hand'
                }
            },
            plotarea: {
                margin: 'dynamic 70'
            },
            plot: {
                aspect: 'spline',
                lineWidth: 2,
                marker: {
                    borderWidth: 0,
                    size: 5
                }
            },
            scaleX: {
                lineColor: '#E3E3E5',
                zooming: true,
                item: {
                    fontColor: '#E3E3E5'
                },
                transform: {
                    type: 'date',
                    all: '%D %M %d<br>%H:%i:%s'
                }
            },
            scaleY: {
                minorTicks: 1,
                lineColor: '#E3E3E5',
                tick: {
                    lineColor: '#E3E3E5'
                },
                minorTick: {
                    lineColor: '#E3E3E5'
                },
                minorGuide: {
                    visible: true,
                    lineWidth: 1,
                    lineColor: '#E3E3E5',
                    alpha: 0.7,
                    lineStyle: 'dashed'
                },
                guide: {
                    lineStyle: 'dashed'
                },
                item: {
                    fontColor: '#E3E3E5'
                }
            },
            tooltip: {
                borderWidth: 0,
                borderRadius: 3
            },
            preview: {
                adjustLayout: true,
                borderColor: '#E3E3E5',
                mask: {
                    backgroundColor: '#E3E3E5'
                }
            },
            crosshairX: {
                plotLabel: {
                    multiple: true,
                    borderRadius: 3
                },
                scaleLabel: {
                    backgroundColor: '#53535e',
                    borderRadius: 3
                },
                marker: {
                    size: 7,
                    alpha: 0.5
                }
            },
            crosshairY: {
                lineColor: '#E3E3E5',
                type: 'multiple',
                scaleLabel: {
                    decimals: 2,
                    borderRadius: 3,
                    offsetX: -5,
                    fontColor: "#2C2C39",
                    bold: true
                }
            },
            series: []
        };

        this.$onInit = function () {
            $http.get(urljoin(__env.statsUrl, "test")).then(function (response) {
                $scope.myJson.series = response.data;
            })
        };

        this.$onDestroy = function () {
        };
    })

And the code of the view is:

<div class="row" ng-controller="DashBoardController">
  <div class="col-md-12">
    <div class="box">
      <div class="box-header with-border">
        <h3 class="box-title">Videos mas vistos</h3>

        <div class="box-tools pull-right">
          <button type="button" class="btn btn-box-tool" data-widget="collapse" data-toggle="tooltip" title="Collapse">
            <i class="fa fa-minus"></i>
          </button>
          <button type="button" class="btn btn-box-tool" data-widget="remove" data-toggle="tooltip" title="Remove">
            <i class="fa fa-times"></i>
          </button>
        </div>
      </div>
      <div >
        <div zingchart id="myChart" class="box-body" zc-json="myJson" zc-values="series" zc-height=400 zc-width=100%></div>
      </div>
    </div>
  </div>
</div>

I try remove element on destroy, but nothing, can you help me_

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions