commit 189f7a72c650e2073e98d0ea2a3df3ac3078c278 Author: gman Date: Tue Feb 25 19:07:26 2025 +0300 first commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a547bf3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/README.md b/README.md new file mode 100644 index 0000000..74872fd --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# React + TypeScript + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh + +## Expanding the ESLint configuration + +If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: + +- Configure the top-level `parserOptions` property like this: + +```js +export default tseslint.config({ + languageOptions: { + // other options... + parserOptions: { + project: ['./tsconfig.node.json', './tsconfig.app.json'], + tsconfigRootDir: import.meta.dirname, + }, + }, +}) +``` + +- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked` +- Optionally add `...tseslint.configs.stylisticTypeChecked` +- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config: + +```js +// eslint.config.js +import react from 'eslint-plugin-react' + +export default tseslint.config({ + // Set the react version + settings: { react: { version: '18.3' } }, + plugins: { + // Add the react plugin + react, + }, + rules: { + // other rules... + // Enable its recommended rules + ...react.configs.recommended.rules, + ...react.configs['jsx-runtime'].rules, + }, +}) +``` diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..092408a --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,28 @@ +import js from '@eslint/js' +import globals from 'globals' +import reactHooks from 'eslint-plugin-react-hooks' +import reactRefresh from 'eslint-plugin-react-refresh' +import tseslint from 'typescript-eslint' + +export default tseslint.config( + { ignores: ['dist'] }, + { + extends: [js.configs.recommended, ...tseslint.configs.recommended], + files: ['**/*.{ts,tsx}'], + languageOptions: { + ecmaVersion: 2020, + globals: globals.browser, + }, + plugins: { + 'react-hooks': reactHooks, + 'react-refresh': reactRefresh, + }, + rules: { + ...reactHooks.configs.recommended.rules, + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, + }, +) diff --git a/index.html b/index.html new file mode 100644 index 0000000..e4b78ea --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 0000000..a72ad98 --- /dev/null +++ b/package.json @@ -0,0 +1,41 @@ +{ + "name": "demo", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint .", + "preview": "vite preview" + }, + "dependencies": { + "@loaders.gl/core": "^4.3.3", + "@loaders.gl/csv": "^4.3.3", + "@loaders.gl/parquet": "^4.3.3", + "@tanstack/react-query": "^5.66.7", + "@tanstack/react-query-devtools": "^5.66.7", + "@types/d3": "^7.4.3", + "antd": "^5.24.0", + "d3-scale": "^4.0.2", + "d3-scale-chromatic": "^3.1.0", + "deck.gl": "^9.1.1", + "maplibre-gl": "^5.1.0", + "react": "^19.0.0", + "react-dom": "^19.0.0", + "react-map-gl": "^8.0.1" + }, + "devDependencies": { + "@eslint/js": "^9.19.0", + "@types/react": "^19.0.8", + "@types/react-dom": "^19.0.3", + "@vitejs/plugin-react": "^4.3.4", + "eslint": "^9.19.0", + "eslint-plugin-react-hooks": "^5.0.0", + "eslint-plugin-react-refresh": "^0.4.18", + "globals": "^15.14.0", + "typescript": "~5.7.2", + "typescript-eslint": "^8.22.0", + "vite": "^6.1.0" + } +} diff --git a/public/2023-12-01.csv.gz b/public/2023-12-01.csv.gz new file mode 100644 index 0000000..c410a36 Binary files /dev/null and b/public/2023-12-01.csv.gz differ diff --git a/public/2023-12-02.csv.gz b/public/2023-12-02.csv.gz new file mode 100644 index 0000000..c410a36 Binary files /dev/null and b/public/2023-12-02.csv.gz differ diff --git a/src/App.tsx b/src/App.tsx new file mode 100644 index 0000000..115bb82 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,111 @@ +import { load } from '@loaders.gl/core'; +import { CSVLoader } from '@loaders.gl/csv'; +import { useQuery } from '@tanstack/react-query'; +import { Select, Slider, Space, Spin } from 'antd'; +import { scaleLinear } from 'd3-scale'; +import { interpolateViridis } from 'd3-scale-chromatic'; +import { DeckGL, GridCellLayer, ScatterplotLayer } from 'deck.gl'; +import 'maplibre-gl/dist/maplibre-gl.css'; +import { useState } from 'react'; +import Map from 'react-map-gl/maplibre'; + +const colorScale = scaleLinear().domain([0, 10000]).range([interpolateViridis(0), interpolateViridis(1)]); +const radiusScale = scaleLinear().domain([0, 12000]).range([50, 250]); + +function App() { + const [value, setValue] = useState(0); + const [attr, setAttr] = useState("00:00:00"); + const [day, setDay] = useState("2023-12-01") + + const { isPending, error, data } = useQuery({ + queryKey: [day], + queryFn: () => load(`./${day}.csv.gz`, CSVLoader, { csv: {} }), + }) + + const layers = [ + new ScatterplotLayer({ + id: 'deckgl-circle', + data: [ + { position: [0.45, 51.47] } + ], + getPosition: d => d.position, + getFillColor: [255, 0, 0, 100], + getRadius: 1000, + }), + new GridCellLayer({ + id: 'deckgl-grid', + //@ts-ignore + data: isPending ? [] : data.data, + getPosition: d => [d.x, d.y], + //@ts-ignore + getFillColor: d => colorScale(d[attr]).slice(4, -1).split(", ").map(Number), + cellSize: 505, + extruded: false, + updateTriggers: { + getFillColor: [attr], + } + }), + new ScatterplotLayer({ + id: 'deckgl-circle2', + //@ts-ignore + // data: isPending ? [] : data.data, + getPosition: d => [d.x, d.y], + //@ts-ignore + getFillColor: d => colorScale(d[attr]).slice(4, -1).split(", ").map(Number), + getRadius: d => radiusScale(d[attr]), + updateTriggers: { + getFillColor: [attr], + getRadius: [attr] + } + }), + ]; + + return ( + <> + + + + + +