Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart Not Rendering on iOS and Android #4

Closed
userkpkpuser opened this issue May 29, 2019 · 66 comments
Closed

Chart Not Rendering on iOS and Android #4

userkpkpuser opened this issue May 29, 2019 · 66 comments

Comments

@userkpkpuser
Copy link

Hi Team, when we tried to run the sample example provided in Readme file, but the charts are not rendering and there is no error also.

@sebastianbochan
Copy link
Contributor

Hi @userkpkpuser,
Please let me know if you use the newest expo / npm etc ?
Is it blank screen or its not builded at all?

@ssuchanowski
Copy link

When running demo via expo it works but doesn't seem to be showing anything when run normally.

I see also a blank screen, just a white background. Tested with newest npm. Will investigate more.

@ssuchanowski
Copy link

And for me running it on Android results in:

(this is the blank view that I see on iOS)
Screenshot 2019-06-11 at 15 32 40

@ssuchanowski
Copy link

After debugging I see that injectedJavaScript is

"\n            var modules = [],\n                moduleCounter = modules.length,\n                hcScript;\n\n            hcScript = document.createElement('script');\n\n            hcScript.setAttribute('src', '../highcharts-files/highcharts.js');\n            hcScript.onload = function() {\n\n                if (moduleCounter === 0) {\n                    \n                Highcharts.chart(\n                'container',\n                {\"series\":[{\"data\":[1,3,2,4]}]},\n                undefined\n           ..."

So I think the path to the lib might be an issue here - didn't check it though.

@masiamj
Copy link

masiamj commented Jun 19, 2019

Same issue here as well. Let us know about any updates! Thanks!

@loncardom
Copy link

I think this is an issue with WebView, the HighchartsReactNative.js file imports WebView from 'react-native' instead of from 'react-native-webview'. If you change it, the index.html file will render but it's just a blank page (you can check if it's actually rendering by putting an alert in a script tag and checking if it pops up).

This is all on Android - very excited about using Highcharts with React Native!

@sebastianbochan
Copy link
Contributor

sebastianbochan commented Jul 2, 2019

Hi,
Please let me know which version of xCode (os) and Android studio, do you have?

@ssuchanowski
Copy link

ssuchanowski commented Jul 2, 2019

XCode 10.1 and 10.2.1
Android Studio 3.4.1

@sebastianbochan
Copy link
Contributor

sebastianbochan commented Jul 3, 2019

I did steps:

  1. Clone repo of wrapper
  2. run yarn
  3. run in expo, all works properly
  4. call expo eject to have correct ios and android native apps
  5. run the project (ios) in xCode and then in simulator

As a result all worked properly (withtout errors which you experienced).

Zrzut ekranu 2019-07-1 o 17 08 41

Please correct me if I miss something or did in differant way than you.

@ssuchanowski
Copy link

Try non expo project

@sebastianbochan
Copy link
Contributor

Hi @ssuchanowski,
Are you able to send me your really simple / basic project to reproduce?

@SaeedZhiany
Copy link

@ssuchanowski
I'm facing this problem too. I create a simple Github repo to reproduce the problem

@sebastianbochan
Copy link
Contributor

Hi @SaeedZhiany,
Thank you for demo, will test as soon as possible.

@ssuchanowski
Copy link

How is this going?

@Seshpenguin
Copy link

Seshpenguin commented Aug 16, 2019

I'm having this issue also with Expo 34, it seems to be broken since Expo 32 (33+ needs to use the WebView exported from 'react-native-webview' community package).

@athenawisdoms
Copy link

Tried using both Expo SDK 33 and 34 with "@highcharts/highcharts-react-native": "^1.0.0", getting an error

Unable to resolve module @highcharts/HighChartsReactNative from /Users/x/src/foo/index.js: Module @highcharts/HighChartsReactNative does not exist in the Haste module map.

@Seshpenguin Is there a solution to get this package working with Expo 33+ using react-native-webview?

@ssuchanowski
Copy link

@athenawisdoms that's probably just a caching issue, google this part does not exist in the Haste module map. and you will find a solution quickly.

@ssuchanowski
Copy link

@sebastianbochan any update here?

@sebastianbochan
Copy link
Contributor

Hi @ssuchanowski,
Im prepared the beta-version of wrapper on separate branch (beta-webview). If you will be able to test it, I would be grateful for any feedback.

Related topic:

