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

Formatter function dependencies not included #79

Open
VitaliiK91 opened this issue May 21, 2020 · 9 comments
Open

Formatter function dependencies not included #79

VitaliiK91 opened this issue May 21, 2020 · 9 comments

Comments

@VitaliiK91
Copy link
Contributor

VitaliiK91 commented May 21, 2020

When function passed to formatter calls other functions (i.e. lodash or any other library) or functions defined outside of the scope of formatter function, it throws Can't find variable exception. This seems to be due to outer functions or libraries don't make it to the WebView where charts are rendered. How can we bypass it?
Example of not working formatter funtion:

const sum = (a, b) => a + b;

function formatter() {
  return sum(this.value, 1);
}

will throw Can't find variable sum

@sebastianbochan
Copy link
Contributor

The problem here is that we use webview and we inject the javascript there. When you declare a variable in the app, the reference does not exist.

Im thinking how it should work, because the webview is really limited.

@VitaliiK91
Copy link
Contributor Author

@sebastianbochan Yes, this is definitely why it is happening. The only solutions I see is to declare all the variables within the formatter function body or inject all dependencies in the web view, although both solutions sound suboptimal. Do you have any suggestions? Thanks

@sebastianbochan
Copy link
Contributor

Do you mean to add variables + values from RN to webview by injectJavascript? It sounds really strange, especially that RN variables can change, but communication between layers is limited. Correct me if Im wrong.

@VitaliiK91
Copy link
Contributor Author

@sebastianbochan For example I have a system wide value formatting engine, I already use to format values and input on RN side, and I would like to use same engine in chart formatters functions. The only way I found so far is to copy over and inject the entire engine with all dependencies in the web view.

@sebastianbochan
Copy link
Contributor

@VitaliiK91,
Is it possible to paste a piece of example of it here? I would like to check this formatters.

@chandlervdw
Copy link

It feels like the issue resides in this line: https://github.com/highcharts/highcharts-react-native/blob/master/dist/src/HighchartsReactNative.js#L98

I'm very confused as to why passing a string works but passing an object doesn't. I've tried several options – see @sebastianbochan's reference to my issue above.

@chandlervdw
Copy link

@VitaliiK91 ping ping. Can you help this keep moving forward?

@gmonte
Copy link

gmonte commented Dec 29, 2020

any solution?

@aditya1711
Copy link

Is there a way to be able to access the Chart Object in these functions?

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

No branches or pull requests

5 participants