3 Commits
v2021 ... pivot

Author SHA1 Message Date
Aarni Koskela
03f74b3b95 Link analysaattori 2021-02-22 14:55:40 +02:00
Aarni Koskela
7f7b220771 Build analysaattori in GHA 2021-02-22 14:48:06 +02:00
Aarni Koskela
114dc59db7 Add React analysaattori 2021-02-22 14:48:06 +02:00
13 changed files with 11574 additions and 3 deletions

View File

@@ -33,6 +33,26 @@ jobs:
python -m pip install -r requirements.txt
- name: Build
run: make -j3
- uses: actions/setup-node@v2
with:
node-version: '12'
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v2
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- run: yarn
working-directory: analysaattori
- run: yarn build
working-directory: analysaattori
env:
GENERATE_SOURCEMAP: 'false'
- run: cp -a analysaattori/build ./out/analysaattori
- run: ls -laR out
- name: Deploy
uses: JamesIves/github-pages-deploy-action@4.0.0
with:

23
analysaattori/.gitignore vendored Normal file
View 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*

View 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
View File

@@ -0,0 +1 @@
data.json

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View 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
View 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;

View 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
View File

@@ -0,0 +1 @@
/// <reference types="react-scripts" />

View File

@@ -0,0 +1,3 @@
declare module "react-pivottable/PivotTableUI";
declare module "react-pivottable/TableRenderers";
declare module "react-pivottable/PlotlyRenderers";

View 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

File diff suppressed because it is too large Load Diff

View File

@@ -22,18 +22,22 @@
<li>Mediaanivuositulot = {{ num_v.median()|round(0) }} €</li>
{% endwith %}
</ul>
<h2>Lisää</h2>
<h2>Työkalut</h2>
<ul>
<li><a href="charts.html">Kaaviot</a></li>
<li><a href="profiling_report.html">Lähdedatan analyysi</a></li>
<li><a href="analysaattori">Pivot-työkalu</a></li>
</ul>
<h2>Data</h2>
<ul>
<li><a href="data.csv">Lähdedata (CSV)</a></li>
<li><a href="data.html">Lähdedata (HTML)</a></li>
<li><a href="data.json">Lähdedata (JSON)</a></li>
<li><a href="data.xlsx">Lähdedata (XLSX)</a></li>
<li><a href="profiling_report.html">Lähdedatan analyysi</a></li>
<li><a href="raw.tsv">Raakadata (TSV)</a></li>
<li><a href="raw.xlsx">Raakadata (XLSX)</a></li>
</ul>
<h2>Vielä lisää</h2>
<h2>Kysely</h2>
<ul>
<li><a href="http://bit.ly/koodiklinikka-palkkakysely">Vastaa kyselyyn (Google Forms)</a>
<li><a href="http://bit.ly/koodiklinikka-palkkakysely-vastaukset">Vastaukset raakamuodossa (Google Sheets)</a>