@ms042087
Copy link

ms042087 commented Sep 7, 2019

Mine showing a blank page. Any update on this?

@sebastianbochan
Copy link
Contributor

sebastianbochan commented Sep 9, 2019

@ms042087,
Let me know which version of android you have

@ms042087
Copy link

@sebastianbochan Android 9.0, compiler compileSdkVersion = 28

Finally get it done.

Blank page or page showing html text are basically due to wrong path or Android debug mode problem. I tried to put a website URL into source, it displayed normally. Therefore, the WebView module should work fine.

Main Problem:
I think it is not possible to put local html file into WebView source in Android debug mode.
Also, the source for WebView uses require() which I think it is for IOS. uri:... should be used for Android. Using require() gives blank page and using uri:... gives html text in Android virtual device.

My Solution:

  1. Change the source to
    source = {(Platform.OS == 'ios') ? require('../highcharts-layout/index.html') : { uri: 'file:///android_asset/highcharts-layout/index.html' }}

This changes the source path of the local files based on the platforms.
Remember to import 'Platform' from 'react native'

  1. Put the files (i.e. Folder: highcharts-layout and highcharts-files) to android/app/src/main/assets and /ios

  2. Use release mode instead of debug mode
    i.e. run react-native run-android --variant=release

Hope it helps.

@sebastianbochan
Copy link
Contributor

sebastianbochan commented Sep 11, 2019

Hi @userkpkpuser,
Thank you for the suggestions. When I tested the solution (point 1) I had a problem (blank page) in old Android 6.

Its strickly related with webview problems like:

At this moment, I think that the best solution is adding platform recognizing (like you suggested) + add an option of load files prom CDN instead of local files system.

Points 2 and 3 will be only in docs (for user adaption).

Does it make sense?

@ms042087
Copy link

@sebastianbochan
yes, it makes sense to load file from CDN instead of local files system.

I retested my solution and it works for me.
Point 1 + 2 should be done together. Have you put the files to android/app/src/main/assets?
If not works, I think that maybe my solution is not suitable for old version of Android.

@sebastianbochan
Copy link
Contributor

Hi @ms042087,
Thank you for really big feedback and advices. I committed your suggestions (and some for iOS) on my beta-webview branch.

Will be really grateful if you will be able to test it too.

ps. if all will work properly I will add CDN and modules options.

@ms042087
Copy link

@sebastianbochan
yes it works for me

@sebastianbochan
Copy link
Contributor

Thank you for feedback, Im starting to add CDN support and multiple modules.

@athenawisdoms
Copy link

athenawisdoms commented Oct 5, 2019

@sebastianbochan

What is the proper way to install the beta-webview branch in an Expo project?

Tried npm install --save highcharts/highcharts-react-native#beta-webview but getting the error Duplicate module name: react-native after running expo start:

node:43440) UnhandledPromiseRejectionWarning: Error: jest-haste-map: Haste module naming collision:
  Duplicate module name: react-native
  Paths: /Users/x/foo/node_modules/react-native/package.json collides with /Users/x/foo/node_modules/highcharts-react-native/node_modules/react-native/package.json

package.json shows react-native on https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz" and expo v34.0.4.

@sebastianbochan
Copy link
Contributor

@BabishanM,
Unfortunately I was not able to reproduce the problem, which android do you have?

@athenawisdoms
I did not publish it in npm, so at this moment I recommend to download beta-webview, and use package by import HighchartsReactNative from path/to/the/beta-webview

@sebastianbochan
Copy link
Contributor

Regarding to update, in the wrapper I used webkit.postmessage and event to cache it. At this moment it was removed from webview and is still developed / reorganized.

Ref:

@IgorUsoltsev
Copy link

Had the issue with Expo + RN High Charts as well.

And the case was ONLY with published project.

The reason was really funny enough.

https://github.com/highcharts/highcharts-react-native/blob/beta-webview/dist/src/HighchartsReactNative.js#L12 - here guys you use HTTP. As I suppose in the latest versions of iOS Apple could have blocked non secure connections in iFrames (i.e. WebViews). So I just changed it to HTTPS:
const cdnPath = 'https://code.highcharts.com/'; and it worked!

Please give some time to Expo so cache could go on. Hope that will help you!

@sebastianbochan
Copy link
Contributor

Thank you for the feedback!

@sebastianbochan
Copy link
Contributor

