Actually i’m would load data dynamically to react-native-pure-chart.
I have an API that give the data for each time where there was some measures and the response look’s like the following:
Array [
230,
230,
230,
50,
250,
]
Array [
"14",
"13",
"09",
"09",
"09",
]
const [itemsY, setItemsY] = useState([]);
const [itemsX, setItemsX] = useState([]);
useEffect(() => {
fetchData1();
}, [1])
const fetchData1 = () => {
DataService.getEnergyDataList()
.then(response => {
setItemsY([...itemsY,...response.data.map(res => res.Voltage)]);
setItemsX([...itemsX, ...response.data.map(res => res.Time.substr(11, 2))]);
})
.catch(e => {
console.log(e);
});
};
let sampleData = [
{x: itemsX, y: itemsY},
]
<PureChart
data={sampleData}
type='line' width={'100%'}
height={300}
customValueRenderer={(index, point) => {
if (index % 2 === 0) return null
return (
<Text style={{textAlign: 'center'}}>{point.y}</Text>
)
}}/>
Error: Exception in HostFunction: Malformed calls from JS: field sizes are different.
[[3,3,3,3,3],[2,2,2,2,2],[[357,”RCTView”,21,{“position”:”absolute”,”height”:”100%”,”width”:”100%”}],[367,”RCTView”,21,{“borderTopColor”:-2039584,”borderTopWidth”:1,”width”:”100%”}]],2038]