Highcharts nodeName of undefined
-
24-05-2021 - |
質問
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.