react-native - 胜利图表 - x 轴标签缩短、自定义范围并防止重叠

标签 react-native victory-charts

使用胜利图表,我创建了一个简单的条形图。在 X 轴上,我有从 500,000 到 3,000,000 的大数字。由于图表非常窄,X 轴上的数字是重叠的。我的代码如下所示:

   <VictoryChart>
      theme={VictoryTheme.material}
      <VictoryGroup
        height={chartHeight}
        offset={10}>
        <VictoryBar
          horizontal
          data={chart2}
          labels={d => d.y}
          labelComponent={<VictoryLabel dy={10} />}
        />
        <VictoryBar horizontal data={chart1} />
      </VictoryGroup>
    </VictoryChart>
  1. 我想要这样的 x 轴标签:500,000 -> 500K。
  2. 此外,在 x 轴上,我只想有 4-5 个标签,它们总是均匀分布,所以例如0、1000K、2000K、3000K、4000K。如果我的数据的 x 轴为 1000K,则间隔将为 0、250K、500K、750K、1000K。

enter image description here

最佳答案

还有一个名为 fixLabelOverlap 的 Prop ,您可以将其传递给轴。

默认设置为false

https://formidable.com/open-source/victory/docs/victory-axis#fixlabeloverlap

关于react-native - 胜利图表 - x 轴标签缩短、自定义范围并防止重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55381658/

相关文章:

android - CodePush - 发布 iOS bundle 会破坏 Android,反之亦然

react-native - Victory Native 饼图动画

reactjs - 胜利 native : events props not working in react native/event not firing in react native when using victory bar chart

javascript - 如何在胜利 native 的面积图中制作可拖动光标

react-native - 任务队列 : Error with task: undefined is not an object (evaluating '_this.view._component.measureInWindow' ) in react native

ios - 如何从 react native 页面快速打开现有的ViewController?

javascript - react native componetWillUpdate 不起作用

android - 将数据从 Android Activity 发送到 React Native

reactjs - 胜利图表背景网格

reactjs - VictoryChart 没有填满整个 div