heatmap

package module
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2022 License: MIT Imports: 10 Imported by: 2

README

This repository contains essential fixes for dustin/go-heatmap, but it is not actively maintained.

dustin/go-heatmap is unfortunately using broken dependencies at this point.

To avoid having to use replace, this repository changed the import path from dustin/go-heatmap to markus-wa/go-heatmap.

All credit goes to @dustin, see LICENSE.

Heatmaps

This is a toolkit for creating heatmaps. Heatmaps are awesome. I use them for a few things, and now you can, too.

There are quite a few things you can do here and they don't all have the high level documentation they deserve currently. You can start by looking at the example to get a feel for what you can do. Basically, feed in a bunch of x,y type data and get back a heatmap. Awesome.

Here's an example from a real-live report:

Northeast US

Colors

Colors are always the hardest part, so I attempted to make it easy by providing three things:

Predefined Color Schemes

gheat has a set of colors that are available by default under the schemes subpackage. You can preview them in their documentation and use them directly.

Drawing Color Schemes

The schemes subpackage also has a tool for generating a color scheme from an image. Given an image that looks like this:

Alpha Fire Scheme

You can use schemes.FromImage("/path/to/file") to load it and use it directly. Colors near the bottom are for sparsely populated areas and colors near the top are for areas that are densely populated.

Computing Color Schemes

You can also compute a color scheme from spec using schemes.Build. This lets you specify starting and ending colors across multiple segments. Fun away!

Documentation

Overview

Package heatmap generates heatmaps for map overlays.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Heatmap

func Heatmap(size image.Rectangle, points []DataPoint, dotSize int, opacity uint8,
	scheme []color.Color) image.Image

Heatmap draws a heatmap.

size is the size of the image to crate dotSize is the impact size of each point on the output opacity is the alpha value (0-255) of the impact of the image overlay scheme is the color palette to choose from the overlay

func KML

func KML(size image.Rectangle, points []DataPoint, dotSize int, opacity uint8,
	scheme []color.Color, imgurl string, out io.Writer) (image.Image, error)

KML generates a heatmap for geographical data and the kml required to render it.

func KMZ

func KMZ(size image.Rectangle, points []DataPoint, dotSize int, opacity uint8,
	scheme []color.Color, out io.Writer) error

KMZ generates a heatmap for geographical data as a kmz.

Types

type DataPoint

type DataPoint interface {
	X() float64
	Y() float64
}

A DataPoint to be plotted. These are all normalized to use the maximum amount of space available in the output image.

func P

func P(x, y float64) DataPoint

P is a shorthand simple datapoint constructor.

Directories

Path Synopsis
examples
Package schemes provides standard color schemes from gheat.
Package schemes provides standard color schemes from gheat.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL