react-native-charts-wrapper
react-native-charts-wrapper copied to clipboard
fix ios blank
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch [email protected] for the project I'm working on.
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-charts-wrapper/ios/ReactNativeCharts/bar/RNBarChartView.swift b/node_modules/react-native-charts-wrapper/ios/ReactNativeCharts/bar/RNBarChartView.swift
index fef1570..723a7e4 100644
--- a/node_modules/react-native-charts-wrapper/ios/ReactNativeCharts/bar/RNBarChartView.swift
+++ b/node_modules/react-native-charts-wrapper/ios/ReactNativeCharts/bar/RNBarChartView.swift
@@ -18,6 +18,11 @@ class RNBarChartView: RNBarChartViewBase {
return _dataExtract
}
+ override func layoutSubviews() {
+ super.layoutSubviews()
+ _chart.frame = self.bounds // Adjust the chart's frame to fill the entire component's bounds
+ }
+
override init(frame: CoreGraphics.CGRect) {
self._chart = BarChartView(frame: frame)
This issue body was partially generated by patch-package.
@qiushui123 This fix is only for the bar chart.
It is better to adjust RNBarLineChartViewBase, which will also work for the line chart. There may be a better fix, which will work for all charts. I don't use others and this was enough for me
I used yarn patch and not patch-package
diff --git a/ios/ReactNativeCharts/RNBarLineChartViewBase.swift b/ios/ReactNativeCharts/RNBarLineChartViewBase.swift
index a1fd7d5dd13a17bbbc4a0ee732d8932032a69abd..8c590b26c54345018ac133be52af5153ffd56703 100644
--- a/ios/ReactNativeCharts/RNBarLineChartViewBase.swift
+++ b/ios/ReactNativeCharts/RNBarLineChartViewBase.swift
@@ -74,6 +74,11 @@ class RNBarLineChartViewBase: RNYAxisChartViewBase {
}
}
+ override func layoutSubviews() {
+ super.layoutSubviews()
+ barLineChart.frame = self.bounds // Adjust the chart's frame to fill the entire component's bounds
+ }
+
func setMaxHighlightDistance(_ maxHighlightDistance: CGFloat) {
barLineChart.maxHighlightDistance = maxHighlightDistance;
}