Skip to main content

Crate contribution_grid

Crate contribution_grid 

Source
Expand description

A library for generating GitHub-style contribution graphs.

This crate provides a builder interface to create contribution heatmaps, similar to those found on GitHub user profiles. It supports custom date ranges, colors, and dimensions, outputting the result as an image.

§Examples

use contribution_grid::{ContributionGraph, Theme, LinearStrategy};
use chrono::NaiveDate;
use std::collections::HashMap;

let mut data = HashMap::new();
data.insert(NaiveDate::from_ymd_opt(2023, 1, 1).unwrap(), 5);
data.insert(NaiveDate::from_ymd_opt(2023, 1, 2).unwrap(), 12);

// Use a built-in theme with a linear mapping strategy
let img = ContributionGraph::new()
    .with_data(data)
    .theme(Theme::blue(LinearStrategy))
    .generate();

// img is an ImageBuffer from the `image` crate
// img.save("graph.png")?;

Structs§

ContributionGraph
A builder struct for generating GitHub-style contribution graphs.
LinearStrategy
Linear percentile-based mapping.
LogarithmicStrategy
Logarithmic mapping (emphasizes differences at lower values).
Palette
Defines the color palette and the strategy used to map counts to colors.
Theme
Helper for built-in color themes.
ThresholdStrategy
Fixed threshold mapping (ignores max_count).

Traits§

MappingStrategy
Defines how to map counts to color indices.