We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
let months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun"] let unitsSold = [20.0, 4.0, 6.0, 3.0, 12.0, 3.0] let unitsSold2 = [10.0, 3.0, 5.0, 2.0, 2.0, 1.0] var combineChartView = BarChartView() combineChartView.chartDescription?.enabled = false combineChartView.scaleYEnabled = false combineChartView.scaleXEnabled = false combineChartView.noDataText = "暂时没有任何数据" let xAxis = combineChartView.xAxis xAxis.labelPosition = .bottom xAxis.drawGridLinesEnabled = false xAxis.drawAxisLineEnabled = true xAxis.valueFormatter = IndexAxisValueFormatter(values: months) xAxis.forceLabelsEnabled = true xAxis.granularity = 1 xAxis.granularityEnabled = true xAxis.labelTextColor = UIColor.black combineChartView.rightAxis.enabled = false let yAxis = combineChartView.leftAxis yAxis.drawGridLinesEnabled = true var entrys : [BarChartDataEntry] = [] for i in 0..<unitsSold.count { let entry = BarChartDataEntry(x: Double(i), y: Double(unitsSold[i])) entrys.append(entry) } let set1 = BarChartDataSet(values: entrys, label: "老顾客") set1.colors = [UIColor.yellow] set1.drawValuesEnabled = false entrys = [] for i in 0..<unitsSold2.count { let entry = BarChartDataEntry(x: Double(i), y: Double(unitsSold2[i])) entrys.append(entry) } let set2 = BarChartDataSet(values: entrys, label: "新顾客") set2.colors = [UIColor.red] set2.drawValuesEnabled = false let chartData = BarChartData(dataSets: [set1,set2]) combineChartView.xAxis.axisMinimum = chartData.xMin - 1.0 combineChartView.xAxis.axisMaximum = chartData.xMax + 1.0 combineChartView.data = chartData
The text was updated successfully, but these errors were encountered:
I think Writing like this ,it's will work. Is there any more attention?
xAxis.valueFormatter = IndexAxisValueFormatter(values: months) xAxis.forceLabelsEnabled = true xAxis.granularity = 1 xAxis.granularityEnabled = true
Sorry, something went wrong.
NOW ,i change this file "IndexAxisValueFormatter.swift" it works
open func stringForValue(_ value: Double, axis: AxisBase?) -> String { let index = Int(value.rounded()) guard index>=0, index <= _values.count-1 else { return "" } print(_values[index]) return _values[index] }
No branches or pull requests
The text was updated successfully, but these errors were encountered: