Skip to content

Commit

Permalink
Modernize analysaattori packages (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
akx authored Sep 28, 2023
1 parent ff8f98f commit 2195f66
Show file tree
Hide file tree
Showing 8 changed files with 1,138 additions and 1,138 deletions.
22 changes: 22 additions & 0 deletions analysaattori/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020,
sourceType: "module",
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: "detect",
},
},
extends: [
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"plugin:react/recommended",
"prettier",
],
rules: {},
};
8 changes: 0 additions & 8 deletions analysaattori/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
<meta charset="utf-8" />
<link rel="icon" href="./favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<script
src="https://cdn.plot.ly/plotly-latest.min.js"
charset="utf-8"
></script>
<title>Palkka-analysaattori</title>
</head>
<body>
Expand Down
46 changes: 24 additions & 22 deletions analysaattori/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,33 @@
"private": true,
"homepage": "https://koodiklinikka.github.io/palkkakysely/analysaattori/",
"dependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-pivottable": "^0.11.0",
"react-plotly.js": "^2.5.1",
"swr": "^0.4.2"
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@dnd-kit/utilities": "^3.2.1",
"@imc-trading/react-pivottable": "^0.2.13",
"immutability-helper": "^3.1.1",
"plotly.js-dist": "^2.26.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-plotly.js": "^2.6.0",
"swr": "^2.2.4"
},
"devDependencies": {
"@types/node": "^14.14.31",
"@types/plotly.js": "^1.54.8",
"@types/react-plotly.js": "^2.2.4",
"@types/react": "^17.0.38",
"@types/react-dom": "^17.0.11",
"@typescript-eslint/eslint-plugin": "^5.30.6",
"@typescript-eslint/parser": "^5.30.6",
"@vitejs/plugin-react": "^2.0.0",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.30.1",
"@types/node": "^20.7.1",
"@types/plotly.js": "^2.12.27",
"@types/react": "^18.2.23",
"@types/react-dom": "^18.2.8",
"@types/react-plotly.js": "^2.6.1",
"@typescript-eslint/eslint-plugin": "^6.7.3",
"@typescript-eslint/parser": "^6.7.3",
"@vitejs/plugin-react-swc": "^3.4.0",
"eslint": "^8.50.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^2.7.1",
"typescript": "^4.1.5",
"vite": "^3.0.0"
"prettier": "^3.0.3",
"typescript": "^5.2.2",
"vite": "^4.4.9"
},
"scripts": {
"dev": "vite",
Expand All @@ -34,9 +39,6 @@
"lint": "eslint .",
"prettify": "prettier --write ."
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
Expand Down
28 changes: 19 additions & 9 deletions analysaattori/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
import React from "react";
import PivotTableUI from "react-pivottable/PivotTableUI";
import "react-pivottable/pivottable.css";
import TableRenderers from "react-pivottable/TableRenderers";
import "@imc-trading/react-pivottable/pivottable.css";
import {
PivotTableUI,
TableRenderers,
createPlotlyRenderers,
} from "@imc-trading/react-pivottable";
import createPlotlyComponent from "react-plotly.js/factory";
import createPlotlyRenderers from "react-pivottable/PlotlyRenderers";
import useSWR from "swr/esm";
import Plotly from "plotly.js-dist/plotly";
import useSWR from "swr";

const Plot = createPlotlyComponent(window.Plotly);
const Plot = createPlotlyComponent(Plotly);
const PlotlyRenderers = createPlotlyRenderers(Plot);
const renderers = Object.assign({}, TableRenderers, PlotlyRenderers);

const fetcher = (url: string) => fetch(url).then((res) => res.json());

function App() {
const qs = new URLSearchParams(window.location.search);
const url = qs.get("url") || "/palkkakysely/data.json";
const [pivotState, setPivotState] = React.useState({});
const dataSwr = useSWR(qs.get("url") || "/palkkakysely/data.json");
const dataSwr = useSWR(url, fetcher, { revalidateOnFocus: false });
if (!dataSwr.data) {
if (dataSwr.error) {
return <>Virhe ladatessa dataa: {`${dataSwr.error}`}</>;
return (
<>
Virhe ladatessa dataa {url}: {`${dataSwr.error}`}
</>
);
}
return <>Ladataan...</>;
return <>Ladataan {url}...</>;
}
return (
<div>
Expand Down
7 changes: 4 additions & 3 deletions analysaattori/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from "react";
import ReactDOM from "react-dom";
import { createRoot } from "react-dom/client";
import App from "./App";

ReactDOM.render(
const container = document.getElementById("root");
const root = createRoot(container!);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root"),
);
5 changes: 2 additions & 3 deletions analysaattori/src/react-pivottable.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
declare module "react-pivottable/PivotTableUI";
declare module "react-pivottable/TableRenderers";
declare module "react-pivottable/PlotlyRenderers";
declare module "@imc-trading/react-pivottable";
declare module "plotly.js-dist/plotly";
2 changes: 1 addition & 1 deletion analysaattori/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import react from "@vitejs/plugin-react-swc";

// https://vitejs.dev/config/
export default defineConfig({
Expand Down
Loading

0 comments on commit 2195f66

Please sign in to comment.