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
By the way, in general I think the library is a great library. To the builders of this library, I say thanks.
So sometimes when I try to get chart to display, it shows the legend and the title, but doesn't show the chart itself. I've checked and the data being submitted to the chart is fine- as best as I can tell, sometimes it just refuses to display a chart. Usually, it's with the pie chart (though I think the bar chart may have displayed the same behavior, that doesn't happen as frequently). Here is the bulk of the code for setting up the pie chart: let chart = getChartObject() as! PieChartView
chart.drawHoleEnabled = false
/chart.isUsePercentValuesEnabled = true/
var values = myPieChartData.secondsPerSection
var sum = 0
for a in 0...values.count - 1
{
sum += values[a]
}
var outputSolutions: [PieChartDataEntry] = []
for b in 0...values.count - 1
{
var myVal: PieChartDataEntry
let (h, m, s) = secondsToHoursMinutesSeconds(seconds: Double(values[b]))
assert (sum > 0)
if sum > 0
{
myVal = PieChartDataEntry(value: Double(values[b] / sum * 100), label: "(Int(h)) hrs (Int(m)) mins")
}
else
{
myVal = PieChartDataEntry(value: 0.0, label: "0 hrs 0 mins")
}
outputSolutions.append(myVal)
}
var myDataSet = PieChartDataSet(values: outputSolutions, label: getChartTitle())
setDatasetColors(myDataSet: myDataSet)
var myChartSet: [IChartDataSet] = []
myChartSet.append(myDataSet)
var myData = PieChartData(dataSets: myChartSet)
chart.data = myData`
Thanks for your consideration of this matter.
Sincerely,
Sean
The text was updated successfully, but these errors were encountered:
I figured it out! I had recently changed values to being integers instead of doubles. It was dividing and not getting an integer, so it rounded to zero. Casting values[b] to a double and casting sum to a double before dividing solved the problem.
Hi,
By the way, in general I think the library is a great library. To the builders of this library, I say thanks.
So sometimes when I try to get chart to display, it shows the legend and the title, but doesn't show the chart itself. I've checked and the data being submitted to the chart is fine- as best as I can tell, sometimes it just refuses to display a chart. Usually, it's with the pie chart (though I think the bar chart may have displayed the same behavior, that doesn't happen as frequently). Here is the bulk of the code for setting up the pie chart: let chart = getChartObject() as! PieChartView
chart.drawHoleEnabled = false
/chart.isUsePercentValuesEnabled = true/
var values = myPieChartData.secondsPerSection
var sum = 0
for a in 0...values.count - 1
{
sum += values[a]
}
var outputSolutions: [PieChartDataEntry] = []
for b in 0...values.count - 1
{
var myVal: PieChartDataEntry
let (h, m, s) = secondsToHoursMinutesSeconds(seconds: Double(values[b]))
assert (sum > 0)
if sum > 0
{
myVal = PieChartDataEntry(value: Double(values[b] / sum * 100), label: "(Int(h)) hrs (Int(m)) mins")
}
else
{
myVal = PieChartDataEntry(value: 0.0, label: "0 hrs 0 mins")
}
outputSolutions.append(myVal)
}
var myDataSet = PieChartDataSet(values: outputSolutions, label: getChartTitle())
setDatasetColors(myDataSet: myDataSet)
var myChartSet: [IChartDataSet] = []
myChartSet.append(myDataSet)
var myData = PieChartData(dataSets: myChartSet)
chart.data = myData`
Thanks for your consideration of this matter.
Sincerely,
Sean
The text was updated successfully, but these errors were encountered: