I use IOS charts to draw download speeds. I give an array of chart functions double, which has byte values. He is building a chart. But I want to show the value of the chart labels in megabytes, kilobytes or bytes. I can convert bytes to this value using NSByteFormatter
. But there is one problem: the function that builds the diagrams takes one array of values ββ(for example, an array of bytes) and displays the same values ββin the labels on the diagram, I tried to find a solution for this, but I did not find any. How can i do this?
Function that draws a chart
func setSendChart(description: [String], value: [Double]) { var chartDataEntryArray = [ChartDataEntry]() for item in 0..<description.count { let chartEntry = ChartDataEntry(value: value[item], xIndex: item) chartDataEntryArray.append(chartEntry) } let dataSet = LineChartDataSet(yVals: chartDataEntryArray, label: "") dataSet.drawCircleHoleEnabled = false dataSet.drawCirclesEnabled = false dataSet.drawCubicEnabled = true dataSet.drawFilledEnabled = true dataSet.drawValuesEnabled = false dataSet.fillColor = UIColor(red: 47/255, green: 206/255, blue: 255/255, alpha: 1.0) let chartData = LineChartData(xVals: description, dataSet: dataSet) sendChartView.data = chartData }
source share