xAxis is occluded and the line of the chart is broken
- Dominant language
- Swift
- Stars
- 28k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
## Charts Environment
**Charts version:** 3.2.0
**Xcode version:** 10.2
**Swift version:** 5.0
**Platform(s) running Charts:** iOS
**macOS version running Xcode:** 10.14.4
## The Problem
* As shown below, xAxis is occluded when it is too long.

* As shown below, the line of the chart is broken.

## The Code
```swift
// 混合图表
public lazy var combinedChartView: CombinedChartView = {
let view = CombinedChartView()
view.drawOrder = [DrawOrder.bar.rawValue, DrawOrder.line.rawValue] // 绘制顺序
view.noDataText = FMModuleChart.localized("chart_empty") // 无数据时显示的文字
view.chartDescription = nil // 描述文字
view.legend.enabled = false // 隐藏图例
view.dragEnabled = true // 拖拽图表
view.pinchZoomEnabled = false // 触控放大
view.doubleTapToZoomEnabled = false // 双击放大
view.scaleXEnabled = false // X 轴缩放
view.scaleYEnabled = false // Y 轴缩放
view.highlightPerTapEnabled = false // 单击高亮
view.highlightPerDragEnabled = false // 拖拽高亮
// X 轴
view.xAxis.labelPosition = .bottom // 显示位置
view.xAxis.drawGridLinesEnabled = false // 网格绘制
view.xAxis.axisLineColor = UIColor(hexString: "#e5e5e5")! // X 轴颜色
view.xAxis.axisLineWidth = FMSize.separator // X 轴线宽
view.xAxis.labelFont = FMFont.font30 // 字号
view.xAxis.labelTextColor = FMColor.description // 颜色
// 左侧 Y 轴
view.leftAxis.labelPosition = .outsideChart // 显示位置
view.leftAxis.drawGridLinesEnabled = true // 网格绘制
view.leftAxis.gridColor = UIColor(hexString: "#e5e5e5")! // 网格颜色
view.leftAxis.gridLineWidth = FMSize.separator // 网格线宽
view.leftAxis.drawAxisLineEnabled = false // 是否显示轴线
view.leftAxis.labelFont = FMFont.font30 // 字号
view.leftAxis.labelTextColor = FMColor.description // 颜色
view.leftAxis.axisMinimum = 0 // 最小值
view.leftAxis.setLabelCount(6, force: true) // Y 轴段数
// 右侧 Y 轴
view.rightAxis.labelPosition = .outsideChart // 显示位置
view.rightAxis.drawGridLinesEnabled = false // 网格绘制
view.rightAxis.drawAxisLineEnabled = false // 是否显示轴线
view.rightAxis.labelFont = FMFont.font30 // 字号
view.rightAxis.labelTextColor = FMColor.description // 颜色
view.rightAxis.axisMinimum = 0 // 最小值
view.rightAxis.axisMaximum = 100 // 最大值
view.rightAxis.setLabelCount(6, force: true) // Y 轴段数
return view
}()
```
```swift
/// 设置图表数据
public func setChartData(xValues: [String], finishData: [Double], unfinishData: [Double], completionData: [Double], isXLabelRotation: Bool = false) {
if !xValues.isEmpty, xValues.count == finishData.count, xValues.count == unfinishData.count, xValues.count == completionData.count {
// 柱状图数据
var barEntries = [BarChartDataEntry]()
var maxTotalData: Double = 0
for index in 0.. maxTotalData { maxTotalData = finish + unfinish }
let entry = BarChartDataEntry(x: index.double, yValues: [finish, unfinish])
barEntries.append(entry)
}
let barDataSet = BarChartDataSet(values: barEntries, label: nil)
barDataSet.colors = [finishColor, unfinishColor] // 柱状颜色
barDataSet.axisDependency = .left // 根据左边数据显示
barDataSet.drawValuesEnabled = false // 是否显示数据
let barData = BarChartData(dataSet: barDataSet)
barData.barWidth = 0.55 // 柱状图宽度(数值范围 0 ~ 1)
// 折线图数据
var lineEntries = [ChartDataEntry]()
for index in 0..
Contributor guide
Assessment
This issue has not been assessed yet.