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.

§Core Types

  • MappingStrategy - Trait for mapping contribution counts to color indices
  • Palette - Defines colors and the strategy used to map counts to colors
  • ContributionGraph - Main builder for generating contribution graphs

§Built-in Components

The builtins module provides:

§Examples

use contribution_grid::{ContributionGraph, builtins::Theme, builtins::Strategy};
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);

let img = ContributionGraph::new()
    .with_data(data)
    .theme(Theme::blue(Strategy::linear()))
    .generate();

// img.save("graph.png")?;

Modules§

builtins
Built-in themes and strategy factory for the contribution grid library.

Structs§

ContributionGraph
A builder struct for generating GitHub-style contribution graphs.
Palette
Defines the color palette and the strategy used to map counts to colors.

Traits§

MappingStrategy
Defines how to map counts to color indices.