React-native-chart-kit: How can i change yAxisLabel in React Native Chart Kit?

Created on 10 Aug 2020  路  2Comments  路  Source: indiespirit/react-native-chart-kit

I'm creating Weather app in React Native and I'm using react-native-chart-kit to display temperature chart. Is there a way to change yAxisLabel values to a fixed values, or is there any props that can do that.
this is my code

const chartConfig = {
  backgroundColor: "#1cc910",
  backgroundGradientFrom: "#eff3ff",
  backgroundGradientTo: "#efefef",
  decimalPlaces: 2,
  color: (opacity = 1) => `rgba(0, 0, 0, ${opacity})`,
  fillShadowGradient: "#037d50",
  fillShadowGradientOpacity: 0.8,
  barPercentage: 0.8,
  style: {
    borderRadius: 20,
  },
};
const data = {
      labels: this.createtime(Object.values(this.state.res), histogramType),
      datasets: [
        {
          labels: [0, 20, 50, 100],
          //this function just to get data from API
          data: this.createData(Object.values(this.state.res), histogramType),
        },
      ],
    };

       <BarChart
          data={data}
          width={350}
          height={550 * 0.7}
          showBarTops={true}
          withInnerLines={true}
          // showValuesOnTopOfBars={true}
          chartConfig={chartConfig}
          verticalLabelRotation={90}
          fromZero={true}
          style={styles.barChartStyle}
        />

Most helpful comment

Hello @fernando-pascoal

I used this param but nothing is changed,
how can I use it with the correct method

All 2 comments

'm creating Weather app in React Native and I'm using react-native-chart-kit to display temperature chart. Is there a way to change yAxisLabel values to a fixed values, or is there any props that can do that.
this is my code

you can make this with this param

 formatYLabel={(value) => value}

put this attribute and return the desired value

Hello @fernando-pascoal

I used this param but nothing is changed,
how can I use it with the correct method

Was this page helpful?
0 / 5 - 0 ratings