Skip to content

Instantly share code, notes, and snippets.

@adammark
Last active July 10, 2017 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adammark/0a31e67735bbb9e64ec300a5b3ef1882 to your computer and use it in GitHub Desktop.
Save adammark/0a31e67735bbb9e64ec300a5b3ef1882 to your computer and use it in GitHub Desktop.
var Bubble = function (props) {
var {
percent = 0, // a number between 0 and 1, inclusive
size = 20, // the width and height of the bubble
color = "#0078bc", // the fill color
label = null // a label to describe the contents (for accessibility)
} = props;
var c = size / 2;
var r = Math.sqrt(Math.pow(c, 2) * percent);
return (
<svg width={size} height={size} aria-label={label} data-tooltip={label}>
<circle cx={c} cy={c} r={c} fill="#ddd"/>
<circle cx={c} cy={c} r={r} fill={color}/>
</svg>
);
};
module.exports = Bubble;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment