You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-3Lines changed: 53 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -76,14 +76,64 @@ The `ref` exposes the following methods:
76
76
- `setSize(width, height)`: Set the size of the chart.
77
77
- `destroy()`: Destroy the chart instance.
78
78
79
-
### Plot dimensions
79
+
### Dimensions
80
80
81
-
You can set the width and height either through the uPlot `options` or by passing a `style` prop to the `ChartUPlot` component. If you set both, the uPlot `options` will take precedence.
81
+
You can set the width and height either through the uPlot `options` or by passing a `style` prop to the `ChartUPlot` component. If you set both, the uPlot `options` will take precedence. Any changes to the width and height in the `options` will not automatically update the chart size.
82
82
83
-
### Plot margins
83
+
### Margins
84
84
85
85
Margin for the title and legend will be subtracted from the final width and height for the chart. You can control the margin via the `margin: { title?: number; legend?: number }` prop.
86
86
87
+
### Functions
88
+
89
+
The uPlot options can include custom functions for things like drawing and formatting tick labels. You'll need to duplicate each function: one as a normal javascript function and another as a string for the webview. Pass any functions to the `functions` prop of `ChartUPlot`, which will be injected into the webview and can be used in the uPlot options.
- One of the other functions passed to the `functions` prop.
130
+
- A global variable that is defined in the webview.
131
+
- A function from the uPlot library that is available in the webview.
132
+
133
+
#### Why is it done this way?
134
+
135
+
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. If you didn't do this and instead tried doing something like `function.toString()` in an iOS build, it does not return the javascript source code.
136
+
87
137
## Demo app
88
138
89
139
The `demo` folder contains an example Expo app that demonstrates how to use the library. You can run it by cloning the repository and running:
0 commit comments