mirror of
https://github.com/koodiklinikka/palkkakysely.git
synced 2026-01-26 03:14:03 +00:00
Add React analysaattori
This commit is contained in:
23
analysaattori/.gitignore
vendored
Normal file
23
analysaattori/.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
44
analysaattori/package.json
Normal file
44
analysaattori/package.json
Normal file
@@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "analysaattori",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"homepage": "https://koodiklinikka.github.io/palkkakysely/analysaattori/",
|
||||
"dependencies": {
|
||||
"@types/node": "^14.14.31",
|
||||
"@types/react": "^17.0.2",
|
||||
"@types/react-dom": "^17.0.1",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"react-pivottable": "^0.11.0",
|
||||
"react-plotly.js": "^2.5.1",
|
||||
"react-scripts": "4.0.2",
|
||||
"swr": "^0.4.2",
|
||||
"typescript": "^4.1.5"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
"build": "react-scripts build",
|
||||
"test": "react-scripts test",
|
||||
"eject": "react-scripts eject"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "react-app"
|
||||
},
|
||||
"browserslist": {
|
||||
"production": [
|
||||
">0.2%",
|
||||
"not dead",
|
||||
"not op_mini all",
|
||||
"not ie 11"
|
||||
],
|
||||
"development": [
|
||||
"last 1 chrome version",
|
||||
"last 1 firefox version",
|
||||
"last 1 safari version"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/plotly.js": "^1.54.8",
|
||||
"@types/react-plotly.js": "^2.2.4"
|
||||
}
|
||||
}
|
||||
1
analysaattori/public/.gitignore
vendored
Normal file
1
analysaattori/public/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
data.json
|
||||
BIN
analysaattori/public/favicon.ico
Normal file
BIN
analysaattori/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
15
analysaattori/public/index.html
Normal file
15
analysaattori/public/index.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%PUBLIC_URL%/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>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
<div id="root"></div>
|
||||
</body>
|
||||
</html>
|
||||
36
analysaattori/src/App.tsx
Normal file
36
analysaattori/src/App.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import React from 'react';
|
||||
import PivotTableUI from 'react-pivottable/PivotTableUI';
|
||||
import 'react-pivottable/pivottable.css';
|
||||
import TableRenderers from 'react-pivottable/TableRenderers';
|
||||
import createPlotlyComponent from 'react-plotly.js/factory';
|
||||
import createPlotlyRenderers from 'react-pivottable/PlotlyRenderers';
|
||||
import useSWR from "swr/esm";
|
||||
|
||||
const Plot = createPlotlyComponent(window.Plotly);
|
||||
const PlotlyRenderers = createPlotlyRenderers(Plot);
|
||||
const renderers = Object.assign({}, TableRenderers, PlotlyRenderers);
|
||||
|
||||
|
||||
function App() {
|
||||
const qs = new URLSearchParams(window.location.search);
|
||||
const [pivotState, setPivotState] = React.useState({});
|
||||
const dataSwr = useSWR(qs.get("url") || "/palkkakysely/data.json");
|
||||
if (!dataSwr.data) {
|
||||
if (dataSwr.error) {
|
||||
return <>Virhe ladatessa dataa: {`${dataSwr.error}`}</>;
|
||||
}
|
||||
return <>Ladataan...</>;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
<PivotTableUI
|
||||
data={dataSwr.data}
|
||||
renderers={renderers}
|
||||
onChange={setPivotState}
|
||||
{...pivotState}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default App;
|
||||
10
analysaattori/src/index.tsx
Normal file
10
analysaattori/src/index.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import App from './App';
|
||||
|
||||
ReactDOM.render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
document.getElementById('root')
|
||||
);
|
||||
1
analysaattori/src/react-app-env.d.ts
vendored
Normal file
1
analysaattori/src/react-app-env.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/// <reference types="react-scripts" />
|
||||
3
analysaattori/src/react-pivottable.d.ts
vendored
Normal file
3
analysaattori/src/react-pivottable.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
declare module "react-pivottable/PivotTableUI";
|
||||
declare module "react-pivottable/TableRenderers";
|
||||
declare module "react-pivottable/PlotlyRenderers";
|
||||
26
analysaattori/tsconfig.json
Normal file
26
analysaattori/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"lib": [
|
||||
"dom",
|
||||
"dom.iterable",
|
||||
"esnext"
|
||||
],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx"
|
||||
},
|
||||
"include": [
|
||||
"src"
|
||||
]
|
||||
}
|
||||
11388
analysaattori/yarn.lock
Normal file
11388
analysaattori/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user