{"id":3002,"date":"2021-05-27T21:13:55","date_gmt":"2021-05-27T13:13:55","guid":{"rendered":"http:\/\/123.57.164.21\/?p=3002"},"modified":"2021-05-27T21:13:55","modified_gmt":"2021-05-27T13:13:55","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%a318%ef%bc%88%e6%b0%94%e6%b3%a1%e5%9b%be%ef%bc%89","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=3002","title":{"rendered":"Swift &#8211; \u7b2c\u4e09\u65b9\u56fe\u8868\u5e93Charts\u4f7f\u7528\u8be6\u89e318\uff08\u6c14\u6ce1\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-156-1024x578.png\" alt=\"\" class=\"wp-image-3003\" width=\"670\" height=\"378\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-1024x578.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-300x169.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-768x434.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-1536x868.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-830x469.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-230x130.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-350x198.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156-480x271.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-156.png 1590w\" sizes=\"(max-width: 670px) 100vw, 670px\" \/><\/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    \/\/\u6c14\u6ce1\u56fe\n    var chartView: BubbleChartView!\n     \n    override func viewDidLoad() {\n        super.viewDidLoad()\n         \n        \/\/\u521b\u5efa\u6c14\u6ce1\u56fe\u7ec4\u4ef6\u5bf9\u8c61\n        chartView = BubbleChartView()\n        chartView.frame = CGRect(x: 20, y: 80, width: self.view.bounds.width - 40,\n                                 height: 260)\n        self.view.addSubview(chartView)\n         \n        \/\/\u7b2c\u4e00\u7ec4\u6c14\u6ce1\u56fe\u768410\u6761\u968f\u673a\u6570\u636e\n        let dataEntries1 = (0..&lt;10).map { (i) -> ChartDataEntry in\n            let val = Double(arc4random_uniform(100) + 3)\n            let size = CGFloat(arc4random_uniform(10))\n            return BubbleChartDataEntry(x: Double(i), y: val, size: size)\n        }\n        let chartDataSet1 = BubbleChartDataSet(values: dataEntries1, label: \"\u56fe\u4f8b1\")\n \n        \/\/\u7b2c\u4e8c\u7ec4\u6c14\u6ce1\u56fe\u768410\u6761\u968f\u673a\u6570\u636e\n        let dataEntries2 = (0..&lt;10).map { (i) -> ChartDataEntry in\n            let val = Double(arc4random_uniform(100) + 3)\n            let size = CGFloat(arc4random_uniform(10))\n            return BubbleChartDataEntry(x: Double(i), y: val, size: size)\n        }\n        let chartDataSet2 = BubbleChartDataSet(values: dataEntries2, label: \"\u56fe\u4f8b2\")\n        chartDataSet2.setColor(.orange) \/\/\u7b2c\u4e8c\u7ec4\u6c14\u6ce1\u4f7f\u7528\u6a59\u8272\n         \n        \/\/\u76ee\u524d\u6c14\u6ce1\u56fe\u5305\u62ec2\u7ec4\u6570\u636e\n        let chartData = BubbleChartData(dataSets: [chartDataSet1, chartDataSet2])\n         \n        \/\/\u8bbe\u7f6e\u6c14\u6ce1\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-157-1024x596.png\" alt=\"\" class=\"wp-image-3004\" width=\"729\" height=\"423\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-1024x596.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-300x174.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-768x447.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-1536x893.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-830x483.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-230x134.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-350x204.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157-480x279.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-157.png 1592w\" sizes=\"(max-width: 729px) 100vw, 729px\" \/><\/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-158-1024x565.png\" alt=\"\" class=\"wp-image-3005\" width=\"733\" height=\"404\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158-1024x565.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158-300x165.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158-768x424.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158-830x458.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158-230x127.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158-350x193.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158-480x265.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-158.png 1516w\" sizes=\"(max-width: 733px) 100vw, 733px\" \/><\/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=\"\">\/\/\u7b2c\u4e00\u7ec4\u6c14\u6ce1\u56fe\u768410\u6761\u968f\u673a\u6570\u636e\nlet dataEntries1 = (0..&lt;10).map { (i) -> ChartDataEntry in\n    let val = Double(arc4random_uniform(100) + 3)\n    let size = CGFloat(arc4random_uniform(10))\n    \/\/\u53ea\u8981size\u8d85\u8fc77\u7684\u6c14\u6ce1\u90fd\u4f1a\u5e26\u6709\u4e00\u4e2a\u5c0f\u56fe\u6807\n    if size > 7 {\n        return BubbleChartDataEntry(x: Double(i), y: val, size: size,\n                                    icon: UIImage(named: \"icon\"))\n    } else {\n        return BubbleChartDataEntry(x: Double(i), y: val, size: size)\n    }\n}\nlet chartDataSet1 = BubbleChartDataSet(values: dataEntries1, label: \"\u56fe\u4f8b1\")\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-159-1024x553.png\" alt=\"\" class=\"wp-image-3006\" width=\"717\" height=\"387\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-1024x553.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-300x162.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-768x415.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-1536x830.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-830x449.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-230x124.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-350x189.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159-480x259.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-159.png 1558w\" sizes=\"(max-width: 717px) 100vw, 717px\" \/><\/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-160-1024x605.png\" alt=\"\" class=\"wp-image-3007\" width=\"733\" height=\"433\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-1024x605.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-300x177.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-768x454.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-1536x907.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-830x490.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-230x136.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-350x207.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160-480x284.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-160.png 1608w\" sizes=\"(max-width: 733px) 100vw, 733px\" \/><\/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-161-1024x589.png\" alt=\"\" class=\"wp-image-3008\" width=\"682\" height=\"392\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161-1024x589.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161-300x172.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161-768x441.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161-830x477.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161-230x132.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161-350x201.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161-480x276.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2021\/05\/image-161.png 1510w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/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\/3002"}],"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=3002"}],"version-history":[{"count":1,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3002\/revisions"}],"predecessor-version":[{"id":3009,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/3002\/revisions\/3009"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}