Highcharts nodeName of undefined - javascript

When playing around with a chart generated by highcharts, and exporting it to SVG, I get a lot of errors, about 1000 (nodeName of undefined) per 6 seconds
The code responsible is this:
element = wrapper.element,
nodeName = element.nodeName, // <---- Here (Cannot read property 'nodeName' of undefined)
renderer = wrapper.renderer,
skipAttr,
attrSetters = wrapper.attrSetters,
shadows = wrapper.shadows,
hasSetSymbolSize,
ret = wrapper;
The stacktrace (in Chrome 17.0.963)
Uncaught TypeError: Cannot read property 'nodeName' of undefined
SVGElement.attr highcharts.src.js:2008
init.Effect.HighchartsTransition.Class.create.update prototype-adapter.src.js:86
(anonymous function) effects.js:1
Effect.Base.Class.create.loop effects.js:1
Effect.ScopedQueue.Class.create.loop effects.js:1
b prototype.js:1
The fiddle to re-create : here, to reproduce click the series on/off and then click on the My Download link, switch on/off again and click on the My Download link again.
My question is as follows, is this my code, or a bug in highcharts; and how can I fix it?

Got the answer I was looking for; It was a bug in highcharts, fixed here

I am not really familiar with Prototype framework, but I did some tests and look at this code:
function getGraphSVG(options) {
var svg;
if (window.charts) {
window.charts.each(function(pair) {
svg = pair.value.getSVG(options);
throw $break;
});
}
return svg;
}
Somehow this each method returns 2 objects, one being undefined. So do the simple check:
if (pair.value)
svg = pair.value.getSVG(options);
or in one line
pair.value && ( svg = pair.value.getSVG(options) );
and it should work.

Related

