Shinobi를 사용하는 도넛 차트가 있습니다. 그러나 데이터에 따라 라벨이 겹칩니다.Shinobi 도넛 차트 레이블이 겹침
또한 레이블 중 하나가 완전히 (최대 지불을) 보여되지 않습니다.
스택 오버플로 전체를 검색하여 이에 대한 해결책을 찾을 수 없습니다. 또한 Shinobi 웹 사이트 나 관련 문서에서이 문제에 관한 내용은 없습니다. 어떤 도움을 주시면 감사하겠습니다
import UIKit
class MyViewController: UIViewController, SChartDatasource {
var donutChartValues:[Double] = []
var donutChartLabels:[String] = []
@IBOutlet weak var chartView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
redrawChart()
}
func redrawChart() {
setDonutChartValues()
let chart = ShinobiChart(frame: chartView.bounds)
chart.autoresizingMask = [.flexibleHeight, .flexibleWidth]
chart.backgroundColor = UIColor.clear
chart.datasource = self
chartView.addSubview(chart)
}
func setDonutChartValues() {
donutChartValues.removeAll()
donutChartLabels.removeAll()
donutChartValues.append(2500.00)
donutChartLabels.append("Max Payment")
donutChartValues.append(300.0)
donutChartLabels.append("Property Tax")
donutChartValues.append(100.0)
donutChartLabels.append("Condo Fees")
donutChartValues.append(150.0)
donutChartLabels.append("Heating Costs")
donutChartValues.append(300.0)
donutChartLabels.append("Debts")
donutChartValues.append(4000.0)
donutChartLabels.append("Other Expenses")
}
/********************************************************************************/
// MARK: - SChartDatasource methods
/********************************************************************************/
func numberOfSeries(in chart: ShinobiChart) -> Int {
return 1
}
func sChart(_ chart: ShinobiChart, seriesAt index: Int) -> SChartSeries {
let donutSeries = SChartDonutSeries()
donutSeries.style().spokeStyle.showSpokes = true;
donutSeries.selectedStyle().spokeStyle.showSpokes = true;
donutSeries.style().labelFontColor = UIColor.black
donutSeries.selectedStyle().labelFontColor = UIColor.black
return donutSeries
}
func sChart(_ chart: ShinobiChart, numberOfDataPointsForSeriesAt seriesIndex: Int) -> Int {
return donutChartValues.count
}
func sChart(_ chart: ShinobiChart, dataPointAt dataIndex: Int, forSeriesAt seriesIndex: Int) -> SChartData {
let dp = SChartDataPoint()
dp.xValue = 0
dp.yValue = (donutChartValues.count > dataIndex) ? donutChartValues[dataIndex] : 0
return dp
}
func sChart(_ chart: ShinobiChart, labelForSliceAt sliceIndex: Int, in series: SChartRadialSeries) -> UILabel? {
let sliceLabel = UILabel()
sliceLabel.text = (donutChartLabels.count > sliceIndex) ? donutChartLabels[sliceIndex] : ""
return sliceLabel
}
}
:
이
내 코드입니다.
감사하지만 데이터가 프로그램에서 변경 될 것이므로 새 데이터를 기반으로하는 레이블이 겹칠 지 여부를 계산할 수있는 쉬운 방법은 없을 것이라고 생각합니다. – Besat