Convert Figma logo to code with AI

sallar logogithub-contributions-chart

:octocat: Generate an image of all your Github contributions

5,210
239
5,210
19

Top Related Projects

4,336

📮 Untangle your GitHub Notifications

8,892

🤖 A framework for building GitHub Apps to automate and improve your workflow

3,043

Bring your code to the conversations you care about with the GitHub and Slack integration

Quick Overview

The github-contributions-chart project is a JavaScript library that generates an image of a user's GitHub contributions chart. It can be used to display a user's contribution history on a website or in other applications.

Pros

  • Customizable: The library provides a wide range of options for customizing the appearance of the generated chart, including colors, font, and layout.
  • Easy to use: The library has a simple API that makes it easy to integrate into a project.
  • Responsive: The generated chart is designed to be responsive and can adapt to different screen sizes.
  • Open-source: The project is open-source and available on GitHub, allowing developers to contribute to its development and customize it as needed.

Cons

  • Dependency on external services: The library relies on the GitHub API to fetch the user's contribution data, which means that it may be subject to rate limiting and other API-related issues.
  • Limited functionality: The library is focused on generating a single type of chart (the GitHub contributions chart), and may not be suitable for more complex data visualization needs.
  • Potential performance issues: Generating the chart can be resource-intensive, especially for users with a large number of contributions, which may impact the performance of the application.
  • Lack of documentation: The project's documentation could be more comprehensive, making it harder for new users to get started.

Code Examples

Here are a few examples of how to use the github-contributions-chart library:

import GitHubContributionsChart from 'github-contributions-chart';

// Create a new chart instance
const chart = new GitHubContributionsChart({
  username: 'sallar',
  selector: '#contributions-chart',
  year: 2022,
});

// Render the chart
chart.render();

This code creates a new GitHubContributionsChart instance, configures it with the username and the year to display, and then renders the chart to the specified DOM element.

// Customize the chart appearance
const chart = new GitHubContributionsChart({
  username: 'sallar',
  selector: '#contributions-chart',
  year: 2022,
  color: '#7289da',
  fontFamily: 'Roboto, sans-serif',
  fontSize: 12,
  square: {
    size: 15,
    margin: 2,
  },
});

chart.render();

This example demonstrates how to customize the appearance of the chart by setting various options, such as the color, font family, font size, and the size and margin of the contribution squares.

// Handle chart events
const chart = new GitHubContributionsChart({
  username: 'sallar',
  selector: '#contributions-chart',
  year: 2022,
});

chart.on('click', (data) => {
  console.log('Clicked on contribution:', data);
});

chart.on('hover', (data) => {
  console.log('Hovered over contribution:', data);
});

chart.render();

This code shows how to listen for events, such as clicks and hovers, on the generated chart and handle them in your application.

Getting Started

To use the github-contributions-chart library in your project, follow these steps:

  1. Install the library using npm or yarn:
npm install github-contributions-chart
  1. Import the library and create a new GitHubContributionsChart instance:
import GitHubContributionsChart from 'github-contributions-chart';

const chart = new GitHubContributionsChart({
  username: 'sallar',
  selector: '#contributions-chart',
  year: 2022,
});
  1. Render the chart:
chart.render();
  1. Customize the chart's appearance and behavior as needed:
chart.options.color = '#7289da';
chart.options.fontFamily = 'Roboto, sans-serif';
chart.options.fontSize = 12;

chart.on('click', (data) => {
  console.log('Clicked on contribution:', data);
});

That's it! You can now use the github-contributions-chart library to display a user's GitHub contributions

Competitor Comparisons

4,336

📮 Untangle your GitHub Notifications

Pros of Octobox

  • Octobox provides a web-based interface for managing GitHub notifications, making it easier to stay on top of your notifications.
  • Octobox supports features like filtering, starring, and archiving notifications, which can help you better organize and prioritize your work.
  • Octobox integrates with various third-party services, such as Slack and Microsoft Teams, allowing you to receive notifications in your preferred communication channels.

Cons of Octobox

  • Octobox requires you to host the application yourself, which may not be suitable for users who prefer a hosted solution.
  • Octobox may have a steeper learning curve compared to simpler GitHub notification management tools.
  • Octobox may not be as visually appealing or customizable as some other GitHub-related tools.

Code Comparison

Here's a brief code comparison between Octobox and GitHub Contributions Chart:

