使用 xstream 和 react-native-svg-charts

问题描述

我是 React Native 的新手,所以如果我的解释不好请原谅。

我正在尝试制作一个应用程序,该应用程序接收 BLE 数据并将其绘制到图表上。使用“xstream”包接收数据时将数据放入流中,然后使用“stream-to-array”包将此数据放入数组中,我使用的图形库是“react-native” -svg-charts'。

到目前为止,我一直在努力测试从流中获取数据并将其格式化在图表上的能力,因为即使流中有数据也没有显示任何内容

import React from "react";
import { LineChart,Grid } from "react-native-svg-charts";
import xs from "xstream";

var toArray = require("stream-to-array");
const set = [10,20,30,40];

var stream = xs.fromArray(set);
var data = [];

stream.addListener({
  next: (i) => console.log(i),error: (err) => console.error(err),});

toArray(stream,function (err,data) {
  assert.ok(Array.isArray(data));
});

class Graph extends React.PureComponent {
  render() {
    return (
      <LineChart
        style={{ height: 200 }}
        data={data}
        animate="true"
        svg={{ stroke: "rgb(134,65,244)" }}
        contentInset={{ top: 20,bottom: 20 }}
      >
        <Grid />
      </LineChart>
    );
  }
}

export default Graph;

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...