Skip to content

sangriel/SMHeatMapView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SMHeatMapView

CI Status Version License Platform

Example

Alt text

Alt text

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

no delegates or callbacks it just return UIImage? right away

import SMHeatMapView

//processHeatmap image
image.image = SMHeatMapView().processHeatMapImage(point: points,
                                                  gridSize: CGSize(width: 200, height: 200),
                                                  ranges: [0, 0.1, 0.25 , 0.5 ,0.75, 1],
                                                  colors: [Color0,
                                                           Color1,
                                                           Color2,
                                                           Color3,
                                                           Color4,
                                                           Color5
                                                       ])

WeightCustomization

this part of code is responsible for calculating heatmap weight

customize as your own taste

for y in 0..<Int(gridSize.height) {
    for x in 0..<Int(gridSize.width)  {
        var totalWeight : CGFloat = 0
        for innerpoints in inputs {
            let distance = CGPoint(x: x, y: y).distance(to: innerpoints)
            //dropout weights for distance longer than radius
            totalWeight += max(0, (radius - distance)  )
        }
        //normalize weight to 0 ~ 1
        weight[x][y] = totalWeight / CGFloat(inputs.count)
        
    }
}

Installation

SMHeatMapView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SMHeatMapView'

Author

sangriel, [email protected]

License

SMHeatMapView is available under the MIT license. See the LICENSE file for more info.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published