indiespirit / react-native-chart-kit

📊React Native Chart Kit: Line Chart, Bezier Line Chart, Progress Ring, Bar chart, Pie chart, Contribution graph (heatmap)
https://expo.io/@indiespirit/react-native-chart-kit
MIT License
2.86k stars 661 forks source link

Bar Chart transparent on the web #733

Open willianlouza opened 2 months ago

willianlouza commented 2 months ago

The Bar Chart is transparent on the web unless i reload the page.

The home page shows the Bar Chart normally

Captura de tela de 2024-08-29 15-06-34

So if I navigate to another page which also has a Bar Chart, it displays transparent

Captura de tela de 2024-08-29 15-06-51

And when I refresh the page, the graph is displayed as it should

Captura de tela de 2024-08-29 15-06-56

"expo-router": "~3.5.18" "react-native-chart-kit": "^6.12.0" "react-native-svg": "^15.4.0" "react-native-web": "~0.19.10" "expo": "~51.0.22" "react-native": "0.74.3"

willianlouza commented 2 months ago
const chartConfig: Partial<AbstractChartConfig> = {
  backgroundColor: CMEXX_COLORS.TERTIARY,
  backgroundGradientFrom: CMEXX_COLORS.TERTIARY,
  backgroundGradientTo: CMEXX_COLORS.TERTIARY,
  backgroundGradientFromOpacity: 0.2,
  backgroundGradientToOpacity: 0.1,
  color: (opacity = 1) => CMEXX_COLORS.PRIMARY,
};

....

 return (
    <View
      style={{
        marginVertical: 16,
        justifyContent: "center",
        alignItems: "center",
      }}
    >
      <Text style={{ marginBottom: 8 }}>{classificacao.nome}</Text>
      <View
        style={{
          borderWidth: 1,
          borderRadius: 6,
          borderColor: CMEXX_COLORS.PRIMARY,
        }}
      >
        <BarChart
          style={{ paddingRight: 0 }}
          data={barChartData}
          width={(Platform.OS === "web" ? screenWidth / 2 : screenWidth) - 40}
          withHorizontalLabels={false}
          height={220}
          chartConfig={{
            ...chartConfig,
            propsForLabels: {
              fontSize: RFPercentage(1.2),
              fontFamily: "SpaceMono",
            },
          }}
          withInnerLines={false}
          withCustomBarColorFromData={false}
          yAxisLabel=""
          yAxisSuffix=""
          showValuesOnTopOfBars
        />
      </View>
    </View>
  );
hummus-erectus commented 1 month ago

I am experiencing this too. I don't suppose you found a solution?

willianlouza commented 4 weeks ago

No. I'm using react-native-gifted-charts instead