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 indicesPalette- Defines colors and the strategy used to map counts to colorsContributionGraph- Main builder for generating contribution graphs
§Built-in Components
The builtins module provides:
builtins::Theme- Factory for creating predefined color palettesbuiltins::Strategy- Factory for creating built-in strategy instances- Built-in strategy implementations:
builtins::LinearStrategy,builtins::LogarithmicStrategy,builtins::ThresholdStrategy
§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§
- Contribution
Graph - A builder struct for generating GitHub-style contribution graphs.
- Palette
- Defines the color palette and the strategy used to map counts to colors.
Traits§
- Mapping
Strategy - Defines how to map counts to color indices.