{"id":2831,"date":"2021-05-27T17:15:38","date_gmt":"2021-05-27T09:15:38","guid":{"rendered":"http:\/\/123.57.164.21\/?p=2831"},"modified":"2021-05-27T17:15:38","modified_gmt":"2021-05-27T09:15:38","slug":"swift-%e7%ac%ac%e4%b8%89%e6%96%b9%e5%9b%be%e8%a1%a8%e5%ba%93charts%e4%bd%bf%e7%94%a8%e8%af%a6%e8%a7%a32%ef%bc%88%e6%8a%98%e7%ba%bf%e5%9b%be1%ef%bc%9a%e6%95%b4%e4%bd%93%e6%a0%b7%e5%bc%8f%e8%ae%be","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=2831","title":{"rendered":"Swift &#8211; \u7b2c\u4e09\u65b9\u56fe\u8868\u5e93Charts\u4f7f\u7528\u8be6\u89e32\uff08\u6298\u7ebf\u56fe1\uff1a\u6574\u4f53\u6837\u5f0f\u8bbe\u7f6e\uff09"},"content":{"rendered":"\n<p>\u4e0a\u6587\u6211\u7b80\u5355\u4ecb\u7ecd\u4e86\u4e0b\u6298\u7ebf\u56fe\u7684\u4f7f\u7528\uff0c\u5176\u5b9e\u6298\u7ebf\u56fe\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u65b9\u4fbf\u6211\u4eec\u8fdb\u884c\u4e00\u4e9b\u6837\u5f0f\u7684\u81ea\u5b9a\u4e49\uff0c\u6216\u8005\u8fdb\u884c\u4e00\u4e9b\u4ea4\u4e92\u52a8\u4f5c\u3002\u4e0b\u9762\u901a\u8fc7\u6837\u4f8b\u8fdb\u884c\u6f14\u793a\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/05\/image-35-1024x862.png\" alt=\"\" class=\"wp-image-2832\" width=\"780\" height=\"656\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-1024x862.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-300x252.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-768x646.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-1536x1292.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-830x698.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-230x194.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-350x295.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35-480x404.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-35.png 1602w\" sizes=\"(max-width: 780px) 100vw, 780px\" \/><\/figure><\/div>\n\n\n\n<p>\uff082\uff09\u6837\u4f8b\u4ee3\u7801<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import UIKit\nimport Charts\n \nclass ViewController: UIViewController {\n     \n    \/\/\u6298\u7ebf\u56fe\n    var chartView: LineChartView!\n     \n    override func viewDidLoad() {\n        super.viewDidLoad()\n         \n        \/\/\u521b\u5efa\u6298\u7ebf\u56fe\u7ec4\u4ef6\u5bf9\u8c61\n        chartView = LineChartView()\n        chartView.frame = CGRect(x: 20, y: 80, width: self.view.bounds.width - 40,\n                                 height: 300)\n        self.view.addSubview(chartView)\n         \n        \/\/\u6298\u7ebf\u56fe\u80cc\u666f\u8272\n        chartView.backgroundColor = UIColor.yellow\n         \n        \/\/\u6298\u7ebf\u56fe\u65e0\u6570\u636e\u65f6\u663e\u793a\u7684\u63d0\u793a\u6587\u5b57\n        chartView.noDataText = \"\u6682\u65e0\u6570\u636e\"\n         \n        \/\/\u6298\u7ebf\u56fe\u63cf\u8ff0\u6587\u5b57\u548c\u6837\u5f0f\n        chartView.chartDescription?.text = \"\u8003\u8bd5\u6210\u7ee9\"\n        chartView.chartDescription?.textColor = UIColor.red\n         \n        \/\/\u8bbe\u7f6e\u4ea4\u4e92\u6837\u5f0f\n        chartView.scaleYEnabled = false \/\/\u53d6\u6d88Y\u8f74\u7f29\u653e\n        chartView.doubleTapToZoomEnabled = true \/\/\u53cc\u51fb\u7f29\u653e\n        chartView.dragEnabled = true \/\/\u542f\u7528\u62d6\u52a8\u624b\u52bf\n        chartView.dragDecelerationEnabled = true \/\/\u62d6\u62fd\u540e\u662f\u5426\u6709\u60ef\u6027\u6548\u679c\n        chartView.dragDecelerationFrictionCoef = 0.9 \/\/\u62d6\u62fd\u540e\u60ef\u6027\u6548\u679c\u6469\u64e6\u7cfb\u6570(0~1)\u8d8a\u5c0f\u60ef\u6027\u8d8a\u4e0d\u660e\u663e\n \n        \/\/\u751f\u62108\u6761\u968f\u673a\u6570\u636e\n        var dataEntries = [ChartDataEntry]()\n        for i in 0..&lt;8 {\n            let y = arc4random()%100\n            let entry = ChartDataEntry.init(x: Double(i), y: Double(y))\n            dataEntries.append(entry)\n        }\n        \/\/\u8fd950\u6761\u6570\u636e\u4f5c\u4e3a1\u6839\u6298\u7ebf\u91cc\u7684\u6240\u6709\u6570\u636e\n        let chartDataSet = LineChartDataSet(values: dataEntries, label: \"\u674e\u5b50\u660e\")\n        \/\/\u76ee\u524d\u6298\u7ebf\u56fe\u53ea\u5305\u62ec1\u6839\u6298\u7ebf\n        let chartData = LineChartData(dataSets: [chartDataSet])\n         \n        \/\/\u8bbe\u7f6e\u6298\u73b0\u56fe\u6570\u636e\n        chartView.data = chartData\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/05\/image-36-1024x701.png\" alt=\"\" class=\"wp-image-2834\" width=\"797\" height=\"546\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36-1024x701.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36-300x205.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36-768x526.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36-830x568.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36-230x157.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36-350x240.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36-480x329.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-36.png 1402w\" sizes=\"(max-width: 797px) 100vw, 797px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/05\/image-37-1024x641.png\" alt=\"\" class=\"wp-image-2835\" width=\"783\" height=\"489\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37-1024x641.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37-300x188.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37-768x481.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37-1536x962.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37-230x144.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37-350x219.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37-480x301.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-37.png 1632w\" sizes=\"(max-width: 783px) 100vw, 783px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/05\/image-38-1024x660.png\" alt=\"\" class=\"wp-image-2836\" width=\"761\" height=\"490\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-1024x660.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-300x193.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-768x495.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-1536x990.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-830x535.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-230x148.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-350x226.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38-480x309.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-38.png 1604w\" sizes=\"(max-width: 761px) 100vw, 761px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/05\/image-39-1024x569.png\" alt=\"\" class=\"wp-image-2837\" width=\"777\" height=\"431\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39-1024x569.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39-300x167.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39-768x427.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39-830x461.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39-230x128.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39-350x195.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39-480x267.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-39.png 1382w\" sizes=\"(max-width: 777px) 100vw, 777px\" \/><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/05\/image-40-1024x131.png\" alt=\"\" class=\"wp-image-2838\" width=\"794\" height=\"101\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-1024x131.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-300x38.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-768x98.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-1536x196.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-830x106.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-230x29.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-350x45.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40-480x61.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-40.png 1676w\" sizes=\"(max-width: 794px) 100vw, 794px\" \/><\/figure><\/div>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import UIKit\nimport Charts\n \nclass ViewController: UIViewController {\n     \n    \/\/\u6298\u7ebf\u56fe\n    var chartView: LineChartView!\n     \n    override func viewDidLoad() {\n        super.viewDidLoad()\n         \n        \/\/\u521b\u5efa\u6298\u7ebf\u56fe\u7ec4\u4ef6\u5bf9\u8c61\n        chartView = LineChartView()\n        chartView.frame = CGRect(x: 20, y: 80, width: self.view.bounds.width - 40,\n                                 height: 300)\n        self.view.addSubview(chartView)\n         \n        \/\/\u751f\u6210\u7b2c\u4e00\u6761\u6298\u7ebf\u6570\u636e\n        var dataEntries1 = [ChartDataEntry]()\n        for i in 0..&lt;8 {\n            let y = arc4random()%100\n            let entry = ChartDataEntry.init(x: Double(i), y: Double(y))\n            dataEntries1.append(entry)\n        }\n        let chartDataSet1 = LineChartDataSet(values: dataEntries1, label: \"\u674e\u5b50\u660e\")\n         \n        \/\/\u751f\u6210\u7b2c\u4e8c\u6761\u6298\u7ebf\u6570\u636e\n        var dataEntries2 = [ChartDataEntry]()\n        for i in 0..&lt;8 {\n            let y = arc4random()%100\n            let entry = ChartDataEntry.init(x: Double(i), y: Double(y))\n            dataEntries2.append(entry)\n        }\n        let chartDataSet2 = LineChartDataSet(values: dataEntries2, label: \"\u738b\u5927\u9524\")\n         \n        \/\/\u76ee\u524d\u6298\u7ebf\u56fe\u5305\u62ec2\u6839\u6298\u7ebf\n        let chartData = LineChartData(dataSets: [chartDataSet1, chartDataSet2])\n         \n        \/\/\u8bbe\u7f6e\u6298\u73b0\u56fe\u6570\u636e\n        chartView.data = chartData\n    }\n}<\/pre>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2021\/05\/image-41-1024x578.png\" alt=\"\" class=\"wp-image-2841\" width=\"734\" height=\"414\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-1024x578.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-300x169.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-768x434.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-1536x868.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-830x469.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-230x130.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-350x198.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41-480x271.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-41.png 1604w\" sizes=\"(max-width: 734px) 100vw, 734px\" \/><\/figure><\/div>\n\n\n\n<p>\u8f6c\u8f7d\u4e8e\uff1ahttps:\/\/www.hangge.com\/blog\/cache\/detail_2117.html<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u6587\u6211\u7b80\u5355\u4ecb\u7ecd\u4e86\u4e0b\u6298\u7ebf\u56fe\u7684\u4f7f\u7528\uff0c\u5176\u5b9e\u6298\u7ebf\u56fe\u8fd8\u63d0\u4f9b\u4e86\u8bb8\u591a\u5c5e\u6027\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u65b9\u4fbf\u6211\u4eec\u8fdb\u884c\u4e00\u4e9b\u6837\u5f0f\u7684\u81ea\u5b9a\u4e49\uff0c\u6216\u8005\u8fdb\u884c\u4e00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,8],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2831"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2831"}],"version-history":[{"count":5,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2831\/revisions"}],"predecessor-version":[{"id":2843,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/2831\/revisions\/2843"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2831"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2831"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2831"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}