Heatmap creation stuff for go.

Overview

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!

Comments
  • Speedup warm()

    Speedup warm()

    • Fill "out" image with transparent pixels in one operation.
    • Calculate "percent" after we determine a pixel should be modified.

    Before:

    $ go test -bench=BenchmarkWarming -benchtime=20s
    PASS
    BenchmarkWarming           5    5019502926 ns/op
    ok      github.com/dustin/go-heatmap    35.382s
    

    After:

    $ go test -bench=BenchmarkWarming -benchtime=20s
    PASS
    BenchmarkWarming          10    3464537436 ns/op
    ok      github.com/dustin/go-heatmap    44.146s
    
    opened by davidreynolds 3
  • [help] Getting a blank image

    [help] Getting a blank image

    I'm trying to print out card values on a 5x5 grid. But before I start doing the actual logic of converting card information to a point I'm trying to get a working scenario.

    I've set the image size to 25x25 and the dot size to 5. The file is created. But seems to be blank. However, if I use the example from the README and write to the same file; it works. So I feel I've just misunderstood something.

    func movesToDataPoints(card Card) []heatmap.DataPoint {
    	return []heatmap.DataPoint{
    		heatmap.P(10, 15),
    	}
    }
    
    func main() {
    	cards := []Card{
    		Rooster, Rabbit,
    	}
    
    	var points []heatmap.DataPoint
    	for _, card := range cards {
    		points = append(points, movesToDataPoints(card)...)
    	}
    
    	img := heatmap.Heatmap(image.Rect(0, 0, 25, 25),
    		points, 5, 128, schemes.Fire)
    
    	if f, err := os.Create("cards-heatmap.png"); err == nil {
    		defer f.Close()
    
    		err = png.Encode(f, img)
    		if err != nil {
    			panic(err)
    		}
    	} else {
    		panic(err)
    	}
    }
    

    https://play.golang.org/p/W3jHMYxTsG7

    opened by andersfylling 2
  • remove dependency to missing imghash library

    remove dependency to missing imghash library

    This PR replaced the imghash library with hash/fnv.

    If I run go mod tidy in my project I get the following error:

    $ go mod tidy
    github.com/markus-wa/demoinfocs-golang/examples/heatmap imports
        github.com/dustin/go-heatmap tested by
        github.com/dustin/go-heatmap.test imports
        github.com/jteeuwen/imghash: git ls-remote -q https://github.com/jteeuwen/imghash in C:\Users\mwalt\go\pkg\mod\cache\vcs\899a7f2d063a36fd4ddfd213140d24b9bce8d21ec528de64aa73ce33841599f9: exit status 128:
        remote: Repository not found.
        fatal: repository 'https://github.com/jteeuwen/imghash/' not found
    

    imghash has been deleted by the owner (along with all his other repositories) a while ago, see https://github.com/jteeuwen/go-bindata/issues/5

    Instead of removing the tests like #5, this PR replaces the library with a custom imgHash() function.

    opened by markus-wa 0
  • Remove tests with dependency on missing library.

    Remove tests with dependency on missing library.

    github.com/jteeuwen/imghash is no longer available on GitHub and so the library is not go-gettable. I have removed these tests and therefore the dependency on this library.

    opened by hscells 0
  • Add option to disable transformations.

    Add option to disable transformations.

    Creating heatmaps to be overlaid on Google Maps requires precisely controlling the projection and scale of plotted points. The transformation feature doesn't fit this use case well so the option to disable it is handy.

    opened by bobobo1618 11
Owner
Dustin Sallings
Dustin Sallings
Go-backend-test - Creating backend stuff & openid connect authentication stuff in golang

Go Backend Coding Practice This is my practice repo to learn about creating back

Pratik Raut 2 Feb 5, 2022
Calendar heatmap inspired by Github contribution activity

Self-contained, plain Go implementation of calendar heatmap inspired by Github contribution activity. $ go build $ echo '{ "2020-05-16": 8, "2

Nikolay Dubina 364 Nov 21, 2022
Gountries provides: Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO-6709) as well as translations, country borders and other stuff exposed as struct data.

