Activity Widget

CodersRank Activity Widget is a web component that allows you easily integrate nice looking activity chart from your CodersRank profile to your personal website:

Install from NPM

The widget script available through NPM:

npm i @codersrank/activity --save

After installation you need to import and register web component:

import CodersRankActivity from '@codersrank/activity';
// register web component as <codersrank-activity> element
window.customElements.define('codersrank-activity', CodersRankActivity);

Install from CDN

Widget can also be downloaded or linked directly from CDN:

<!-- replace x.x.x with actual version -->
<script src=""></script>

In this case it is not required to register web component, it is already registered as <codersrank-activity> element.


As it is a web component the usage is pretty simple, just add widget HTML tag with your CodersRank username

<codersrank-activity username="YOUR_USERNAME"></codersrank-activity>

Widget Attributes

Widget supports following properties as HTML element attributes:

usernamestringYour CodersRank username
weeksnumber52Amount of weeks to be rendered in chart (max 52).
labelsbooleanfalseDisplay chart labels (months and days of the week)
legendbooleanfalseDisplay legend below the chart
tooltipbooleanfalseEnables tooltip with number of activities per day
stepnumber10Number of activities for division by colors
svg-widthnumber800Render width of chart's SVG element
brandingbooleantrueDisplays "Powered by CodersRank" link

For example, to enable labels, legend and tooltip:

<codersrank-activity username="YOUR_USERNAME" labels legend tooltip></codersrank-activity>


It is possible to customize widget colors with CSS Custom Properties (CSS Variables) by setting them directly on the widget element with style attribute or in CSS.

There are following CSS Custom Properties are available:

--font-familyOpen Sans, Helvetica Neue, Helvetica, Arial, sans-serif
--legend-margin1em 0 0 0
--bg-color-1rgba(80, 176, 186, 0.3)
--bg-color-2rgba(80, 176, 186, 0.6)
--bg-color-3rgba(80, 176, 186, 1)

For example, to change legend text color to red and font-size to 10px, add this to CSS stylesheet:

codersrank-activity {
--legend-text-color: red;
--legend-font-size: 10px;


Widget element supports the following events:

errorWill be fired on data request errorevent.detail will contain an error object
dataWill be fired right after data requestevent.detail will contain an object with data and total properties.

total property contains number of total activities

data object contains information about activities by dates

For example:

<codersrank-activity id="activity" ...></codersrank-activity>
function onData(event) {
const total =;
console.log(`${total} activities in the last year`);
document.querySelector('#activity').addEventListener('data', onData);

Use As Image

It is also possible to insert Activity widget as an image. It is useful in places where you can't integrate web component, or for example on your GitHub profile page.

Image URL is the following:

It accepts all widget attributes as query string parameters, plus one extra parameter:

widthnumber800Width of widget element (generated image). Note that generated image has @2x pixel density, so the PNG image will be actually generated in @2x size from the one specified here
stylestringstyle attribute value (here you can specify all CSS variables)

For example:


Note that you need to URL Encode some of the characters, for example # should be %23 and #ff0 color should be specified as %23ff0 in query.


Yes please! See the contributing guidelines for details.


This project is licensed under the terms of the MIT license.