React native 将本机图表套件图表与图像进行反应
我的React native 将本机图表套件图表与图像进行反应,react-native,react-native-chart-kit,React Native,React Native Chart Kit,我的react native应用程序中有一个图形,我想将其转换为base64字符串。因此,我想将我的折线图转换为图像。那么我如何才能做到这一点呢 import React from 'react'; import {Text, View, Dimensions} from 'react-native'; import {LineChart} from 'react-native-chart-kit'; const App = () => { return ( <Vie
react native
应用程序中有一个图形,我想将其转换为base64字符串。因此,我想将我的折线图
转换为图像。那么我如何才能做到这一点呢
import React from 'react';
import {Text, View, Dimensions} from 'react-native';
import {LineChart} from 'react-native-chart-kit';
const App = () => {
return (
<View>
<Text>Bezier Line Chart</Text>
<LineChart
data={{
labels: ['January', 'February', 'March', 'April', 'May', 'June'],
datasets: [
{
data: [
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
Math.random() * 100,
],
},
],
}}
width={Dimensions.get('window').width} // from react-native
height={220}
yAxisLabel="$"
yAxisSuffix="k"
yAxisInterval={1} // optional, defaults to 1
chartConfig={{
backgroundColor: '#e26a00',
backgroundGradientFrom: '#fb8c00',
backgroundGradientTo: '#ffa726',
decimalPlaces: 2, // optional, defaults to 2dp
color: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
labelColor: (opacity = 1) => `rgba(255, 255, 255, ${opacity})`,
style: {
borderRadius: 16,
},
propsForDots: {
r: '6',
strokeWidth: '2',
stroke: '#ffa726',
},
}}
bezier
style={{
marginVertical: 8,
borderRadius: 16,
}}
/>
</View>
);
};
export default App;
从“React”导入React;
从“react native”导入{Text,View,Dimensions};
从“react native chart kit”导入{LineChart};
常量应用=()=>{
返回(
贝塞尔折线图
`rgba(255,255,255,${opacity})`,
labelColor:(不透明度=1)=>`rgba(255,255,255,${opacity})`,
风格:{
边界半径:16,
},
道具:{
r:'6',
冲程宽度:“2”,
笔划:“#ffa726”,
},
}}
贝塞尔
风格={{
Margin:8,
边界半径:16,
}}
/>
);
};
导出默认应用程序;
这是基本的折线图程序。
PS
如果此软件包无法实现,是否有其他方法将任何数据点转换为图形,从而将其转换为图像