You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently attempting to generate a scatterplot graph where many of the coordinates should be decimals. However, the values keep getting rounded to the closest whole number and I am not sure why nor can I find a solution.
The above is a picture of the graph that is being generated. At the marker selected the points should be (x: 3/500 ; y: 3/500).
The code used to generate the graph is as follows:
for i in 0..<num {
let coords = ChartDataEntry(x: Double(i/500), y: Double(i/500), data: ("Testing if points are decimal" as! String))
dataPoints.append(coords)
}
self.graphView.drawMarkers = true
let marker:BalloonMarker = BalloonMarker(color: UIColor(red: 93/255, green: 186/255, blue: 215/255, alpha: 1), font: UIFont(name: "Helvetica", size: 12)!, textColor: UIColor.white, insets: UIEdgeInsets(top: 7.0, left: 7.0, bottom: 25.0, right: 7.0))
marker.minimumSize = CGSize(width: 75.0, height: 35.0)//CGSize(75.0, 35.0)
self.graphView.marker = marker
let set1 = ScatterChartDataSet(entries: self.dataPoints, label: self.graphName)
let data = ScatterChartData(dataSet: set1)
self.graphView.data = data
self.graphView.setVisibleXRangeMaximum(6)
Essentially my question is how can I get the correct decimal points mapped onto the graph without them being rounded?
The text was updated successfully, but these errors were encountered:
So it ended up being a non-charts related problem and something dumb I missed. i was not being casted to a double which is what cause the rounding error. The issue was resolved where I directly casted i into a double (e.g. Double(Double(i)/500)
Hi all.
I am currently attempting to generate a scatterplot graph where many of the coordinates should be decimals. However, the values keep getting rounded to the closest whole number and I am not sure why nor can I find a solution.
The above is a picture of the graph that is being generated. At the marker selected the points should be (x: 3/500 ; y: 3/500).
The code used to generate the graph is as follows:
Essentially my question is how can I get the correct decimal points mapped onto the graph without them being rounded?
The text was updated successfully, but these errors were encountered: