[英]How to use Highcharts in React-Native using webview?
I want to render a chart inside a webview in react-Native.我想在 react-Native 的 webview 中呈现图表。 I used highcharts npm package.
我使用了 highcharts npm 包。
I defined a Webview something like this我定义了一个像这样的 Webview
<WebView ref='webview' />
In componentDidMount, I wrote在 componentDidMount 中,我写了
componentDidMount(){
var chart = Highcharts.chart(this.refs.webview,{
series: [{
data: [1, 3, 2, 4]
}],
// ... more options - see http://api.highcharts.com/highcharts
});
}
But it is throwing error.但它正在抛出错误。
Could anyone please point out what I am doing wrong here.谁能指出我在这里做错了什么。 Thanks
谢谢
I'd recommend using react-native-highcharts
or highcharts-react-native
npm packages.我建议使用
react-native-highcharts
或highcharts-react-native
npm 包。 It does this for you with a ChartView
component in react-native-highcharts and a HigchchartsReactNative
component in highcharts-react-native
.它使用 react-native-highcharts 中的
HigchchartsReactNative
组件和highcharts-react-native
中的ChartView
组件为您执行此操作。 I think you are writing the code for react-highcharts
and attempting to put it in a WebView
.我认为您正在编写
react-highcharts
的代码并试图将其放入WebView
中。 I don't recommend this.我不推荐这个。 Here are a few links
这里有几个链接
https://www.highcharts.com/blog/post/creating-mobile-charts-with-highcharts-react-native/ https://www.highcharts.com/blog/post/creating-mobile-charts-with-highcharts-react-native/
https://www.npmjs.com/package/react-native-highcharts https://www.npmjs.com/package/react-native-highcharts
The main difference is that react-native-highcharts
is a third party package that supports most of highcharts products like highstock
or highmaps
while highcharts-react-native
only support highcharts
.主要区别在于
react-native-highcharts
是第三方包,支持大多数 highcharts 产品,如highstock
或highmaps
,而highcharts-react-native
仅支持highcharts
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.