Created
January 20, 2018 02:11
-
-
Save pavelvlasov/58738a2526dfaba59369cb3543c4e814 to your computer and use it in GitHub Desktop.
simple nivo component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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