簡體   English   中英

勝利| 如何從最低的負y軸值顯示x軸

[英]Victory | How to display x-axis from the lowest negative y-axis value

我有一個圖形來顯示一些值,但是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>

這樣顯示。

在此處輸入圖片說明

我需要將x軸設置為y軸的-7值。 我該如何實現? 謝謝!

嘗試這個:

<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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM