iOS折线图突出显示颜色

问题描述 投票:0回答:1

我正在使用charts 3.2.2 iOS版本。我试图绘制折线图。在折线图中,只要用户点击值点,就会显示高亮线。有什么办法可以隐藏或更改此突出显示的线条颜色。我面临的另一个问题是气泡不会出现在第一个条目上。我在网上找到了很多解决方案,但对我没有用。任何帮助将不胜感激。

    scoreLineChart.legend.form = .none
    scoreLineChart.rightAxis.enabled = false

    scoreLineChart.xAxis.labelPosition = .bottom

    scoreLineChart.xAxis.drawGridLinesEnabled = false
    scoreLineChart.dragEnabled = false
    scoreLineChart.doubleTapToZoomEnabled = false

    scoreLineChart.xAxis.granularityEnabled = true
    scoreLineChart.xAxis.granularity = 1.0

    scoreLineChart.leftAxis.axisMinimum = 0
    scoreLineChart.leftAxis.axisMaximum = 100.0
    scoreLineChart.leftAxis.setLabelCount(5, force: true)

    scoreLineChart.xAxis.valueFormatter = valueFormatter
    scoreLineChart.xAxis.avoidFirstLastClippingEnabled = true
    scoreLineChart.pinchZoomEnabled = false
    let marker = BalloonMarker(color: UIColor(hex: "#58595b"),
                               font: UIFont(name: "Avenir-Heavy", size: 14)!,
                               textColor: .white,
                               insets: UIEdgeInsets(top: 8, left: 8, bottom: 20, right: 8))

    marker.chartView = scoreLineChart
    marker.minimumSize = CGSize(width: 80, height: 40)
    scoreLineChart.marker = marker

添加数据条目后

 let setOne = LineChartDataSet(values: lineChartEntry, label: "") //Here we convert lineChartEntry to a LineChartDataSet

    setOne.mode = .cubicBezier
    setOne.drawValuesEnabled = true

    setOne.lineWidth = 1
    setOne.circleRadius = 3
    setOne.drawCircleHoleEnabled = false
    setOne.valueFont = .systemFont(ofSize: 9)
    setOne.formLineWidth = 1
    setOne.formSize = 15

    setOne.setCircleColor(ChartColorTemplates.colorFromString("#ffcc1a29"))

    if !isSingelValue {
        setOne.setColor(ChartColorTemplates.colorFromString("#ffcc1a29"))
    }else {
        setOne.setColor(UIColor.clear)
    }

    let data = LineChartData(dataSet: setOne)

    data.addDataSet(setOne) //Adds the line to the dataSet
    scoreLineChart.xAxis.axisMinimum = 0
    scoreLineChart.data = data //finally - it adds the chart data to the chart and causes an update
    //        scoreLineChart.data?.setValueFormatter(valueFormatter)
    scoreLineChart.chartDescription?.text = "" // Here we set the description for the graph
    scoreLineChart.notifyDataSetChanged()
ios swift ios-charts
1个回答
0
投票

您只需要将drawHorizontalHighlightIndicatorEnabled drawVerticalHighlightIndicatorEnabled设置为false即可隐藏网格线。

    let set1 = ScatterChartDataSet(entries: values1, label: "DS 1")
    set1.drawHorizontalHighlightIndicatorEnabled = false
    set1.drawVerticalHighlightIndicatorEnabled = false
© www.soinside.com 2019 - 2024. All rights reserved.