-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH: categories can be an array. Update docs
- Loading branch information
Showing
15 changed files
with
255 additions
and
118 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
TODO* | ||
docs/api.md | ||
node_modules/ | ||
dist/ |
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
This file was deleted.
Oops, something went wrong.
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
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<svg id="sankey" width="800" height="300"></svg> | ||
|
||
<script type="module"> | ||
import { sankey } from "../dist/sankey.js"; | ||
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm"; | ||
|
||
// Load the data | ||
const data = await fetch("sales.json").then(r => r.json()); | ||
|
||
// Create the sankey | ||
const graph = sankey("#sankey", { data, categories: ["channel", "city", "product"], d3 }); | ||
|
||
// Color nodes and links | ||
graph.nodes.attr("fill", d3.scaleOrdinal(d3.schemeCategory10)) | ||
graph.links.attr("fill", "rgba(0,0,0,0.2)"); | ||
</script> |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<svg id="sankey" width="800" height="300"></svg> | ||
|
||
<script type="module"> | ||
import { sankey } from "../dist/sankey.js"; | ||
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm"; | ||
|
||
const data = await fetch("sales.json").then(r => r.json()); | ||
const graph = sankey("#sankey", { data, categories: ["channel", "city", "product"], d3 }); | ||
|
||
// Color nodes and links | ||
const nodeColor = d3.scaleOrdinal([...d3.schemePaired]); | ||
const linkColor = d3.scaleSequential(d3.interpolateBlues).domain(d3.extent(graph.linkData, d => d.size)); | ||
graph.nodes.attr("fill", d => nodeColor(d.key)); | ||
graph.links.attr("fill", d => linkColor(d.size)); | ||
</script> |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" /> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
|
||
<svg id="sankey" width="800" height="300"></svg> | ||
|
||
<script type="module"> | ||
import { sankey } from "../dist/sankey.js"; | ||
import * as d3 from "https://cdn.jsdelivr.net/npm/d3@7/+esm"; | ||
|
||
const data = await fetch("sales.json").then(r => r.json()); | ||
const graph = sankey("#sankey", { data, categories: ["channel", "city", "product"], d3 }); | ||
graph.nodes.attr("fill", d3.scaleOrdinal(d3.schemeCategory10)) | ||
graph.links.attr("fill", "rgba(0,0,0,0.2)"); | ||
|
||
// Add tooltip text | ||
graph.nodes.attr("data-bs-toggle", "tooltip") | ||
.attr("title", (d, i) => `${d.key}: ${d.size.toFixed(2)}`); | ||
graph.links.attr("data-bs-toggle", "tooltip") | ||
.attr("title", (d, i) => `${d.source.key} - ${d.target.key}: ${d.size.toFixed(2)}`); | ||
|
||
// Initialize tooltips | ||
new bootstrap.Tooltip("#sankey", { selector: '[data-bs-toggle="tooltip"]' }); | ||
</script> |
Binary file not shown.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.