嘿,我想在折线图中显示每周电池电量的数据

问题描述

y 轴 => 电池电量 x 轴 => 工作日

我每秒钟都从 API for Battery-Level 获得这些数据 {"BatteryLevel":"45",Datetime:"当前时间"}

我想将该数据更新为折线图,但我无法进行自动时间缩放。周五的数据将在周三显示。那么我如何使用 react-native-chart-kit 库进行日期时间缩放。

我正在获取电池电量数据,但我不知道如何将其转换为时间缩放

我的折线图代码是:

                <LineChart
                    data={this.state.responsedata}
                    width={screenWidth*0.98}
                    height={500}
                    chartConfig={chartConfig}
                    fromZero
                    bezier
                    //withDots={false}
                    withVerticalLines={false}
                    segments={10}
                    style={{
                        marginTop: 20,borderRadius: 16
                    }}
                    formatXLabel={() => yLabelIterator.next().value}
                />

我的数据代码是:

 state = {
        isLoading:true,responsedata: {
            labels: ["mon"," ","tue","wed","thu","fri","sat","sun"],datasets: [
                {
                    data: [data from api]
                },]
        }
    };

解决方法

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

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

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