如何解决将react-native-chart-kit图表导出为PDF
我正在尝试将使用react-native-chart-kit创建的图表导出到具有expo-print的PDF文档中。我很难这么做。我找不到在PDF内呈现图表的方法,它只会在图表说明中放置文本。
这是我正在使用的代码:
...
const createPDF = async() => {
const html = `<View style={styles.formContainer}>
<LineChart
style={styles.graphStyle}
data={{
labels: reportData.sale,datasets: [
{
data: reportData.sale.map(i => reportData.saleById[i]['total'])
}
]
}}
width={Dimensions.get("window").width}
height={Dimensions.get("window").height * 0.55}
yAxisLabel="Q."
chartConfig={chartConfig}
verticalLabelRotation={45}
/>
</View>`;
const { uri } = await Print.printToFileAsync({html});
Sharing.shareAsync(uri);
};
return (
<View style={styles.formContainer}>
<LineChart
style={styles.graphStyle}
data={{
labels: reportData.sale,datasets: [
{
data: reportData.sale.map(i => reportData.saleById[i]['total'])
}
]
}}
width={Dimensions.get("window").width}
height={Dimensions.get("window").height * 0.55}
yAxisLabel="Q."
chartConfig={chartConfig}
verticalLabelRotation={45}
/>
</View>
<View>
<Button
theme={roundness}
color={'#000000'}
icon={"chart-bar"}
height={50}
mode="contained"
labelStyle={{
fontFamily: "dosis-bold",fontSize: 15,}}
style={{
fontFamily: 'dosis',marginLeft: '5%',marginRight: '5%',justifyContent: 'center',}}
onPress={ createPDF }
>
{'CREAR PDF'}
</Button>
</View>
);
...
谢谢大家的帮助! :)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。