[英]Victory | How to display x-axis from the lowest negative y-axis value
I have a graph to display some values, but the y axis has negative values, as below. 我有一个图形来显示一些值,但是y轴具有负值,如下所示。
<VictoryChart
theme={VictoryTheme.material}
>
<VictoryLine
style={{
data: { stroke: "#c43a31" },
parent: { border: "1px solid #ccc"}
}}
data={[
{ x: 1, y: -2 },
{ x: 2, y: -3 },
{ x: 3, y: -5 },
{ x: 4, y: -4 },
{ x: 5, y: -7 }
]}
/>
</VictoryChart>
It's displayed like this. 这样显示。
I need to have the x-axis at -7 value of the y-axis. 我需要将x轴设置为y轴的-7值。 How can I achieve this?
我该如何实现? Thanks!
谢谢!
Try this: 尝试这个:
<VictoryChart
theme={VictoryTheme.material}
domain={{x: [1, 5], y: [-7, -2]}}
>
<VictoryAxis
orientation="top"
/>
<VictoryAxis dependentAxis
orientation="left"
invertAxis
/>
<VictoryLine
style={{
data: { stroke: "#c43a31" },
parent: { border: "1px solid #ccc"}
}}
data={[
{ x: 1, y: -2 },
{ x: 2, y: -3 },
{ x: 3, y: -5 },
{ x: 4, y: -4 },
{ x: 5, y: -7 }
]}
/>
</VictoryChart>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.