This issue was fixed in SAP Lumira 1.15 so these steps are no longer needed.
Just a quick post before I go for my vacation in case you also run into this known issue/message when using your extension inside SAP Lumira 1.14.
I was using the sample code that gets generated by the vizPacker, the only thing I had changed was the extension ID and plot area ID like we did with the Hello World extension for SAP Lumira.
The extension worked fine inside of the vizPacker preview and externally in Google Chrome:
But when I installed my extension into SAP Lumira and then switched to it the following message was displayed:
Failed to create chart: TypeError: Cannot read property ‘0’ of undefined
What caused it?
The generated render code call to _util.toFlattenTable throws an exception when SAP Lumira does not pass in any data to display.
We avoided this issue with Hello World extension because we replaced all of the render code with our own.
These are the steps I went through to find out what was wrong:
- I closed down SAP Lumira
- Then I followed the SAP Lumira SDK Getting Started Guide instructions to enable debug mode
- I then started SAP Lumira and went into debug mode (again referring to the guide) so I could add a break point to the top of my render function
- I then switched to my extension which stopped at the breakpoint so I could step through and see what was wrong
- As I stepped through the code I saw the error was coming from inside the generated code:
var fdata = _util.toFlattenTable(data);
You apply this workaround every time the render function is generated by the vizPacker.
You can workaround the issues in the generated render code to:
- Catch the error from var fdata = _util.toFlattenTable, suppress it, and return
This call is commonly used to turn the SAP Lumira cross table data format into a simple JSON array we can work with in our extension
- Fix the sample chart code to return when dimensions are passed in but no measures
Here marked in red are the changes I made to the render code:
I then packed the extension, copied it into SAP Lumira, restarted SAP Lumira, imported the vizPacker sample CSV file and then tested again and this time it worked:
The SAP Lumira development team is fixing this issue (which may differ to the way I applied my workaround) and it should be part of the next SAP Lumira update in 2014.
Happy coding and Happy Holidays everybody!