FIVEM : Uncaught TypeError: Cannot read property 'x' of undefined (#esx_mcdonaldscrafting/html/js/app.js:66)

So I'm trying to develop a fivem server without knowing much about coding. I get this error in a script I have and at row 66 I have this :
return { 'x': rects.x + (rects.width/2),'y': rects.y + (rects.height/2) };
Full :
// Get the abosolute position of a node
function getPosition(node)
{
var rects = node.getClientRects()[0];
return { 'x': rects.x + (rects.width/2),'y': rects.y + (rects.height/2) };
}
Anyone who can help me out?
Note: This is a dublicated script (the script is officially named esx_crafting) which I wanted to seperate from the original one. It is used to craft items using what you have in your inventory but I wanted to make different list items depended on the x,y,z of each crafting menu. So that's the reason why I dublicated the scripts. If that's the problem, is there any other way to make this work?

Error when using addChild twice in one function in NativeScript

I am trying to dynamically create stackLayouts and add them to the existing scrollView but got an error:
JS ERROR TypeError: scrollView.addChild is not a function. (In 'scrollView.addChild(stackLayout)', 'scrollView.addChild' is undefined)
but by using console.log it sees both of them:
StackLayout(10) ScrollView<dates>#diary/diary-page.xml:4:7;
My code is:
input.forEach(function(entry) {
const scrollView = page.getViewById("dates");
var stackLayout = new StackLayout();
stackLayout.className = 'date';
var label = new Label();
label.text = entry.Date;
stackLayout.addChild(label);
console.log(stackLayout + ' ' + scrollView);
scrollView.addChild(stackLayout);
});
Can anybody help with this strange behaviour? Thank you
What's the code of your getViewById function? It looks like it doesn't return DOM element, this is why you can't call addChild on scrollView.
Found the reason here: How to nest elements in dynamically created ScrollView?
"ScrollView is actually an implantation of ContentView so the right way to set it's content is by doing:
scrollview.content = stacklayout
Note: Only can only set a single content view. That's the reason there is not addChild method as it suggests multiple children are supported."

Getting Uncaught TypeError: Cannot read property 'getAttribute' of null but code is working

I have made a soundboard website which has a number of small audio clips and the below Javascript to play, pause and reset them when they are finished playing. The page works exactly as expected but I get a
index.html:90 Uncaught TypeError: Cannot read property 'getAttribute' of null
error in my Javascript console and I have no idea why.
cliplist = ['audio1','audio2','audio3','audio4','audio5','audio6','audio7','audio8'];
playerlist = ['player1','player2','player3','player4','player5','player6','player7','player8'];
document.addEventListener("DOMContentLoaded", function()
{
for(let i=0;i<cliplist.length;i++)
{
document.getElementById(playerlist[i]).addEventListener("click", function()
{
playClip(cliplist[i]);
})
document.getElementById(playerlist[i]).addEventListener("click", function()
{
playClip(cliplist[i],playerlist[i]);
})
document.getElementById(cliplist[i]).addEventListener("ended", function()
{
reset(playerlist[i]);
})
}
});
function playClip(theclip,theplayer)
{
playerElement = document.getElementById(theplayer);
clipElement = document.getElementById(theclip)
if(playerElement.getAttribute("src") == 'playbutton.png')
{
playerElement.setAttribute("src","pausebutton.png");
clipElement.play();
}
else
{
playerElement.setAttribute("src","playbutton.png");
clipElement.pause();
}
}
function reset(theplayer)
{
document.getElementById(theplayer).src = 'playbutton.png';
}
You have a call to playClip that looks like this:
playClip(cliplist[i]);
It only passes one argument. But, playClip() expects a second argument and that is what is used with .getElementById(), which gets a DOM element that .getAttribute() is called on. When you don't pass the argument, you don't get a DOM element and you get the error.
So, make sure that you pass it the two arguments it's looking for, like in the other spot where you wrote:
playClip(cliplist[i],playerlist[i]);
Lastly, the reason it still works is because you are adding two click event hanlders to document.getElementById(playerlist[i]). The first one throws the error and the second one works.

What causes Kendo to throw a "Cannot read property 'offsetTop' of null" js error?

I get the following Kendo js error and stack trace from a page with a Kendo Grid with the error coming in about once or twice a day at random from end users:
Message: Cannot read property 'offsetTop' of null
at offsetTop line 28097, column 35 (/source//kendo.all.js:28097)
var itemHeight = $(element.children[0]).height();
var itemIndex = Math.floor(scrollTop / itemHeight) || 0;
var item = element.children[itemIndex] || element.lastChild;
var forward = item.offsetTop < scrollTop;
while (item) {
if (forward) {
if (item.offsetTop + itemHeight > scrollTop || !item.nextSibling) {
at _firstVisibleItem line 28127, column 39
(/source//kendo.all.js:28127)
if (!template) {
return;
}
var visibleItem = this._firstVisibleItem();
if (visibleItem) {
this.header.html(template(visibleItem.group));
}
at _renderHeader line 27650, column 29 (/source//kendo.all.js:27650)
var that = this;
clearTimeout(that._scrollId);
that._scrollId = setTimeout(function () {
that._renderHeader();
}, 50);
}, this);
},
It's not clear if the error is having any impact, but any error is disturbing and takes up room in our error log. My best guess is that the error occurs while the user is navigating away from the page. Perhaps there is a way to dispose of the grid safely without issue, though the problem could be something else entirely.
I'm using the latest Kendo release from January 2017, but I've seen it on previous versions as well.
Is there anything that can be done to eliminate this error, or can it be safely ignored?
This error occurs probably because the grid isn't completely loaded in the DOM when a piece of your code is running and using some functionality of the grid.
What you need to do to find the cause is go further down the call-stack to the first appearance of a function in your code and not Kendo's.
I had a similar error happen to me. I'm using angular2 and tried using a Kendo Scheduler's functionality before the view was ready.

DHTMLX Error on dock [ing] an undocked cell

I am having trouble getting an undocked cell in DHTMLX 4 to dock.
When I click on the provided "dock" button(on the undocked cell) I get the error:
Uncaught TypeError: Cannot read property 'close' of null
I also get this same error when assigning the .dock() function to another button.
onclick: function ()
{
// where to undock to
_this.dhxLayout.dhxWins.attachViewportTo("layout_div");
// init & undock window
var popup_cell = _this.dhxLayout.cells("c");
popup_cell.undock(0,0,800,600);
var popup_window = _this.dhxLayout.dhxWins.window("c");
popup_window.button("minmax1").hide();
popup_window.setText(" ");
// things to do when window is opened
popup_cell.attachEvent("onUnDock", alert("undocked"));
// assigning .dock() to another button, neither work
popup_window.button("park").attachEvent("onClick", function(popup_window){_this.dhxLayout.cells("c").dock();});
// popup_window.button("park").attachEvent("onClick", function(popup_window){popup_cell.dock()});
}
The traceback takes me to c=this.layout.dhxWins.window(this.conf.name);c.close(); so I am guessing that c is somehow undefined? Is there an argument/parameter I am supposed to be passing in the .dock(foo)? The API shows no examples with it.
Any help is greatly appreciated!
I missed out on this: http://forum.dhtmlx.com/viewtopic.php?f=5&t=37052
And followed it to change the offending line of:
c=this.layout.dhxWins.window(this.conf.name);c.close();
(in dhtmlx.js)
to
c=g.dhxWins.window(this.conf.name);c.close();
and the problem is fixed!

Categories