The new version (2.0.2) has been already released.

Im closing the ticket, but please reopen if any issues will come again.

@bestjsguru
Copy link

bestjsguru commented Nov 27, 2019

Hi @sebastianbochan
I love the react native and I am very interested in your highchart component.
So I am going to use it on my react native cli project but it shows the empty background
react-native: 0.61
react: 16.9
npm: 6.12.1
node: 12.13.1
@highchart/highcharts-react-native: 2.0.2

I tried to use react-native 0.59 for this component but had the same problem
used 1.0.0 version on RN 0.59

@sebastianbochan
Copy link
Contributor

@bestjsguru did you run this in Android or iOS? Which version of OS?

@horstleung
Copy link
Contributor

@sebastianbochan
I've init a new rn project with the following package.json

  "name": "highcharts",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@highcharts/highcharts-react-native": "^2.0.2",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-webview": "^7.5.2"
  },
  "devDependencies": {
    "@babel/core": "^7.7.4",
    "@babel/runtime": "^7.7.4",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.7.2",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.57.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Then I receive some error messages in terminal:

Error: 'node_modules/@highcharts/highcharts-react-native/highcharts-files/highcharts.js' cannot be loaded as its extension is not registered in assetExts

After that, I added 'css', 'js to metro as following:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

const { getDefaultConfig } = require('metro-config')


module.exports = (async () => {
  const {
      resolver: { assetExts },
  } = await getDefaultConfig()
  console.log(assetExts)
  return {
      transformer: {
          getTransformOptions: async () => ({
              transform: {
                  experimentalImportSupport: false,
                  inlineRequires: false,
              },
          }),
      },
      resolver: {
          assetExts: [...assetExts, 'css', 'js'],
      },
  }
})()

Finally I got this:
image

Am I missing any installation step?

@mrinal-roy
Copy link

I am getting this error:
**Encountered an error loading page {"canGoBack": false, "canGoForward": false, "code": -1, "description": "net::ERR_FILE_NOT_FOUND", "loading": false, "target": 18623, "title": "", "url": "file:///android_asset/highcharts-layout/index.html"}**

I am running RN 0.61.5 with android emulator. Please tell me which files to add and where?

@oillada
Copy link

oillada commented Feb 19, 2020

Same issues here, any help?

@georgeCts
Copy link

I am getting this error:
**Encountered an error loading page {"canGoBack": false, "canGoForward": false, "code": -1, "description": "net::ERR_FILE_NOT_FOUND", "loading": false, "target": 18623, "title": "", "url": "file:///android_asset/highcharts-layout/index.html"}**

I am running RN 0.61.5 with android emulator. Please tell me which files to add and where?

Same issue :(

@nerami
Copy link

nerami commented Feb 19, 2020

@sebastianbochan Android 9.0, compiler compileSdkVersion = 28

Finally get it done.

Blank page or page showing html text are basically due to wrong path or Android debug mode problem. I tried to put a website URL into source, it displayed normally. Therefore, the WebView module should work fine.

Main Problem:
I think it is not possible to put local html file into WebView source in Android debug mode.
Also, the source for WebView uses require() which I think it is for IOS. uri:... should be used for Android. Using require() gives blank page and using uri:... gives html text in Android virtual device.

My Solution:

  1. Change the source to
    source = {(Platform.OS == 'ios') ? require('../highcharts-layout/index.html') : { uri: 'file:///android_asset/highcharts-layout/index.html' }}

This changes the source path of the local files based on the platforms.
Remember to import 'Platform' from 'react native'

  1. Put the files (i.e. Folder: highcharts-layout and highcharts-files) to android/app/src/main/assets and /ios
  2. Use release mode instead of debug mode
    i.e. run react-native run-android --variant=release

Hope it helps.

This worked for me! Thanks!

@mustapha-khan
Copy link

I am getting this error:
**Encountered an error loading page {"canGoBack": false, "canGoForward": false, "code": -1, "description": "net::ERR_FILE_NOT_FOUND", "loading": false, "target": 18623, "title": "", "url": "file:///android_asset/highcharts-layout/index.html"}**
I am running RN 0.61.5 with android emulator. Please tell me which files to add and where?

Same issue :(

i am having similar issue on using highchart in EXPO application .
getting the error on running app on emulator or physical device : ERR_FILE_NOT_FOUND

image

the issue seems to be in the source provided to webView in highcharts react native wrapper . i.e:
source={highchartsLayout}

I solved it by using expo-asset-utils to convert my required file into asset in componentdidmount() and used the uri of this asset as source of webView so that my modified HighchartsReactNative.js file looks like :

async componentDidMount() {
try {
const asset = await AssetUtils.resolveAsync(require('../highcharts-layout/index.html'));
this.setState({ asset });
console.log("=- -= CHEK ASSET -= = ", asset)
} catch (error) {
console.log({ error });
}
Dimensions.addEventListener('change', this.onRotate);
}

and in webview using source as :

source={{uri:this.state.asset.localUri}}

using the uri of asset didn't work for me hence using loacalUri

try this and it might help you

@sebastianbochan
Copy link
Contributor

sebastianbochan commented Mar 13, 2020

Thank you for the suggestion.
Will test it.

@sebastianbochan
Copy link
Contributor

@mustapha-khan could you share your simplified working project? When I run the Expo SDK 64, was not able to run it properly in Android.

@horstleung
Copy link
Contributor

@sebastianbochan
I've init a new rn project with the following package.json

  "name": "highcharts",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "@highcharts/highcharts-react-native": "^2.0.2",
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-webview": "^7.5.2"
  },
  "devDependencies": {
    "@babel/core": "^7.7.4",
    "@babel/runtime": "^7.7.4",
    "@react-native-community/eslint-config": "^0.0.5",
    "babel-jest": "^24.9.0",
    "eslint": "^6.7.2",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "^0.57.0",
    "react-test-renderer": "16.9.0"
  },
  "jest": {
    "preset": "react-native"
  }
}

Then I receive some error messages in terminal:

Error: 'node_modules/@highcharts/highcharts-react-native/highcharts-files/highcharts.js' cannot be loaded as its extension is not registered in assetExts

After that, I added 'css', 'js to metro as following:

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

const { getDefaultConfig } = require('metro-config')


module.exports = (async () => {
  const {
      resolver: { assetExts },
  } = await getDefaultConfig()
  console.log(assetExts)
  return {
      transformer: {
          getTransformOptions: async () => ({
              transform: {
                  experimentalImportSupport: false,
                  inlineRequires: false,
              },
          }),
      },
      resolver: {
          assetExts: [...assetExts, 'css', 'js'],
      },
  }
})()

Finally I got this:
image

Am I missing any installation step?

I get it work after changing the metro config file into

module.exports = (async () => {
  const {
      resolver: { sourceExts, assetExts },
  } = await getDefaultConfig()
  return {
      transformer: {
          getTransformOptions: async () => ({
              transform: {
                  experimentalImportSupport: false,
                  inlineRequires: false,
              },
          }),
      },
      resolver: {
        sourceExts,
        assetExts: [...assetExts, 'css'],
      },
  }
})()

@sebastianbochan
Copy link
Contributor

Big thanks for the hint. Will share it with our users to be ensure that it worked.

@ChenRaul
Copy link

ChenRaul commented May 20, 2020

@sebastianbochan Except for yours Highcharts, actually, that's what you're talking about with using react-native-webview,when the html file import other JS files which will hint xxxx.js cannot be loaded as its extension is not registered in assetExts.if I add ‘js’ into assetExts while it didn't work.
So do you have any other solutions? thanks.

Environment
OS: iPhone
OS version:
"react": "16.11.0",
"react-native": "0.62.2",
react-native-webview : 8.0.0;

@samimhakimi
Copy link

platforms

How to implement this could you please explain it?

@sebastianbochan
Copy link
Contributor

We are wokring on that and debugging the problem. Can be related with new versions of modules.

Thankfully, we are able to reproduce the problem.

I will inform you about progress, when find a reason of issue.

@walidbezzaoui
Copy link

any progress on this ?

@horstleung
Copy link
Contributor

any progress on this ?

3.0 fixed this issue. But 3.0 got another problem with iOS, here is the [hotfix].(#104 (comment)).

@ManelGonzalez-ops
Copy link

There's not even a working example on the internet with this thing working... hilarious

@DamanSoftRadixx
Copy link

If any one try to Implement HIChartView in flutter with native code with the help of ( implement class with PlatformView) in flutter . Then make sure during make instance of HIChartView give them layout and background color to HIChartView if background color missing then view not rendered and it will not showing error in log .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests