@gitgraph/js
Draw pretty git graphs with vanilla JS.
This is the vanilla JS rendering library of GitGraph.js.
Get started
You need to have npm installed.
Install the package with npm: npm i --save @gitgraph/js
Now you can use the <GitGraph>
component:
const { createGitgraph } = require("@gitgraph/js");
const graphContainer = document.getElementById("graph-container");
const gitgraph = createGitgraph(graphContainer);
const master = gitgraph.branch("master");
master.commit("Initial commit");
const develop = gitgraph.branch("develop");
develop.commit("Add TypeScript");
const aFeature = gitgraph.branch("a-feature");
aFeature
.commit("Make it work")
.commit("Make it right")
.commit("Make it fast");
develop.merge(aFeature);
develop.commit("Prepare v1");
master.merge(develop).tag("v1.0.0");
This code will render the following graph:
More examples
A bunch of scenarios has been simulated in our Storybook. You can give them a look 👀