Skip to content

Commit 72ffe15

Browse files
committed
readme
1 parent d803b78 commit 72ffe15

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ Margin for the title and legend will be subtracted from the final width and heig
8888
8989
If you have custom functions within your uPlot `options`, have them defined elsewhere; do not use inline functions. Then to make use of them on iOS and Android version, wrap all functions into a single string to pass them to the ChartUPlot's `injectedJavaScript` prop.
9090
91+
Any dependencies in each function must be:
92+
93+
- One of the other functions passed to the `injectedJavaScript` prop.
94+
- Anything globally available within a WebView.
95+
- A function from the uPlot library that is available in the webview.
96+
9197
```javascript
9298
// for web version of uPlot
9399
function format_value(self, ticks) {
@@ -122,14 +128,6 @@ const options = {
122128
<ChartUPlot options={options} injectedJavaScript={injectedJavaScript} />;
123129
```
124130
125-
#### Important!
126-
127-
Any dependencies in each function must be:
128-
129-
- One of the other functions passed to the `injectedJavaScript` prop.
130-
- Anything globally available within a WebView.
131-
- A function from the uPlot library that is available in the webview.
132-
133131
#### Why is it done this way?
134132
135133
There may be a better way to do this, so please open an issue if you have a suggestion. Passing javascript functions to the webview is tricky, so the current solution is to pass them as strings into WebView's `injectedJavaScript` prop. This means if you're also supporting web, you need to duplicate each function to support both web and iOS/Android. You could argue that you can try something like, `function.toString()`, but in iOS build `toString()` does not actually return the javascript source code, so it won't work.

0 commit comments

Comments
 (0)