{"id":3041,"date":"2021-05-27T21:40:27","date_gmt":"2021-05-27T13:40:27","guid":{"rendered":"http:\/\/123.57.164.21\/?p=3041"},"modified":"2021-05-27T21:40:27","modified_gmt":"2021-05-27T13:40:27","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%a322%ef%bc%88%e9%a5%bc%e7%8a%b6%e5%9b%be2%ef%bc%9a%e6%8c%87%e7%a4%ba%e6%8a%98%e7%ba%bf%e3%80%81","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=3041","title":{"rendered":"Swift &#8211; \u7b2c\u4e09\u65b9\u56fe\u8868\u5e93Charts\u4f7f\u7528\u8be6\u89e322\uff08\u997c\u72b6\u56fe2\uff1a\u6307\u793a\u6298\u7ebf\u3001\u534a\u997c\u56fe\uff09"},"content":{"rendered":"\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-187-1024x724.png\" alt=\"\" class=\"wp-image-3042\" width=\"723\" height=\"510\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-1024x724.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-300x212.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-768x543.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-1536x1086.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-830x587.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-230x163.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-350x248.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187-480x339.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-187.png 1592w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/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    \/\/\u997c\u72b6\u56fe\n    var chartView: PieChartView!\n     \n    override func viewDidLoad() {\n        super.viewDidLoad()\n         \n        \/\/\u521b\u5efa\u997c\u56fe\u7ec4\u4ef6\u5bf9\u8c61\n        chartView = PieChartView()\n        chartView.frame = CGRect(x: 20, y: 80, width: self.view.bounds.width - 40,\n                                 height: 260)\n        self.view.addSubview(chartView)\n         \n        \/\/\u751f\u62105\u6761\u968f\u673a\u6570\u636e\n        let dataEntries = (0..&lt;5).map { (i) -> PieChartDataEntry in\n            return PieChartDataEntry(value: Double(arc4random_uniform(50) + 10),\n                                     label: \"\u6570\u636e\\(i)\")\n        }\n        let chartDataSet = PieChartDataSet(values: dataEntries, label: \"\u6570\u636e\u5206\u5e03\")\n        \/\/\u8bbe\u7f6e\u989c\u8272\n        chartDataSet.colors = ChartColorTemplates.vordiplom()\n            + ChartColorTemplates.joyful()\n            + ChartColorTemplates.colorful()\n            + ChartColorTemplates.liberty()\n            + ChartColorTemplates.pastel()\n         \n        chartDataSet.xValuePosition = .insideSlice \/\/\u6807\u7b7e\u663e\u793a\u5728\u5185\n        chartDataSet.yValuePosition = .outsideSlice \/\/\u6570\u503c\u663e\u793a\u5728\u5916\n         \n        let chartData = PieChartData(dataSet: chartDataSet)\n        chartData.setValueTextColor(.black)\/\/\u6587\u5b57\u989c\u8272\u4e3a\u9ed1\u8272\n         \n        \/\/\u8bbe\u7f6e\u997c\u72b6\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-188-1024x587.png\" alt=\"\" class=\"wp-image-3043\" width=\"743\" height=\"425\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-1024x587.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-300x172.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-768x440.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-1536x881.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-830x476.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-230x132.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-350x201.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188-480x275.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-188.png 1552w\" sizes=\"(max-width: 743px) 100vw, 743px\" \/><\/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-189-1024x589.png\" alt=\"\" class=\"wp-image-3044\" width=\"738\" height=\"424\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-1024x589.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-300x172.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-768x441.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-1536x883.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-830x477.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-230x132.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-350x201.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189-480x276.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-189.png 1552w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/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-190-1024x653.png\" alt=\"\" class=\"wp-image-3045\" width=\"722\" height=\"460\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-1024x653.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-300x191.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-768x490.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-1536x979.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-830x529.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-230x147.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-350x223.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190-480x306.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-190.png 1688w\" sizes=\"(max-width: 722px) 100vw, 722px\" \/><\/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-191-1024x569.png\" alt=\"\" class=\"wp-image-3046\" width=\"731\" height=\"405\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-1024x569.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-300x167.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-768x427.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-1536x854.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-830x461.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-230x128.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-350x195.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191-480x267.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-191.png 1644w\" sizes=\"(max-width: 731px) 100vw, 731px\" \/><\/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    \/\/\u997c\u72b6\u56fe\n    var chartView: PieChartView!\n     \n    override func viewDidLoad() {\n        super.viewDidLoad()\n         \n        \/\/\u521b\u5efa\u997c\u56fe\u7ec4\u4ef6\u5bf9\u8c61\n        chartView = PieChartView()\n        chartView.frame = CGRect(x: 20, y: 80, width: self.view.bounds.width - 40,\n                                 height: 260)\n        self.view.addSubview(chartView)\n         \n        chartView.maxAngle = 270 \/\/\u6574\u4e2a\u6247\u5f62\u53602\/3\u5706\n        chartView.rotationAngle = 135 \/\/\u65cb\u8f6c\u89d2\u5ea6\u8ba9\u6247\u9762\u5de6\u53f3\u5bf9\u79f0\n         \n        \/\/\u751f\u62105\u6761\u968f\u673a\u6570\u636e\n        let dataEntries = (0..&lt;3).map { (i) -> PieChartDataEntry in\n            return PieChartDataEntry(value: Double(arc4random_uniform(50) + 10),\n                                     label: \"\u6570\u636e\\(i)\")\n        }\n        let chartDataSet = PieChartDataSet(values: dataEntries, label: \"\u6570\u636e\u5206\u5e03\")\n        \/\/\u8bbe\u7f6e\u989c\u8272\n        chartDataSet.colors = ChartColorTemplates.colorful()\n        let chartData = PieChartData(dataSet: chartDataSet)\n         \n        \/\/\u8bbe\u7f6e\u997c\u72b6\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-192-1024x482.png\" alt=\"\" class=\"wp-image-3047\" width=\"723\" height=\"340\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-1024x482.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-300x141.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-768x362.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-1536x723.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-830x391.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-230x108.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-350x165.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192-480x226.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-192.png 1538w\" sizes=\"(max-width: 723px) 100vw, 723px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"","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\/3041"}],"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=3041"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3041\/revisions"}],"predecessor-version":[{"id":3048,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3041\/revisions\/3048"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}