Skip to content

Instantly share code, notes, and snippets.

@pavelvlasov
Created January 20, 2018 02:11
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 pavelvlasov/58738a2526dfaba59369cb3543c4e814 to your computer and use it in GitHub Desktop.
Save pavelvlasov/58738a2526dfaba59369cb3543c4e814 to your computer and use it in GitHub Desktop.
simple nivo component
import { Bar as NBar } from "@nivo/bar";
import * as React from "react";
import { render } from "react-dom";
interface Item {
author: string;
added: number;
deleted: number;
changed: number;
}
type Data = Item[];
const colors = {
added: "#97e3d5",
changed: "#f1e15b",
deleted: "#f47560"
};
interface Options {
animate?: boolean;
}
interface Node {
id: "added" | "changed" | "deleted";
}
export const Bars = (props: { data: Data; options?: Options }) => {
const data = props.data;
const options = props.options || {};
return (
<NBar
width={600}
height={300}
data={data}
keys={["deleted", "changed", "added"]}
indexBy="author"
... another props
/>
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment