react-native - 修改react-native-chart-kit中标签的宽度

标签 react-native react-native-chart-kit

我正在用我的动态值绘制图表,我需要知道两件事:

1/使用react-native-chart-kit的LineChart修改x和y中标签的宽度!!

2/控制图表的比例

如果您知道可以实现此目的的比例或选项;

 <LineChart
            data={this.state.data}
            width={Dimensions.get("window").width*0.9}
            height={400}
            //yAxisLabel={"DH"}
            chartConfig={chartConfig}
            bezier
            spacing={0.8}
            spacingInner={0.8}
            verticalLabelRotation={90}
            style={{
              marginTop:40,
              marginLeft:20,
              fontSize:1,
            }}
            />
const chartConfig = {
  backgroundColor: "#f5f3ed",
  backgroundGradientFrom: "#f5f3ed",
  backgroundGradientTo: "#f5f3ed",
  //decimalPlaces: 2, // optional, defaults to 2dp
  color: (opacity = 1) => `rgba(3, 2, 2, ${opacity})`,
  labelColor: (opacity = 1) => `rgba(3, 2, 2, ${opacity})`,
  barPercentage: 0.5,
  style: {
    borderRadius: 16
  },
  propsForDots: {
    r: "6",
    strokeWidth: "2",
    stroke: "#ffa726"
  }
}

最佳答案

  1. propsForLabels 可用于覆盖标签的样式,react-native-svg
  2. 图表的比例与数据集的极值成正比。如果您希望缩小规模,这意味着您的数据应该在一个相当小的范围内。

关于react-native - 修改react-native-chart-kit中标签的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60492727/

相关文章:

javascript - Prop 验证中缺少 React Navigation 'navigation'

android - 如何在 React Native 中将状态映射到 redux 中的 Prop

react-native - 在 react 原生图表工具包中导入 barChart 中的 Y 标签

react-native - 如何在 React Native 图表工具包中将 Y 轴值从数字更改为字符串

javascript - onDataPointClick 函数不起作用 - react-native-chart-kit

android - 如何在 React Native Android 构建中包含 AAR?

react-native - 使用 create-react-native-app 创建了一个应用程序,如何将其发布到 Google Play 商店?

reactjs - 警告 : Failed prop type: Invalid prop `value` of type `number` supplied to `TextInput` , 预期 `string`

javascript - 单击按钮刷新图表