diff --git a/app/page.tsx b/app/page.tsx
index 4687db0..48714fb 100644
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -4,6 +4,7 @@ import {RadarChart} from '../components/charts/radar'
import {EmpireStats} from '../components/tables/empires'
import { Checkbox } from '@nextui-org/react';
import { PopChart } from '@/components/charts/pops';
+import { EthicsBar } from '../components/charts/ethicsBar';
export default function Home() {
const [weighted, setWeighted] = useState(true);
@@ -15,7 +16,10 @@ export default function Home() {
setWeighted(!weighted)}>Weighted Ethics
-
+
diff --git a/components/charts/ethicsBar.tsx b/components/charts/ethicsBar.tsx
new file mode 100644
index 0000000..3d0e5ca
--- /dev/null
+++ b/components/charts/ethicsBar.tsx
@@ -0,0 +1,122 @@
+'use client';
+import useSWR from "swr";
+import { Chart as ChartJS, registerables } from 'chart.js';
+import { Bar } from "react-chartjs-2";
+import { Ethics, EthicsDataG15, Species } from '../../types/stellaris';
+import { number } from "prop-types";
+
+const fetcher = async (url:any) => await fetch(url).then((res) => res.json());
+
+export const EthicsBar = () => {
+ const {data: tmpData} = useSWR('/api/ethics',fetcher);
+ const {data: empData} = useSWR('/api/empires',fetcher);
+
+ const parseData = (data: Array>) => {
+ let parsedData: EthicsDataG15[] = new Array;
+ Object.keys(Ethics).forEach((ethic: number | string) => {
+ if (Number.isInteger(Number(ethic))) {
+ parsedData[Number(ethic)] = new EthicsDataG15(data[Number(ethic)])
+ }
+ });
+ return parsedData;
+ }
+
+ let ethicsData: EthicsDataG15[];
+ let data;
+ let empireCount = 0;
+ let scaleLimit = 0;
+
+ if (tmpData && empData) {
+ let sheetData = tmpData.sheetData
+ ethicsData = parseData(sheetData);
+
+ empireCount = empData.empireCount;
+
+ let sumArray = new Array;
+ let labelArray = new Array;
+
+ ethicsData.forEach((ethicData, index) => {
+ sumArray[index] = ethicData.sum(false);
+ labelArray[index] = Ethics[index]
+ });
+
+ let zipped: Array<{sums: number, labels: string}> = [];
+ for (let i = 0; i (a.sums > b.sums ? -1 : 1));
+
+ for (let i = 0; i
+
+
+ );
+}
\ No newline at end of file