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

问题描述 投票:0回答:1

我的图表具有我的动态值,我需要知道两件事:

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"
  }
}
react-native react-native-chart-kit
1个回答
1
投票
  1. [propsForLabels可用于替代标签的样式,react-native-svg
  2. 图形的比例与数据集的极值成正比。如果您希望减小比例,这意味着您的数据应该在较小范围内。
© www.soinside.com 2019 - 2024. All rights reserved.