in a personal swift app i am writing, i am using a charting library to create bar charts and display them in a viewcontroller. everything is working fine so far. Now i would like to create other charts, capture them as a uiimage to include in a PDF form ... without displaying the charts. The charting library creates a uiview and I tried many of the suggestions. post1, and this one post2 but without much luck...
this code works but forces me to display the chart
resourceBarChart.updateDataEntries(dataEntries: resChartData, animated: false)
self.view.addSubview(resourceBarChart)
let myimage1 = self.view.subviews[1].image(withScale: .native)
omitting the display of the uiview
resourceBarChart.updateDataEntries(dataEntries: resChartData, animated: false)
let myimage = resourceBarChart.image(withScale: .native)
returns an empty canvas. i tried playing with the hidden property but without luck (maybe as expected). Being new at this, i suspect there is a subtlety that i am overlooking and open for any suggestions