I have struggling while using xlsx-chart… I'm using xlsx-chart to create a chart in Excel, but when I add multiple charts in opts I have an issue like this below
TypeError: Cannot set properties of undefined (setting 'c:ser')
at /node_modules/xlsx-chart/chart/base.js:508:83
at Function.each (/node_modules/underscore/underscore-node-f-pre.js:1321:7)
this is my opts object
const xlsxChart = new XLSXChart();
const opts = {
charts: [
{
chart: 'line',
titles: ['inside', 'outside'],
fields: [
'29-06-2022, 14:15:01',
'29-06-2022, 14:30:10',
],
data: {
outside: {
'29-06-2022, 14:15:01': 44,
'29-06-2022, 14:30:10': 42,
},
inside: {
'29-06-2022, 14:15:01': 37,
'29-06-2022, 14:30:10': 35,
},
},
chartTitle: 'Temperature',
},
{
chart: 'column',
titles: ['inside', 'outside'],
fields: [
'29-06-2022, 14:15:01',
'29-06-2022, 14:30:10',
],
data: {
outside: {
'29-06-2022, 14:15:01': 66,
'29-06-2022, 14:30:10': 67,
},
inside: {
'29-06-2022, 14:15:01': 91,
'29-06-2022, 14:30:10': 92,
},
},
chartTitle: 'humidity',
},
],
};
Can anyone please help me
I've been found a pull request can resolve this problem in this commit
you just add this block code below into base.js file in package
else if (chart == "line") {
o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:lineChart"] = o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:lineChart"] || o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:barChart"];
delete o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:barChart"];
delete o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:lineChart"]["c:barDir"];
o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:lineChart"]["c:grouping"] = { $: { val: 'standard' } };
if (me.tplName == "charts") {
o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:lineChart"][1]["c:ser"] = ser;
} else {
o ["c:chartSpace"]["c:chart"]["c:plotArea"]["c:lineChart"]["c:ser"] = ser;
};
}
into callback _.each (ser, function (ser, chart) {