gountries Inspired by the countries gem for ruby. Countries (ISO-3166-1), Country Subdivisions(ISO-3166-2), Currencies (ISO 4217), Geo Coordinates(ISO

Pär Karlsson 365 Nov 28, 2022
go.pipeline is a utility library that imitates unix pipeline. It simplifies chaining unix commands (and other stuff) in Go.

go.pipeline go.pipeline is a utility library that imitates unix pipeline. It simplifies chaining unix commands (and other stuff) in Go. Installation g

Song Gao 14 May 8, 2022
Git folder digger, I'm sure it's worthwhile stuff.

Gigger Git folder digger, I'm sure it's worthwhile stuff. Installation Download a prebuilt binary from releases page. or If you have recent go compile

Rıza Sabuncu 37 Nov 9, 2022
Software for archiving my digital stuff like tweets

rsms's memex Software for managing my digital information, like tweets. Usage First check out the source and build. You'll need Make and Go installed.

Rasmus 45 Nov 17, 2022
Terraform provider to help with various AWS automation tasks (mostly all that stuff we cannot accomplish with the official AWS terraform provider)

terraform-provider-awsutils Terraform provider for performing various tasks that cannot be performed with the official AWS Terraform Provider from Has

Cloud Posse 24 Oct 1, 2022
The primary place where Optimism works on stuff related to Optimistic Ethereum

The Optimism Monorepo TL;DR This is the primary place where Optimism works on stuff related to Optimistic Ethereum. Documentation Extensive documentat

Onther Inc. Technology 3 Nov 24, 2022
Make TCP connection storm between server and client for benchmarking network stuff

Make TCP connection storm between server and client for benchmarking network stuff

Masahiro Nagano 2 Nov 14, 2021
🍕 PizzaCoin - cryptocurrency for buying and selling pizza or another stuff

?? PizzaCoin Cryptocurrency for buying and selling pizza or another stuff Installation Compilation Windows go build -o pizzacoin.exe ./cmd/PizzaCoin/m

PizzaNode 1 Nov 21, 2021
Cleo CLI - do annoying stuff faster

Cleo CLI Installing Heroku CLI Most of Heroku functionality relies on Heroku CLI being present in your system. Go ahead and install it if you haven't

Cleo AI 0 Dec 20, 2021
This is a brief tutorial I created for a couple friends to show how to do some stuff in go and ethereum. Feel free to do any PRs with suggestions

golang-tutorial This is a brief tutorial I created for a couple friends to show how to do some stuff in Go and Ethereum. Milestones Create the environ

Nico Cesar 5 Aug 29, 2022
NosTale API for stuff ...

Nos API An API for finding several items in NosTale with the goal of creating damage calculator as frontend to shed some light on actual itemupgrades.

Schattenbrot 0 Dec 9, 2021
Stream processing stuff for Go

GoStream Type safe Stream processing library inspired in the Java Streams API. Table of contents Requirements Usage examples Limitations Performance C

Mario Macias 57 Nov 27, 2022
others implement usefuls stuff in their free time. I implement an eventstore framework

Eventstore eventstore is a library where I try out new stuff related to an eventstore as a single point of truth. At the moment I'm writing this it's

Silvan 6 Nov 10, 2022
A Telegram bot that echoes stuff.

A Telegram bot that echoes stuff.

Shreeyans Bahadkar 2 Jul 15, 2022
MagicSummon - A Terminal Game about Mixing Stuff to summon a MONSTER. Currently The Biggest Project I have worked on.

MagicSummon A Terminal Game about Mixing Stuff to summon a MONSTER that the warriors ALMOST defeated, but the MONSTER fled. Getting Started Clone the

Boat 1 Jan 6, 2022
Kubernetes Stuff

Kubernetes Stuff

Brian 0 Jan 11, 2022
Stuff to make standing up sigstore (esp. for testing) easier for e2e/integration testing.

sigstore-scaffolding This repository contains scaffolding to make standing up a full sigstore stack easier and automatable. Our focus is on running on

Ville Aikas 37 Nov 2, 2022
This is a CLI to help changing and doing stuff in Terraform Cloud.

Terraform Cloud Tool This is a CLI to help changing and doing stuff in Terraform Cloud. Terraform CLI Functions $ terraform-cloud-tool Terraform Cloud

Edson Ribeiro Junior 2 Jul 27, 2022