问题:我正在尝试制作一个简单的折线图,当我选择新数据时会更新。我的VictoryLine似乎没有将我的y轴(VictoryAxis)识别为从属轴。实际上,当我完全移除两个轴组件时,该行的功能几乎相同。我不确定如何根据实际给定数据使线可靠地绘制图形。具体如下。
复制系统:
react-native:0.55.4
react-native-svg:6.5.0
胜利图:0.0.1
胜利本机:31.0.0
我正在使用prop allData传递Redux存储的一部分。默认的redux存储结构如下: redux store image
这两个默认点不会自动显示在图形上(即使将域从轴上删除也是如此)。如果我选择1,则图形似乎从10开始并趋向于1。如果我随后选择10,则y截距将向下移动至应有的5。以下示例图片:
problem state 1
problem state 2
这是我正在使用的代码:
import React from 'react';
import { View, StyleSheet, Text } from 'react-native';
import Svg from 'react-native-svg';
import { VictoryAxis, VictoryLine } from 'victory-native';
const MoodGraph = ({ allData }) => {
return(
<View>
<Svg>
<VictoryAxis //Select domain that works absolute then can eventually be filtered by range
domain={{x: [new Date(2018, 11, 29, 13), new Date(2018, 11, 29)]}} //set domain to exclude first two state points (so victory line works with no visual errors)
scale="time"
standalone={false}
/>
<VictoryAxis dependentAxis
domain={[0, 10]} //Adjust picker to selected domain
orientation="left"
standalone={false}
/>
<VictoryLine //Need this line to graph mood over time, experimenting with dif domains
style={{ data: { stroke: "#000FFF"}}}
data={allData}
x="date"
y= "rating"
scale= {{x: "time", y: "linear"}}
/>
</Svg>
</View>
);
};
const styles = StyleSheet.create({
parent: {
backgroundColor: "#000000",
padding: 0
},
});
export default MoodGraph;`
这让我发疯。请帮忙!