0.9.21 • Published 3 years ago

@codersrank/skills-chart v0.9.21

Weekly downloads
141
License
MIT
Repository
github
Last release
3 years ago

CodersRank Skills Chart Widget

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

Install from NPM

Widget script available through NPM:

npm i @codersrank/skills-chart --save

After installation you need to import and register web component:

import CodersRankSkillsChart from '@codersrank/skills-chart';

// register web component as <codersrank-skills-chart> element
window.customElements.define('codersrank-skills-chart', CodersRankSkillsChart);

Install from CDN

Widget can also be downloaded or linked directly from CDN:

<!-- replace x.x.x with actual version -->
<script src="https://unpkg.com/@codersrank/skills-chart@x.x.x/codersrank-skills-chart.min.js"></script>

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

Usage

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

<codersrank-skills-chart username="YOUR_USERNAME"></codersrank-skills-chart>

Widget Attributes

Widget supports following properties as HTML element attributes:

NameTypeDefaultDescription
usernamestringYour CodersRank username
labelsbooleanfalseDisplay chart labels (chart axis with dates)
legendbooleanfalseDisplay legend below the chart
tooltipbooleanfalseEnables tooltip with number of activities per day
skillsstringAllows to specify skills to display in chart. For example skills="JavaScript, Vue, CSS"
active-skillsstringAllows to specify skills to be active by default (all skills not specified here will appear as disabled). For example active-skills="JavaScript, Vue"
svg-widthnumber640Render width of chart's SVG element. Ideally should match actual chart width
svg-heightnumber320Render height of chart's SVG element. Ideally should match actual chart height
show-other-skillsbooleanfalseGroup skills not specified in skills property under the "Other" chart area
max-labelsnumber8Maximum amount of labels (dates) to be displayed (dates)
brandingbooleantrueDisplays "Powered by CodersRank" link
sort-by-scorebooleanfalseSorts labels by score if true or alphabetically

For example, to enable labels, legend and tooltip:

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

Styling

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:

PropertyValue
--font-familyOpen Sans, Helvetica Neue, Helvetica, Arial, sans-serif
--svg-width100%
--svg-heightauto
--axis-bg-colorrgba(0, 0, 0, 0.35)
--hidden-area-color#ddd
--label-text-colorinherit
--label-font-size10px
--label-font-weight500
--label-white-spacenowrap
--legend-text-colorinherit
--legend-disabled-text-color#ccc
--legend-font-size14px
--preloader-color#72a0a8
--tooltip-font-size12px
--tooltip-total-font-size16px
--tooltip-total-font-weightbold
--other-skills-area-color#bbb
--chart-bg-colortransparent
--chart-border-radius0px
--branding-text-colorinherit

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

codersrank-skills-chart {
  --legend-text-color: red;
  --legend-font-size: 12px;
}

Events

Widget element supports the following events:

For example:

<codersrank-skills-chart id="skills-chart" skils="..."></codersrank-skills-chart>
function onData(event) {
  const highest = event.detail.highest;
  console.log(`Highest score was ${highest.score} on ${highest.date}`);
}
document.querySelector('#skills-chart').addEventListener('data', onData);

Use As Image

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

Image URL is the following:

https://cr-skills-chart-widget.azurewebsites.net/api/api?username=YOUR_USERNAME

It accepts query parameters:

NameTypeDefaultDescription
usernamestringYour CodersRank username
skillsstringSpecify skills to display in chart (comma separated), for example ?skills=JavaScript,TypeScript
widthnumber640Render width of chart's SVG element. Ideally should match actual chart width
heightnumber320Render height of chart's SVG element. Ideally should match actual chart height
show-other-skillsbooleanfalseGroup skills not specified in skills property under the "Other" chart area
bgstring#fffChart background image
paddingnumber0Image content padding

For example:

<img
  src="https://cr-skills-chart-widget.azurewebsites.net/api/api?username=YOUR_USERNAME&skills=JavaScript,TypeScript&show-other-skills=true"
/>

Live example:

<img
  src="https://cr-skills-chart-widget.azurewebsites.net/api/api?username=nolimits4web&skills=Vue,C%2B%2B,C%23,SCSS,Svelte&width=820"
/>

Note that you need to URL Encode some of the characters, for example C++ should be C%2B%2B and C# should be C%23

Contribution

Yes please! See the contributing guidelines for details.

Licence

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

0.9.21

3 years ago

0.9.20

3 years ago

0.9.19

3 years ago

0.9.17

3 years ago

0.9.18

3 years ago

0.9.16

3 years ago

0.9.14

3 years ago

0.9.15

3 years ago

0.9.13

3 years ago

0.9.12

3 years ago

0.9.11

3 years ago

0.9.10

3 years ago

0.9.8

3 years ago

0.9.7

3 years ago

0.9.9

3 years ago

0.9.6

4 years ago

0.9.5

4 years ago

0.9.4

4 years ago

0.9.3

4 years ago

0.9.2

4 years ago

0.9.1

4 years ago