Charts: الرسوم المتحركة الشريطية من نوع easyInBack تعطل

تم إنشاؤها على ١٤ مارس ٢٠١٨  ·  3تعليقات  ·  مصدر: danielgindi/Charts

لدي تمديد
""
عرض BarChart {

private class BarChartFormatter: NSObject,IAxisValueFormatter {

    var values : [String]
    required init (values : [String]) {
        self.values = values
        super.init()
    }


    func stringForValue(_ value: Double, axis: AxisBase?) -> String {
        return values[Int(value)]
    }
}

func setChartValues (xAxisValues : [String] , values : [Double],label : String) {

    var barChartDataEntries = [BarChartDataEntry]()

    for i in 0..<values.count {
        let dataEntry = BarChartDataEntry(x: Double(i), y: values[i])
        barChartDataEntries.append(dataEntry)
    }
    let chartDataSet = BarChartDataSet(values: barChartDataEntries, label: label)
    chartDataSet.colors = ChartColorTemplates.colorful()
    let chartData = BarChartData(dataSet: chartDataSet)

    let formatter = BarChartFormatter(values: xAxisValues)
    let xAxis = XAxis()
    xAxis.valueFormatter = formatter
    self.xAxis.valueFormatter = xAxis.valueFormatter
    self.xAxis.labelPosition = .bottom

    self.data = chartData
   // self.data?.notifyDataChanged()
   // self.notifyDataSetChanged()

    self.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .easeInBack) // Cause  crash

}

}
""

ويتعطل التطبيق هنا

for j in 0 ..< Int(ceil(Double(dataSet.entryCount) * animator.phaseX)) // Crash here { guard let e = dataSet.entryForIndex(j) as? BarChartDataEntry else { continue }

خطأ فادح: لا يمكن تشكيل النطاق مع الجزء العلوي من النطاق <LowerBound

(lldb) po dataSet.entryCount
12

(lldb) po animator.phaseX
-0.085005447941268492

الرجاء حل هذه المشكلة

bug help wanted

ال 3 كومينتر

أعتقد أنه من الممكن أن يكون في مشروعك وظيفة كبيرة تستغرق وقتًا
انتهى الوقت

لا الحل

        DispatchQueue.main.async(execute: {() -> Void in
       self.animate(xAxisDuration: 2.0, yAxisDuration: 2.0, easingOption: .easeInBack) 
        })

أنا اعتقد ذلك،
for j in 0 ..< Int(ceil(Double(dataSet.entryCount) * animator.phaseX))
تغير ل
for j in stride(from: 0, to: Int(ceil(Double(dataSet.entryCount) * animator.phaseX)), by: 1)

PrashantKT لدي نفس المشكلة والمقتطف الذي نشرهtxoan يعمل ، ولكن سيكون رائعًا إذا كان بإمكان أي شخص التحقق مما إذا كان الحل لا يقدم أخطاء جديدة أو أي مشكلة أخرى. تضمين التغريدة

هل كانت هذه الصفحة مفيدة؟
0 / 5 - 0 التقييمات

القضايا ذات الصلة

ahmedsafadii picture ahmedsafadii  ·  3تعليقات

coop44483 picture coop44483  ·  3تعليقات

BrandonShega picture BrandonShega  ·  4تعليقات

Bharati555 picture Bharati555  ·  4تعليقات

cilasgimenez picture cilasgimenez  ·  4تعليقات