supervons / react-native-echarts-pro

A React-Native charts based on Apache ECharts, support various charts and map.
https://supervons.github.io/react-native-echarts-pro-docs/
MIT License
216 stars 33 forks source link

圖表能否在user看不見的情況下生成? #66

Closed Summerflowerling closed 2 years ago

Summerflowerling commented 2 years ago

问题描述; Hi, 我需要在user看不見的情況下,生成圖表並將取得的base64存檔 嘗試作法是將圖表拉出view之外 試過絕對定位,也試過單純加上margin把圖表推走,發現如果推出view之外,current.getInstance就會是空的object 請問這個套件有辦法做到在view以外的地方依然生成圖表嗎? 謝謝

react-native-echarts-pro 版本: "1.8.4" react-native 版本 ;"0.68.2 react-native-webview 版本; "^11.22.7" 平台; Andoid & ios

ng520tx commented 2 years ago

你在图表上面 覆盖一层VIEW啊 不就看不见了啊

supervons commented 2 years ago

的确,可以使用@ng520tx 的方案,在上面覆盖一层 View,然后 Index 给高一些。

最后,使用下面的方式获取图片:

  echartsRef.current.getInstance('getDataURL',{
    pixelRatio: 2,
    backgroundColor: '#fff'
    }).then(res=>{
      console.log(res) // base64
  })