在iOS中创建漏斗图?

Sho*_*ari 6 objective-c ios uibezierpath swift

需要为iOS中的漏斗图创建自定义控件(在Swift或Objective - C中).

找到它的少量库:这里是链接:https://github.com/ayudasystems/funnel

计划使用BezierPath实现漏斗图.

请建议需要实现此控件的数据结构.

**注意 - 搜索很多帖子但是dint找到了在ios中实现漏斗图的确切解决方案(很少有帖子但是答案不正确或被接受)

Shr*_*wan 2

在此输入图像描述

您必须使用简单的逻辑来实现上面的漏斗图。

有 5 个项目:A1、A2、A3、A4、A5漏斗高度为200

&& A1=30%,A2=25%,A3=20%,A4=15%,A5=10%

Now distritribute items according to height % in funnel. So

A1 = 0.3*200  = 60
A2 = 0.25*200 = 50
A3 = 0.2*200  = 40
A4 = 0.15*200 = 30
A5 = 0.1*200  = 20
--------------------
Total         = 200


On the basis of above calculated height:- 5 different BezierPath can  be drawn . 

Above data can be generalised to 'n' items and 'x' Height .
Run Code Online (Sandbox Code Playgroud)

计算高度分布的逻辑

class HeightDistribution {
   class func  height(percentages: [Float] , TotalHeight:Float ) -> [Float]  
      {
        var heights = [Float]()
        for percentage in   percentages
        {
           let height = (percentage/100)*TotalHeight
            heights.append(height)
        }
        return heights
    }
}
Run Code Online (Sandbox Code Playgroud)

进度演示漏斗图应用程序 || 斯威夫特3