High**Resolved** Charts update 14.0 SP3 -> 14.1 SP2 breaks beforeCreateChart code at .data
We have some code working perfectly in our 14.0 SP3 application using HighCharts beforeCreateChart API, but in 14.1 SP2 the chart never renders and we get the following error in the console:
Uncaught TypeError: Cannot read properties of undefined (reading 'data')
This occurs in both places where we call .data in our code (lines 6 and 13) and I can't figure out how to troubleshoot this issue. Any ideas of what we would need to do to keep this code working??
var verticalBarChartContainer = Y.one('#Chart1');
var SeriesData = [];
verticalBarChartContainer.on('beforeCreateChart', function(e) {
if (e.options.series == null)
return;
if (e.options.series[0].data === undefined) {
console.log('no data');
return;
}
else {
console.log('data');
}
SeriesData = Object.entries(e.options.series[0].data.map(x=>{ return { 'name': x.qt[0], categories: x.qt[1] };}).reduce(function (r, a) {
r[a.name] = r[a.name] || [];
r[a.name].push(a.categories);
return r;
}, Object.create(null))).map(function (e) {
return {name: e[0], categories: e[1]};
});
e.options.xAxis.forEach(xaxis=>{
xaxis.categories= SeriesData;
xaxis.labels.groupedOptions = [{
rotation: -35,
y: 8,
style: { color: '@Shared.GroupedCategoryLabelColor~', fontSize: '12px'}
}];
});
});
Regards,
Johnny
0
-
The resolution that I've received from Logi Support for this issue is to add another check to my first if statement.
Old code:
var verticalBarChartContainer = Y.one('#Chart1');
var SeriesData = [];
verticalBarChartContainer.on('beforeCreateChart', function(e) {
if (e.options.series == null)
return;New code:
var verticalBarChartContainer = Y.one('#Chart1');
var SeriesData = [];
verticalBarChartContainer.on('beforeCreateChart', function(e) {
if (e.options.series == null || e.options.series.length == 0)
return;0
Please sign in to leave a comment.
Comments
1 comment