pub struct ContributionGraph { /* private fields */ }Expand description
A builder struct for generating GitHub-style contribution graphs.
Implementations§
Source§impl ContributionGraph
impl ContributionGraph
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ContributionGraph builder with default settings.
Sourcepub fn with_data(self, data: HashMap<NaiveDate, u32>) -> Self
pub fn with_data(self, data: HashMap<NaiveDate, u32>) -> Self
Sets the contribution data for the graph.
The data is a mapping from NaiveDate to a contribution count (u32).
Sourcepub fn start_date(self, date: NaiveDate) -> Self
pub fn start_date(self, date: NaiveDate) -> Self
Sets the start date for the graph.
If not provided, it defaults to the earliest date in the data or January 1st of the current year.
Sourcepub fn end_date(self, date: NaiveDate) -> Self
pub fn end_date(self, date: NaiveDate) -> Self
Sets the end date for the graph.
If not provided, it defaults to the latest date in the data or December 31st of the current year.
Sourcepub fn theme(self, palette: Palette) -> Self
pub fn theme(self, palette: Palette) -> Self
Sets a predefined or custom Palette.
§Example
use contribution_grid::{ContributionGraph, Theme, LinearStrategy, Palette, ThresholdStrategy};
use image::Rgba;
// Using a built-in theme
let graph = ContributionGraph::new()
.theme(Theme::github(LinearStrategy));
// Using a custom palette with thresholds
let custom_palette = Palette::new(
vec![
Rgba([20, 20, 20, 255]),
Rgba([0, 255, 0, 255]),
Rgba([0, 0, 255, 255]),
],
ThresholdStrategy::new(vec![1, 10])
);
let graph = ContributionGraph::new()
.theme(custom_palette);Sourcepub fn background_color(self, color: Rgba<u8>) -> Self
pub fn background_color(self, color: Rgba<u8>) -> Self
Sets the background color of the image.
Sourcepub fn round_corners(self, round: bool) -> Self
pub fn round_corners(self, round: bool) -> Self
Sets whether the contribution boxes should have rounded corners.
Sourcepub fn calculate_date_range(&self) -> (NaiveDate, NaiveDate)
pub fn calculate_date_range(&self) -> (NaiveDate, NaiveDate)
Calculates the effective start and end dates for the graph.
Sourcepub fn calculate_dimensions(
&self,
start: NaiveDate,
end: NaiveDate,
) -> (u32, u32)
pub fn calculate_dimensions( &self, start: NaiveDate, end: NaiveDate, ) -> (u32, u32)
Calculates the dimensions (width, height) of the resulting image.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContributionGraph
impl !RefUnwindSafe for ContributionGraph
impl !Send for ContributionGraph
impl !Sync for ContributionGraph
impl Unpin for ContributionGraph
impl !UnwindSafe for ContributionGraph
Blanket Implementations§
Source§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Source§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Source§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Source§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Source§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Source§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Source§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Source§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.