-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
95 additions
and
16 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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import {html} from "../../_npm/[email protected]/_esm.js"; | ||
import * as Inputs from "../../_observablehq/stdlib/inputs.js"; | ||
import * as Plot from "../../_npm/@observablehq/[email protected]/_esm.js"; | ||
|
||
// cluster is the cluster index | ||
export function clusterListCard(clusters, { | ||
heading, | ||
description, | ||
plot, | ||
tableConfig, | ||
da, | ||
scope, | ||
hulls, | ||
}) { | ||
const cda = da.filter(d => clusters.indexOf(d.cluster) >= 0) | ||
const cos = clusters.map(c => scope.cluster_labels_lookup[c]) | ||
return html`<div class="cluster-card grid grid-cols-1"> | ||
<div class="card"> | ||
<h2>${heading}</h2> | ||
<h3>${cda.length} rows</h3> | ||
<div class="cluster-content grid grid-cols-3"> | ||
<div class="cluster-plot"> | ||
${ | ||
Plot.plot({ | ||
marks: [ | ||
Plot.hull(hulls.flatMap(d => d), { | ||
x: "x", | ||
y: "y", | ||
z: "cluster", | ||
// fill: "cluster", | ||
fill: "lightgray", | ||
fillOpacity: 0.1, | ||
stroke: "lightgray", | ||
curve: "catmull-rom", | ||
}), | ||
Plot.hull(hulls.flatMap(d => d), { | ||
filter: d => clusters.indexOf(d.cluster) >= 0, | ||
x: "x", | ||
y: "y", | ||
z: "cluster", | ||
// fill: "cluster", | ||
fill: "orange", | ||
fillOpacity: 0.25, | ||
// stroke: "cluster", | ||
stroke: "orange", | ||
curve: "catmull-rom", | ||
}), | ||
], | ||
width: 300, | ||
height: 300, | ||
color: { scheme: "cool" }, | ||
y: { axis: null}, | ||
x: { axis: null }, | ||
tip: { | ||
format: { | ||
cluster: true, | ||
title: true | ||
} | ||
} | ||
}) | ||
} | ||
</div> | ||
<div class="cluster-description"> | ||
${cos.map(c => html`${c.cluster}: ${c.label}<br>`)} | ||
</div> | ||
<div class="cluster-diagram"> | ||
${plot} | ||
</div> | ||
</div> | ||
<div class="static-table"> | ||
${Inputs.table(cda, tableConfig)} | ||
</div> | ||
</div>` | ||
} | ||
|
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 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 |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
<link rel="modulepreload" href="./_import/components/hull.f981bcf2.js"> | ||
<link rel="modulepreload" href="./_import/components/tooltip.c593267a.js"> | ||
<link rel="modulepreload" href="./_import/components/clusterCard.eba8a284.js"> | ||
<link rel="modulepreload" href="./_import/components/clusterListCard.2bd231cb.js"> | ||
<link rel="modulepreload" href="./_import/components/clusterListCard.c2fe14e1.js"> | ||
<link rel="modulepreload" href="./_node/[email protected]/index.js"> | ||
<link rel="modulepreload" href="./_npm/[email protected]/_esm.js"> | ||
<link rel="modulepreload" href="./_npm/[email protected]/_esm.js"> | ||
|
@@ -506,7 +506,7 @@ | |
}}); | ||
|
||
define({id: "bdbd85b8", outputs: ["scatter","hull","tooltip","clusterCard","clusterListCard","markdownit","min","max","sum"], body: async () => { | ||
const [{scatter}, {hull}, {tooltip}, {clusterCard}, {clusterListCard}, {default: markdownit}, {min, max, sum}] = await Promise.all([import("./_import/components/scatter.e6a504c8.js"), import("./_import/components/hull.f981bcf2.js"), import("./_import/components/tooltip.c593267a.js"), import("./_import/components/clusterCard.eba8a284.js"), import("./_import/components/clusterListCard.2bd231cb.js"), import("./_node/[email protected]/index.js"), import("./_npm/[email protected]/_esm.js")]); | ||
const [{scatter}, {hull}, {tooltip}, {clusterCard}, {clusterListCard}, {default: markdownit}, {min, max, sum}] = await Promise.all([import("./_import/components/scatter.e6a504c8.js"), import("./_import/components/hull.f981bcf2.js"), import("./_import/components/tooltip.c593267a.js"), import("./_import/components/clusterCard.eba8a284.js"), import("./_import/components/clusterListCard.c2fe14e1.js"), import("./_node/[email protected]/index.js"), import("./_npm/[email protected]/_esm.js")]); | ||
|
||
|
||
return {scatter,hull,tooltip,clusterCard,clusterListCard,markdownit,min,max,sum}; | ||
|
@@ -680,6 +680,6 @@ <h2 id="filtering-on-metadata" tabindex="-1"><a class="observablehq-header-ancho | |
</main> | ||
<footer id="observablehq-footer"> | ||
<nav><a rel="prev" href="./plot-issues"><span>GitHub Issues & PRs</span></a><a rel="next" href="./us-federal-laws"><span>US Federal Laws</span></a></nav> | ||
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-05-10T15:08:00">May 10, 2024</a>.</div> | ||
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-05-13T09:35:53">May 13, 2024</a>.</div> | ||
</footer> | ||
</div> |
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 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 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 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 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 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 |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
<link rel="modulepreload" href="./_import/components/dynamicHull.09110e6a.js"> | ||
<link rel="modulepreload" href="./_import/components/tooltip.c593267a.js"> | ||
<link rel="modulepreload" href="./_import/components/clusterCard.eba8a284.js"> | ||
<link rel="modulepreload" href="./_import/components/clusterListCard.2bd231cb.js"> | ||
<link rel="modulepreload" href="./_import/components/clusterListCard.c2fe14e1.js"> | ||
<link rel="modulepreload" href="./_node/[email protected]/index.js"> | ||
<link rel="modulepreload" href="./_npm/[email protected]/_esm.js"> | ||
<link rel="modulepreload" href="./_npm/[email protected]/_esm.js"> | ||
|
@@ -331,13 +331,14 @@ | |
return {civilRights}; | ||
}}); | ||
|
||
define({id: "c042747d", inputs: ["Plot","hulls","civilRights","display"], body: async (Plot,hulls,civilRights,display) => { | ||
define({id: "e64a9588", inputs: ["Plot","hulls","civilRights","display"], body: async (Plot,hulls,civilRights,display) => { | ||
display(await( | ||
Plot.plot({ | ||
marks: [ | ||
Plot.hull(hulls.flatMap(d => d), { | ||
x: "x", | ||
y: "y", | ||
z: "cluster", | ||
fill: "cluster", | ||
fillOpacity: 0.1, | ||
stroke: "lightgray", | ||
|
@@ -347,7 +348,10 @@ | |
Plot.dot(civilRights, { | ||
x: "x", | ||
y: "y", | ||
z: "cluster", | ||
r: 2, | ||
fill: "cluster", | ||
fill: "gray", | ||
title: d => `${d.Title}\n${d.date_of_passage}\n${d.cluster}: ${d.label}`, | ||
tip: true | ||
}), | ||
|
@@ -502,7 +506,7 @@ | |
}}); | ||
|
||
define({id: "bf752053", outputs: ["scatter","hull","dynamicHull","tooltip","clusterCard","clusterListCard","markdownit","select","min","max","sum","mean"], body: async () => { | ||
const [{scatter}, {hull}, {dynamicHull}, {tooltip}, {clusterCard}, {clusterListCard}, {default: markdownit}, {select}, {min, max, sum, mean}] = await Promise.all([import("./_import/components/scatter.e6a504c8.js"), import("./_import/components/hull.f981bcf2.js"), import("./_import/components/dynamicHull.09110e6a.js"), import("./_import/components/tooltip.c593267a.js"), import("./_import/components/clusterCard.eba8a284.js"), import("./_import/components/clusterListCard.2bd231cb.js"), import("./_node/[email protected]/index.js"), import("./_npm/[email protected]/_esm.js"), import("./_npm/[email protected]/_esm.js")]); | ||
const [{scatter}, {hull}, {dynamicHull}, {tooltip}, {clusterCard}, {clusterListCard}, {default: markdownit}, {select}, {min, max, sum, mean}] = await Promise.all([import("./_import/components/scatter.e6a504c8.js"), import("./_import/components/hull.f981bcf2.js"), import("./_import/components/dynamicHull.09110e6a.js"), import("./_import/components/tooltip.c593267a.js"), import("./_import/components/clusterCard.eba8a284.js"), import("./_import/components/clusterListCard.c2fe14e1.js"), import("./_node/[email protected]/index.js"), import("./_npm/[email protected]/_esm.js"), import("./_npm/[email protected]/_esm.js")]); | ||
|
||
|
||
return {scatter,hull,dynamicHull,tooltip,clusterCard,clusterListCard,markdownit,select,min,max,sum,mean}; | ||
|
@@ -695,7 +699,7 @@ <h2 id="civil-rights" tabindex="-1"><a class="observablehq-header-anchor" href=" | |
<p>I wasn't able to identify clusters that related specifically to civil rights, but thanks to the embeddings I was able to use nearest neighbor search to find 150 laws that are related to the concept of civil rights.</p> | ||
<div id="cell-e16e65c2" class="observablehq observablehq--block"></div> | ||
<div class="card"> | ||
<div id="cell-c042747d" class="observablehq observablehq--block observablehq--loading"></div> | ||
<div id="cell-e64a9588" class="observablehq observablehq--block observablehq--loading"></div> | ||
<div class="static-table"> | ||
<span id="cell-60c87720" class="observablehq--loading"></span> | ||
</div> | ||
|
@@ -725,6 +729,6 @@ <h2 id="civil-rights" tabindex="-1"><a class="observablehq-header-anchor" href=" | |
</main> | ||
<footer id="observablehq-footer"> | ||
<nav><a rel="prev" href="./enjalot-tweets"><span>enjalot's tweets</span></a></nav> | ||
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-05-10T15:08:00">May 10, 2024</a>.</div> | ||
<div>Built with <a href="https://observablehq.com/" target="_blank" rel="noopener noreferrer">Observable</a> on <a title="2024-05-13T09:35:53">May 13, 2024</a>.</div> | ||
</footer> | ||
</div> |
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