surveyjs / survey-analytics

Customizable JavaScript library to create interactive survey data dashboards and facilitate survey results analysis for your end-users.
https://surveyjs.io/dashboard/examples/plain-data
Other
98 stars 49 forks source link

Error when adding import survey-analytics #16

Closed Hrommi closed 4 years ago

Hrommi commented 4 years ago

I only add import * as SurveyAnalytics from "survey-analytics" in my react component. I get error after npm start:

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

React version 16.12.0. NPM version 6.9.0 Survey-analytics version 1.1.24.

What is the best way to use "survey-analytics" in React project?

tsv2013 commented 4 years ago

Survey-analytics is in beta now. It doesn't demonstrated in our demos for while. We can add survey-analytics in our ReactJS boilerplate repo - https://github.com/surveyjs/surveyjs_react_quickstart and check it. But it will take some time.

From the other hand it would be nice if you provide us with a minimal sample to reproduce the issue

Hrommi commented 4 years ago

I created simple demo survey-analytics-react.zip

tsv2013 commented 4 years ago

The "out of memory" issue is related to the "create-react-app" toolkit.

I fount ""react-scripts" FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory" and got the corresponding issue https://github.com/facebook/create-react-app/issues/4436 in the create-react-app repository

I've added another start script to the package.json file:

    "start1": "node --max-old-space-size=4000 node_modules/react-scripts/scripts/start.js",

and command "npm run start1" worked ok for me

tsv2013 commented 4 years ago

After that I've got another issue - "TypeError: Cannot read property 'frameworkUsing' of undefined" - and right now investigating it

tsv2013 commented 4 years ago

The "TypeError: Cannot read property 'frameworkUsing' of undefined" error is caused by wrong data normalization code.

You need to use the

    const normalizeData = data.map(function(item) {
      questions.forEach(function(q) {
        if (item[q.name] === undefined) {
          item[q.name] = "";
        }
      });
      return item;
    });

code instead of

    const normalizeData = data.map(item => {
      questions.forEach(q => {
        if (item[q.name] === undefined) {
          item[q.name] = "";
        }
        return item;
      });
    });
Hrommi commented 4 years ago
"start1": "node --max-old-space-size=4000 node_modules/react-scripts/scripts/start.js"

It's works for me. Thank you.