Skip to content
New issue

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

can not draw circle on axis as the picture #4111

Closed
zhpt opened this issue Aug 19, 2019 · 1 comment
Closed

can not draw circle on axis as the picture #4111

zhpt opened this issue Aug 19, 2019 · 1 comment

Comments

@zhpt
Copy link

zhpt commented Aug 19, 2019

can not draw circle on axis as the picture, please help me solve it. Thanks a lot.

B4C7D7478B1A20C4BD6070695D9B0326

This is my code

chartView1.chartDescription?.enabled = false
chartView1.dragEnabled = true
chartView1.setScaleEnabled(false)
// chartView1.setScaleMinima(3, scaleY: 0)
chartView1.pinchZoomEnabled = false
chartView1.dragDecelerationEnabled = true //拖拽后是否有惯性效果
chartView1.dragDecelerationFrictionCoef = 0.1 //拖拽后惯性效果的摩擦系数(0~1),数值越小,惯性越不明显
chartView1.delegate = self // built in delegate for user interaction
chartView1.legend.enabled = false

    let xAxis = chartView1.xAxis
    xAxis.labelFont = .systemFont(ofSize: 11)
    xAxis.labelTextColor = .white
    xAxis.axisMaximum = 30
    xAxis.axisMinimum = 0
    xAxis.labelPosition = .bottom
    xAxis.axisLineColor = .white //轴颜色
    xAxis.axisLineWidth = 1 //x轴宽度
    // 设置坐标间隔
    xAxis.labelCount = 30
    xAxis.granularityEnabled = true
    xAxis.granularity = 1
    xAxis.gridColor = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 0.1) //x轴对应网格线的颜色
   
    
    let leftAxis = chartView1.leftAxis
    leftAxis.labelFont = .systemFont(ofSize: 11)
    leftAxis.labelTextColor = .white
    leftAxis.axisMaximum = 260
    leftAxis.axisMinimum = 0
    leftAxis.zeroLineColor = .white
    leftAxis.zeroLineWidth = 2
    // 设置坐标间隔
    leftAxis.labelCount = 13
    leftAxis.granularityEnabled = true
    leftAxis.granularity = 1
    leftAxis.gridColor = UIColor(red: 0.85, green: 0.85, blue: 0.85, alpha: 0.1) //轴对应网格线的颜色
    leftAxis.axisLineColor = .white //轴颜色
    leftAxis.axisLineWidth = 2 //x轴宽度
    leftAxis.drawTopYLabelEntryEnabled = false
    leftAxis.drawBottomYLabelEntryEnabled = false
    
    //        let targetLine = ChartLimitLine(limit: 250, label: "")
    //        leftAxis.addLimitLine(targetLine)
    //        targetLine.lineColor = .white
    
    chartView1.rightAxis.enabled = false

let set1 = LineChartDataSet(values: dataEntry, label: "DataSet")
set1.axisDependency = .left
set1.setColor(items[index].color) // 折线本身的颜色
set1.setCircleColor(items[index].color) // 拐点颜色
set1.lineWidth = 2
set1.drawCirclesEnabled = true // 是否绘制拐点

        if self.canEdit {
            set1.circleRadius = 6 // 圆的半径
            set1.drawCircleHoleEnabled = true //是否画空心圆
            set1.circleHoleRadius = 4// 空心圆的半径
            set1.circleHoleColor = .white // 空心圆的颜色
        }else {
             set1.circleRadius = 3
            set1.drawCircleHoleEnabled = false
        }
        set1.highlightColor = UIColor(red: 0.84, green: 0.6, blue: 0.38, alpha: 1) //十字线颜色
        set1.highlightLineWidth = 2 //十字线线宽
        set1.highlightLineDashLengths = [4, 2] //使用虚线样式的十字线
        set1.drawVerticalHighlightIndicatorEnabled = true
        set1.drawHorizontalHighlightIndicatorEnabled = true
        set1.highlightEnabled = canEdit
@liuxuan30
Copy link
Member

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants