Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #4 #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
</a>
</p>

clocviz is a command line tool used to analyze a target codebase and render interactive visualizations; users can traverse the file tree with a simple mouse click and see statistics including lines by file, lines by language, percentage composition per language, etc.
clocviz is a command-line tool used to analyze a target codebase and render interactive visualizations; users can traverse the file tree with a simple mouse click and see statistics including lines by file, lines by language, percentage composition per language, etc.

clocviz is primarily written in Go, using the language's templates and web server capabilities to reduce dependencies. Visualizations are performed through D3.js and vanilla HTML/CSS/JS.

Expand Down
89 changes: 47 additions & 42 deletions src/static/index.tmpl
Original file line number Diff line number Diff line change
@@ -1,63 +1,68 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/sunburst-chart"></script>
<link rel="stylesheet" href="/src/static/styles.css">
<title>clocviz</title>
</head>
<body>
<header>clocviz</header>

<main>
<div class="card">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/sunburst-chart"></script>
<link rel="stylesheet" href="/src/static/styles.css">
<title>clocviz</title>
</head>

<body>
<header>clocviz</header>


<main>
<div class="card">
<h1>Chart</h1>
<div class="container">
<div id="chart">
<script>
function testFunc() {
console.log("Hi");
console.log("Hi");
}
const data = {
{
.ByLang
}
}
const data = {{.ByLang}}
const myChart = Sunburst()
.width(800) /* Make chart size occupy % of width */
.height(1000)
.size("size")
.excludeRoot(true)
.showLabels(true)
.data(data)
.onClick((node) => {
myChart.focusOnNode(node);
wrapper("statsList", node);
})
.color("color")(document.getElementById("chart"));
.width(800) /* Make chart size occupy % of width */
.height(1000)
.size("size")
.excludeRoot(true)
.showLabels(true)
.data(data)
.onClick((node) => {
myChart.focusOnNode(node);
wrapper("statsList", node);
})
.color("color")(document.getElementById("chart"));
</script>
</div>
</div>
</div>
</main>
</div>
</main>

<div id="right">
<div class="card">
<div id="right">
<div class="card">
<h2>Legend</h2>
<ul id="legend">
</ul>
</div>
</div>
</div>

<div id="left">
<div class="card">
<h2>File structure
<div style="display: float; float: right">Lines of code</div>
</h2>
<ul id="statsList"></ul>
</div>
<div id="left">
<div class="card">
<h2>File structure
<div style="display: float; float: right">Lines of code</div>
</h2>
<ul id="statsList"></ul>
</div>
</body>
</div>
</body>

<script src="/src/static/script.js"></script>

<script src="/src/static/script.js"></script>
</html>
11 changes: 6 additions & 5 deletions src/static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const languages = data.children.map((child) => child.name);

languages.forEach(
(language) =>
(document.getElementById(
"legend"
).innerHTML += `<li><div class="box ${language}"></div> ${language}</li>`)
(document.getElementById(
"legend"
).innerHTML += `<li><div class="box ${language}"></div> ${language}</li>`)
);

data.children.forEach((child) =>
Expand All @@ -33,10 +33,11 @@ function clear(id) {

function populateStats(node, parent = "statsList") {
if (!node.hasOwnProperty("children")) {
document.getElementById(parent).innerHTML += `<li>${node.name}
document.getElementById(parent).innerHTML += `<li>${node.name}
<div style="display: float; float: right; padding-right: 2em; color: ${node.color}; font-weight: bold">${node.size}</div></li>`;
console.log(node.name, node.size);
} else {
}
else {
let nestedId = `li_${node.name}`;
document.getElementById(parent).innerHTML += `
<li>/<b>${node.name}</b></li>
Expand Down