Last active
June 12, 2021 11:17
-
-
Save mrts/392b62b81d51fea3d1bbdcde5fa2dc27 to your computer and use it in GitHub Desktop.
Example of Gitgraph.js usage
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.css" rel="stylesheet"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui"> | |
</head> | |
<body> | |
<p style="margin: 20px"></p> | |
<canvas id="gitGraph" style="padding: 20px"></canvas> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/gitgraph.js/1.11.4/gitgraph.js"></script> | |
<script> | |
function addThreeCommits(branch) { | |
var emptyCommit = {message: ' ', sha1: ' ', author: ' '}; | |
branch | |
.commit(emptyCommit) | |
.commit(emptyCommit) | |
.commit(emptyCommit); | |
} | |
var gitgraph = new GitGraph({ | |
orientation: "horizontal-reverse", | |
template: new GitGraph.Template({branch: {showLabel: true}}) | |
}); | |
var master = gitgraph.branch("master"); | |
addThreeCommits(master); | |
var develop = gitgraph.branch("develop"); | |
addThreeCommits(develop); | |
var feature1 = develop.branch("feature1"); | |
addThreeCommits(feature1); | |
var feature2 = feature1.branch("feature2"); | |
addThreeCommits(feature2); | |
var feature3 = feature2.branch("feature3"); | |
addThreeCommits(feature3); | |
var feature4 = feature2.branch("feature4"); | |
addThreeCommits(feature4); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment