AnyChart widget error :

0
I am getting an error while using AnyChart widget. This error is intermittent. i.e. occurring randomly. Some times it works perfect, but sometimes on refreshing the data input to this widget, following error is occurring. i.map is not a function TypeError: i.map is not a function at t.renderChart (https://127.0.0.1:3000/widgets/com/mendix/widget/custom/AnyChart/AnyChart.js?636982915607333023:17:88882) at t.componentDidUpdate (https://127.0.0.1:3000/widgets/com/mendix/widget/custom/AnyChart/AnyChart.js?636982915607333023:17:88154) at Ma (https://127.0.0.1:3000/mxclientsystem/mxui/mxui.js?636982915607333023:61:89511) at Ra (https://127.0.0.1:3000/mxclientsystem/mxui/mxui.js?636982915607333023:61:85168) at Na (https://127.0.0.1:3000/mxclientsystem/mxui/mxui.js?636982915607333023:61:84513) at Sa (https://127.0.0.1:3000/mxclientsystem/mxui/mxui.js?636982915607333023:61:83534) at Zo (https://127.0.0.1:3000/mxclientsystem/mxui/mxui.js?636982915607333023:61:82437) at Object.enqueueSetState (https://127.0.0.1:3000/mxclientsystem/mxui/mxui.js?636982915607333023:61:47365) at i._.setState (https://127.0.0.1:3000/mxclientsystem/mxui/mxui.js?636982915607333023:70:1663) at i.onStateChange (https://127.0.0.1:3000/widgets/com/mendix/widget/custom/AnyChart/AnyChart.js?636982915607333023:17:56482)   Any idea what is going wrong here ?
asked
2 answers
0

I manged to solve this issue. 

Use case : I call a some microflow on button click and microflow used to get the data in Json format. This data is saved as an attribute of some entity – say ‘data’ attribute of ‘ChartJson’ entity.

Any chart (Bar chart in my case) has source attribute = ‘data’ attribute of ‘ChartJson’ entity. Each time this attribute is updated, chart will get updated on UI.  

Here issue was if ‘data’ is blank i.e. empty for some condition, and saved as blank in entity, I used ot see an error at the place of chart that There is some error in widget, please update the widget. In browser console error was being shown as ‘i.map is not a function TypeError: i.map is not a function ’.

Solution:

  1. Create a persistable entity ‘ChartJson’ in domain model.
  2. Add attribute ‘data’ in it.
  3. Create a microflow and set up it as a startup microflow
  4. In this microflow , Delete all objects of this entity, and create new object with some default value for attribute ‘data’. Note that default value should be ‘[]’  . Empty array means no data for json. This step ensure that an each launch of app, previous data will be deleted and only one object of entity exists.
  5.  Now in the main microflow where you refresh the data on button click or some other activity, get the new json data, retrive the first object from list of objects of entity, update this objects’s data attribute with this json data you get.
  6. In Anychart configuration, set source attribute to data attribute of ChartJson entity.

 

Most Important:  If for some condition, there is no data available e.g. future date period, data attribute should be saved as  ‘[]’ as mentioned in step #4 above.

answered
0

Dear Rushikesh

We just release version 1.2.1 of the Any Chart in the app store. https://appstore.home.mendix.com/link/app/106517/

We have fixes an issue similar to the one you describe. It will now ignore the rendering when the data is not array. 

Please let me know if this solves your problem.

Cheers, Andries

answered