-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:andy89923/DVVA_Final-Project into main
- Loading branch information
Showing
13 changed files
with
335 additions
and
95 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
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
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,81 @@ | ||
import { useEffect, useRef, useState } from "react"; | ||
import { Chart } from "react-chartjs-2"; | ||
import * as ChartGeo from "chartjs-chart-geo"; | ||
import { | ||
Chart as ChartJS, | ||
CategoryScale, | ||
Tooltip, | ||
Title, | ||
Legend, | ||
} from "chart.js"; | ||
|
||
ChartJS.register( | ||
Title, | ||
Tooltip, | ||
Legend, | ||
CategoryScale, | ||
ChartGeo.ChoroplethController, | ||
ChartGeo.ProjectionScale, | ||
ChartGeo.ColorScale, | ||
ChartGeo.GeoFeature | ||
); | ||
|
||
export default function Map() { | ||
const chartRef = useRef(); | ||
const [countries, setCountries] = useState<any>([]); | ||
|
||
useEffect(() => { | ||
fetch("https://cdn.jsdelivr.net/npm/world-atlas@2/countries-110m.json") | ||
.then((response) => response.json()) | ||
.then((data) => { | ||
setCountries( | ||
ChartGeo.topojson.feature(data, data.objects.countries).features | ||
); | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<Chart | ||
ref={chartRef} | ||
type="choropleth" | ||
data={{ | ||
labels: countries.map((d: any) => d.properties.name), | ||
datasets: [ | ||
{ | ||
outline: countries, | ||
label: "Countries", | ||
data: countries.map((d: any) => ({ | ||
feature: d, | ||
value: Math.random() * 10, | ||
})), | ||
// color from https://mdigi.tools/color-shades/#9417e2 | ||
backgroundColor: [ | ||
"#f5e8fd", | ||
"#e0baf8", | ||
"#cb8bf3", | ||
"#b75def", | ||
"#a22fea", | ||
"#8815d0", | ||
], | ||
}, | ||
], | ||
}} | ||
options={{ | ||
showOutline: true, | ||
showGraticule: false, | ||
plugins: { | ||
legend: { | ||
display: false, | ||
}, | ||
}, | ||
scales: { | ||
projection: { | ||
axis: "x", | ||
projection: "equalEarth", | ||
}, | ||
// Hide color scale | ||
}, | ||
}} | ||
/> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { type NextPage } from "next"; | ||
import Head from "next/head"; | ||
import Link from "next/link"; | ||
import { ForceGraph2D, ForceGraph3D } from "react-force-graph"; | ||
import Navbar from "../../components/Navbar"; | ||
import ZoomCard from "../../components/ZoomCard"; | ||
// import SpriteText from "three-spritetext"; | ||
|
||
import { api } from "../../utils/api"; | ||
import { getKeywordGraph } from "../../utils/relationUtils"; | ||
|
||
const Overview: NextPage = () => { | ||
// const hello = api.example.hello.useQuery({ text: "from tRPC" }); | ||
// const { data: graph } = api.graph.linkRatingBetween.useQuery({ | ||
// minRating: 10, | ||
// maxRating: 10, | ||
// }); | ||
const { data: movies } = api.movie.betweenYearRange.useQuery({ | ||
minYear: 2018, | ||
maxYear: 2020, | ||
}); | ||
|
||
const graph = movies != null ? getKeywordGraph(movies, 0, 50) : null; | ||
|
||
console.log(graph); | ||
|
||
return ( | ||
<> | ||
<Head> | ||
<title>MoVis</title> | ||
<meta | ||
name="description" | ||
content="A Comprehensive Visualization System for The Movies Dataset" | ||
/> | ||
<link rel="icon" href="/favicon.ico" /> | ||
</Head> | ||
<Navbar /> | ||
<main className="flex min-h-screen flex-col items-center bg-gradient-to-b from-[#2e026d] to-[#15162c]"> | ||
<div className="container flex flex-col py-6"> | ||
{graph != null && <ForceGraph3D graphData={graph} />} | ||
{/* <ForceGraph2D graphData={graph} /> */} | ||
</div> | ||
</main> | ||
</> | ||
); | ||
}; | ||
|
||
export default Overview; |
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.