Octobox (Ruby on Rails):

class NotificationsController < ApplicationController
  def index
    @notifications = current_user.notifications.includes(:subject)
    @notifications = @notifications.filter_by_status(params[:status]) if params[:status].present?
    @notifications = @notifications.filter_by_reason(params[:reason]) if params[:reason].present?
    @notifications = @notifications.filter_by_type(params[:type]) if params[:type].present?
    @notifications = @notifications.order(updated_at: :desc).page(params[:page])
  end
end

GitHub Contributions Chart (JavaScript):

function getContributionData(username) {
  return fetch(`https://github-contributions-api.now.sh/v1/${username}`)
    .then(response => response.json())
    .then(data => data.contributions);
}

function renderContributionChart(data) {
  const canvas = document.getElementById('contributions-chart');
  const chart = new ContributionsChart(canvas, data);
  chart.render();
}
8,892

🤖 A framework for building GitHub Apps to automate and improve your workflow

Pros of Probot

  • Probot provides a framework for building GitHub Apps, which can automate and extend the functionality of GitHub repositories.
  • Probot includes a set of built-in plugins that can be easily integrated into your GitHub App, such as issue labeling, pull request merging, and more.
  • Probot's modular design allows for easy customization and extension of its functionality to fit your specific needs.

Cons of Probot

  • Probot has a steeper learning curve compared to the GitHub Contributions Chart, as it requires understanding the GitHub App ecosystem and Probot's specific API.
  • Probot may be overkill for simple use cases that can be easily handled by the GitHub Contributions Chart.

Code Comparison

GitHub Contributions Chart:

const contributions = await fetchContributions(username);
const chart = new ContributionsChart(contributions);
chart.render();

Probot:

module.exports = (app) => {
  app.on('issues.opened', async (context) => {
    const issueComment = context.issue({ body: 'Thanks for opening this issue!' });
    await context.octokit.issues.createComment(issueComment);
  });
};
3,043

Bring your code to the conversations you care about with the GitHub and Slack integration

Pros of Slack Integrations

  • Provides a wide range of pre-built integrations for popular tools and services, making it easier to connect Slack with other applications.
  • Offers a comprehensive API and developer documentation, allowing for custom integrations to be built.
  • Supports various types of integrations, including incoming webhooks, slash commands, and interactive components.

Cons of Slack Integrations

  • The repository is primarily focused on providing integrations, rather than a specific tool or application like GitHub Contributions Chart.
  • The codebase may be more complex and less approachable for developers who are not familiar with Slack's integration ecosystem.
  • The repository does not provide a single, standalone application that can be easily deployed or used independently.

Code Comparison

GitHub Contributions Chart:

function getContributionData(username) {
  return fetch(`https://github-contributions-api.now.sh/v1/${username}`)
    .then(response => response.json())
    .then(data => data.contributions);
}

function renderContributionChart(data) {
  const canvas = document.getElementById('github-contributions');
  const ctx = canvas.getContext('2d');

  // Render the contribution chart
  // ...
}

Slack Integrations:

const { App } = require('@slack/bolt');

const app = new App({
  token: process.env.SLACK_BOT_TOKEN,
  signingSecret: process.env.SLACK_SIGNING_SECRET
});

app.message('hello', async ({ message, say }) => {
  await say(`Hey there <@${message.user}>!`);
});

(async () => {
  await app.start(process.env.PORT || 3000);
  console.log('⚡️ Bolt app is running!');
})();

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

:octocat: GitHub Contribution Chart Generator GitHub license

Generates an image of all your GitHub contributions since you have signed up, so you can use it in social media.

The API for this project lives in the src/pages/api directory since GitHub doesn't provide a way to access user statistics through it's official API.

The drawing mechanism lives in the sallar/github-contributions-canvas repository.

Requirements

  • A valid github account.
  • Open activity in setting (Settings > Public profile > Contributions & Activity).
    • Make profile private and hide activity

Install

Install the packages using NPM:

$ npm install

How to run

Running locally:

$ npm run dev

Deployment

This project is deployed on Vercel.

Adding themes

Add your theme to sallar/github-contribution-canvas repo and also send a PR here to add the name of the theme to the list.

Example

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Changelog

Every release, along with the migration instructions, is documented on the GitHub Releases page.

License

MIT license

Powered by Vercel