Highcharts react native wrapper, fork from HighCharts.
[x] iOS [x] Android [ ] Web
- expo
>=43.0.3
, we are using theAsset
andFileSystem
packages - react-native-webview
yarn add react-native-webview
yarn add react-native-highcharts-webview
- Run this script to install and config automatically or follow the setup guide of Expo
npx install-expo-modules@latest
- Add permissions to Android manifest
<!-- Added permissions -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
const { getDefaultConfig } = require('metro-config'); // <-- add this
module.exports = (async () => {
//<------add this
const {
resolver: { sourceExts, assetExts },
} = await getDefaultConfig();
//</add this-------->
return {
resolver: {
assetExts: [...assetExts, 'hcscript'], ///<------add this
},
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
},
};
})();
yarn example ios
yarn example android
import React from 'react';
import { StyleSheet, View } from 'react-native';
import HighchartsReactNative from 'react-native-highcharts-webview';
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
chartOptions: {
series: [
{
data: [1, 2, 3],
},
],
},
};
}
render() {
return (
<View style={styles.container}>
<HighchartsReactNative
styles={styles.container}
options={this.state.chartOptions}
/>
</View>
);
}
}
Available properties:
<HighchartsReact
styles={styles}
webviewStyles={webviewStyles}
options={this.state.chartOptions}
modules={modules}
callback={chartCallback}
useSSL={true}
useCDN={true} // or string 'mydomain.com/highchartsfiles/'
data={'Data to be stored as global variable in Webview'}
onMessage={message => this.onMessage(message)}
loader={ true }
devPort={'xxx.xxx.xxx.xxx:xxxxx'} // i.e 192.168.0.1:12345
setOptions={highchartsGlobalOptions}
/>
Parameter | Type | Required | Description |
---|---|---|---|
styles |
Object | no | You can style your container using JavaScript like in the regular react and react native. |
options |
Object | yes | Highcharts chart configuration object. Please refer to the Highcharts API documentation. This option is required. |
modules |
Array | no | List of modules which should be added to Highcharts. I.e when you would like to setup solidgauge series which requires highcharts-more and solid-gauge files, you should declare array: const modules = ['solid-gauge'] |
callback |
Function | no | A callback function for the created chart. First argument for the function will hold the created chart . Default this in the function points to the chart . This option is optional. |
useCDN |
Boolean | no | Set the flag as true, if you would like to load files (i.e highcharts.js) from CDN instead of local file system. You can declare an url to your domain (i.e mydomain.com/highchartsfiles/ ) |
useSSL |
Boolean | no | Set the flag as true, if you would like to load files (i.e highcharts.js) by SSL. (The useCDN flag is mandatory). |
data |
any | no | Data to be stored as global variable in Webview. |
onMessage |
Function | no | Global communication between Webview and App. The function takes the message as the first argument. |
loader |
Boolean | no | Set the flag to true , if you would like to show loader while chart is loading. |
webviewStyles |
Object | no | You can style your webview using JavaScript object structured like in the regular React and React Native apps. |
webviewProps |
Object | no | You can pass webview props. |
setOptions |
Object | no | Options which are set for Highcharts through Highcharts.setOptions() method. Usually it is used to set the global and lang options. For more details please visit Highcharts documentation, and API. |
devPort |
String | no | When using EXPO in DEV mode, you may declare address and port to actually load the html file in Android. You cannot use built-in file:/// when using Expo,because the Android and iOS folders don’t exist yet. When it’s in STAGING or PROD skip this option and use default the file:///android_asset path. |
See the License file
- Init forking from official package
- modify folder structure and dependencies
- update highcharts files to version
9.3.1