react-native-charts-wrapper icon indicating copy to clipboard operation
react-native-charts-wrapper copied to clipboard

Blank Chart on IOS

Open HasanElfalt opened this issue 11 months ago • 12 comments
trafficstars

Hello everyone, I am trying to generate charts (Line, Pie, and MultiLine Charts), and they all appear blank (the chart place is empty just on IOS, and it is working fine on Android after updating React native to 0.76 or above.

Screenshots

Screenshot 2024-11-28 at 11 07 37 PM

Steps to Reproduce the Problem

  • Create React Native with a version of 0.76 or above, or if you have an existing project, update your React Native project to a version equal to 0.76 or above.
  • Install this library

Specifications

  • Version: [v0.6.0] latest version of this library now
  • Platform: IOS
  • React Native version: 0.76 or above

HasanElfalt avatar Nov 28 '24 21:11 HasanElfalt

I have the same issue with RN0.76: Android works fine but iOS shows empty space

gigby avatar Dec 20 '24 01:12 gigby

I have the same problem with 0.76 version. LineСhart and BarChart don't work

NikldjOne avatar Dec 28 '24 07:12 NikldjOne

there is this solution, but the BarChart does not work. Linear graph worked for me https://github.com/wuxudong/react-native-charts-wrapper/pull/1007/files

NikldjOne avatar Dec 28 '24 08:12 NikldjOne

added in node_modules/react-native-charts-wrapper/ios/ReactNativeCharts/bar/RNBarChartView.swift

   override func layoutSubviews() {
        super.layoutSubviews()
        _chart.frame = self.bounds // Adjust the chart's frame to fill the entire component's bounds
    }

It's work for me, for BarChart

NikldjOne avatar Dec 28 '24 09:12 NikldjOne

@NikldjOne If it is solved using this PR, why hasn't it been merged until now?

HasanElfalt avatar Dec 29 '24 14:12 HasanElfalt

@wuxudong

https://github.com/wuxudong/react-native-charts-wrapper/pull/1007/files This PR resolves this problem, so it is highly recommended that it be reviewed and merged, and it needs to be done to all kinds of charts.

    override func layoutSubviews() {
        super.layoutSubviews()
        _chart.frame = self.bounds // Adjust the chart's frame to fill the entire component's bounds
    }

and as @NikldjOne mentioned using the above lines in each chart kind will resolve the problem

HasanElfalt avatar Dec 30 '24 09:12 HasanElfalt

The same problem for me. I've just tried to run the example. On Android, it works when iOS shows a blank screen.

eugen-vg avatar Feb 08 '25 02:02 eugen-vg

@eugen-vg check this PR solves the problem https://github.com/wuxudong/react-native-charts-wrapper/pull/1007/files

you will find that the piece of code added to the chart type you implement in node modules will solve the problem

override func layoutSubviews() {
       super.layoutSubviews()
       _chart.frame = self.bounds // Adjust the chart's frame to fill the entire component's bounds
   }

Example:

  • if you use a Line chart, you can solve the problem by using the previous piece of code and adding it to this file node_modules/react-native-charts-wrapper/ios/ReactNativeCharts/line/RNLineChartView.swift

  • if you use a Pie chart, you can solve the problem by using the previous piece of code and adding it to this file node_modules/react-native-charts-wrapper/ios/ReactNativeCharts/pie/RNPieChartView.swift

...etc

HasanElfalt avatar Feb 08 '25 13:02 HasanElfalt

Thank you @HasanElfalt . It works. I am still concerned about the approach to wrapping the native iOS/Android layers under one library. The history of this one says that Android drove it, and an unworking example doesn't add trust that iOS would work robustly. How do people use it in production? Is there another workaround that does not change the core code?

eugen-vg avatar Feb 08 '25 17:02 eugen-vg

For those who don't want to bother creating a new fork and release, I’ve published a package based on PR #1007: https://www.npmjs.com/package/enda-react-native-charts-wrapper

baran-ozer avatar Apr 18 '25 08:04 baran-ozer

@NikldjOne After following the steps mentioned for Line Chart in PR, line chart is visible in IOS, but I'm trying same solution for Bar Chart but it but it is not working.

ashish03-git avatar May 28 '25 13:05 ashish03-git

This patch solves the problem : react-native-charts-wrapper+0.6.0.patch

SamiChab avatar Jun 03 '25 07:06 SamiChab

This patch solves the problem : react-native-charts-wrapper+0.6.0.patch

thanks @SamiChab that did the trick!

jonacds avatar Jun 25 '25 14:06 jonacds