iOS图表,波浪线 [英] iOS Charts, wavy lines

查看:389
本文介绍了iOS图表,波浪线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们直截了当地:我开始使用Daniel Gindi的iOS图表,但我无法在折线图中复制此波浪线

Let's get straight to the point: I started to use iOS Charts by Daniel Gindi, but I just can't reproduce this wavy lines in my line chart

(并且请注意,此图像是从iOS图表存储库中选取的!)

(and please notice that this image is picked form the repository of iOS charts!)

我所得到的就是没有曲线的简单直线

All I get is just this, simple straight lines with no curves

这是我用来显示该代码的viewDidLoad中的代码:

And this is the code in viewDidLoad that I used for showing that:

    let ys1 = Array(1..<10).map { x in return sin(Double(x) / 2.0 / 3.141 * 1.5) }
    let ys2 = Array(1..<10).map { x in return cos(Double(x) / 2.0 / 3.141) }

    let yse1 = ys1.enumerated().map { x, y in return ChartDataEntry(x: Double(x), y: y) }
    let yse2 = ys2.enumerated().map { x, y in return ChartDataEntry(x: Double(x), y: y) }

    let data = LineChartData()
    let ds1 = LineChartDataSet(values: yse1, label: "Hello")
    ds1.colors = [NSUIColor.red]
    ds1.drawCirclesEnabled = false
    ds1.drawValuesEnabled = false
    data.addDataSet(ds1)

    let ds2 = LineChartDataSet(values: yse2, label: "World")
    ds2.colors = [NSUIColor.blue]
    ds2.drawCirclesEnabled = false
    ds2.drawValuesEnabled = false
    data.addDataSet(ds2)
    self.viewChart.data = data

    self.viewChart.gridBackgroundColor = NSUIColor.white

    self.viewChart.chartDescription?.text = "Linechart Demo"

有人可以帮助我吗?谢谢!

Can someone help me? Thank you!

推荐答案

请检查此内容:

let ds1 = LineChartDataSet(values: yse1, label: "Hello")
ds1.colors = [NSUIColor.red]
ds1.drawCirclesEnabled = false
ds1.drawValuesEnabled = false
ds1.mode = .cubicBezier // add this line
data.addDataSet(ds1)

let ds2 = LineChartDataSet(values: yse2, label: "World")
ds2.colors = [NSUIColor.blue]
ds2.drawCirclesEnabled = false
ds2.drawValuesEnabled = false
ds2.mode = .cubicBezier // add this line
data.addDataSet(ds2)

这篇关于iOS图表,波浪线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