Open mickaelhero opened 5 years ago
I have a problem I can not center the content chart horizontally
private func setup(xValue: [String]) { noDataText = "No data" xAxis.drawGridLinesEnabled = false xAxis.labelPosition = .bottom xAxis.valueFormatter = IndexAxisValueFormatter(values: xValue) xAxis.granularity = 1 xAxis.granularityEnabled = true xAxis.labelCount = xValue.count xAxis.axisMinimum = 0.0 xAxis.axisMaximum = Double(xValue.count) leftAxis.spaceTop = 0.35 leftAxis.axisMinimum = 0 leftAxis.drawGridLinesEnabled = false rightAxis.enabled = false }
And to create the chart:
private func setChart(xValue: xAxisValue, values: [SBChartEntry]) { let dataSets: [BarChartDataSet] = values.map { let set = BarChartDataSet(entries: $0.value.enumerated().map { index, element in BarChartDataEntry(x: Double(index), y: element) }, label: $0.name) set.colors = [$0.color] return set } let chartData = BarChartData(dataSets: dataSets) let groupSpace: Double = (values.count > 1) ? 0.7 / (Double(values.count) * 2.2) : 0.6 let barSpace = (values.count > 1) ? 0.05 : 0 let barWidth: Double = (values.count > 1) ? 0.75 / Double(values.count) : 0.4 chartData.barWidth = barWidth if values.count > 1 { xAxis.centerAxisLabelsEnabled = true chartData.groupBars(fromX: Double(0), groupSpace: groupSpace, barSpace: barSpace) } else { // For one bar } notifyDataSetChanged() data = chartData //chart animation animate(xAxisDuration: 1, yAxisDuration: 1, easingOption: .linear) }
I can not configure when the chart contains only one array (so only one bar)
Same problem here. How can I fix this? The first label text is not aligning the center.
I have a problem I can not center the content chart horizontally
And to create the chart:
I can not configure when the chart contains only one array (so only one bar)