├── .eslintignore ├── .eslintrc.js ├── .github ├── dependabot.yml └── workflows │ └── test.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .prettierignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── babel.config.js ├── commitlint.config.js ├── jest.config.js ├── lerna.json ├── package.json ├── packages ├── react-vega-demo │ ├── .storybook │ │ ├── addons.js │ │ ├── config.js │ │ └── webpack.config.js │ ├── package.json │ └── stories │ │ ├── ChangingDimensionDemo.tsx │ │ ├── ReactVegaDemo.tsx │ │ ├── ReactVegaLiteDemo.tsx │ │ ├── dimensions.stories.tsx │ │ ├── index.stories.tsx │ │ ├── style.css │ │ ├── vega │ │ ├── data1.json │ │ ├── spec1.ts │ │ └── spec2.ts │ │ └── vegaLiteWithLayers.stories.tsx ├── react-vega-lite │ ├── CHANGELOG.md │ └── README.md └── react-vega │ ├── README.md │ ├── package.json │ ├── src │ ├── Vega.tsx │ ├── VegaEmbed.tsx │ ├── VegaLite.tsx │ ├── constants.ts │ ├── createClassFromSpec.tsx │ ├── index.ts │ ├── types │ │ ├── index.ts │ │ └── reExport.ts │ └── utils │ │ ├── addSignalListenersToView.ts │ │ ├── combineSpecWithDimension.ts │ │ ├── computeSpecChanges.ts │ │ ├── getDatasetNamesFromSpec.ts │ │ ├── getUniqueFieldNames.ts │ │ ├── isFunction.ts │ │ ├── removeSignalListenersFromView.ts │ │ ├── shallowEqual.ts │ │ ├── updateMultipleDatasetsInView.ts │ │ └── updateSingleDatasetInView.ts │ ├── test │ ├── Vega.test.tsx │ ├── VegaLite.test.tsx │ ├── createClassFromSpec.test.tsx │ ├── index.test.ts │ ├── mock │ │ └── vegaLiteSpec.ts │ ├── tsconfig.json │ └── utils │ │ ├── combineSpecWithDimension.test.ts │ │ ├── getDatasetNamesFromSpec.test.ts │ │ ├── getUniqueFieldNames.test.ts │ │ ├── isFunction.test.ts │ │ └── shallowEqual.test.ts │ └── tsconfig.json ├── prettier.config.js ├── scripts └── tsc.sh ├── tsconfig.json ├── tsconfig.options.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | coverage/ 2 | node_modules/ 3 | public/ 4 | esm/ 5 | lib/ 6 | tmp/ 7 | dist/ 8 | temporary-plugins/ 9 | storybook-static/ 10 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@babel/eslint-parser', 4 | parserOptions: { 5 | ecmaFeatures: { 6 | experimentalObjectRestSpread: true, 7 | }, 8 | }, 9 | extends: ['airbnb', 'prettier', 'prettier/react', 'plugin:react-hooks/recommended'], 10 | plugins: ['babel', 'compat', 'promise', 'prettier', 'react'], 11 | env: { browser: true }, 12 | globals: { __DEV__: true }, 13 | settings: { 14 | polyfills: ['promises'], 15 | 'import/extensions': ['.js', '.jsx', '.ts', '.tsx', '.json'], 16 | 'import/resolver': { 17 | webpack: {}, 18 | node: { extensions: ['.js', '.jsx', '.ts', '.tsx', '.json'] }, 19 | }, 20 | react: { version: 'detect' }, 21 | }, 22 | rules: { 23 | camelcase: ['error', { allow: ['^UNSAFE_'], properties: 'never' }], 24 | curly: 2, 25 | 'import/extensions': [ 26 | 'error', 27 | { 28 | '.js': 'always', 29 | '.jsx': 'always', 30 | '.ts': 'always', 31 | '.tsx': 'always', 32 | '.json': 'always', 33 | }, 34 | ], 35 | 'prefer-object-spread': 1, 36 | 'prefer-destructuring': ['error', { object: true, array: false }], 37 | 'prettier/prettier': 'error', 38 | }, 39 | overrides: [ 40 | { 41 | files: ['*.ts', '*.tsx'], 42 | parser: '@typescript-eslint/parser', 43 | extends: [ 44 | 'airbnb', 45 | 'plugin:@typescript-eslint/recommended', 46 | 'prettier', 47 | 'prettier/@typescript-eslint', 48 | 'prettier/react', 49 | ], 50 | plugins: ['@typescript-eslint/eslint-plugin', 'prettier', 'react'], 51 | rules: { 52 | '@typescript-eslint/ban-ts-ignore': 0, 53 | '@typescript-eslint/ban-ts-comment': 0, 54 | '@typescript-eslint/ban-types': 0, 55 | '@typescript-eslint/no-empty-function': 0, 56 | '@typescript-eslint/no-use-before-define': 1, 57 | '@typescript-eslint/no-non-null-assertion': 0, 58 | '@typescript-eslint/explicit-function-return-type': 0, 59 | '@typescript-eslint/no-explicit-any': ['warn', { fixToUnknown: false }], 60 | '@typescript-eslint/no-unused-vars': ['error', { ignoreRestSiblings: true }], 61 | 'import/extensions': [ 62 | 'error', 63 | { 64 | '.ts': 'always', 65 | '.tsx': 'always', 66 | '.json': 'always', 67 | }, 68 | ], 69 | 'no-use-before-define': 0, 70 | 'prettier/prettier': 'error', 71 | 'react/destructuring-assignment': 0, 72 | 'react/jsx-filename-extension': [1, { extensions: ['.jsx', '.tsx'] }], 73 | 'react/jsx-fragments': 1, 74 | 'react/jsx-no-bind': 0, 75 | 'react/jsx-no-literals': 'off', 76 | 'react/jsx-props-no-spreading': 0, 77 | 'react/require-default-props': 0, 78 | 'react/sort-comp': 0, 79 | 'react/static-property-placement': 0, 80 | }, 81 | settings: { 82 | 'import/resolver': { 83 | webpack: {}, 84 | typescript: {}, 85 | }, 86 | react: { version: 'detect' }, 87 | }, 88 | }, 89 | // STORYBOOK 90 | { 91 | files: ['*.stories.jsx', '*.stories.tsx', 'commitlint.config.js'], 92 | rules: { 93 | // this is to keep eslint from complaining about storybook addons, 94 | // since they are included as dev dependencies rather than direct dependencies. 95 | 'import/no-extraneous-dependencies': ['error', { devDependencies: true }], 96 | }, 97 | }, 98 | // TYPE DECLARATIONS 99 | { 100 | files: ['*.d.ts'], 101 | rules: { 102 | 'max-classes-per-file': 0, 103 | }, 104 | }, 105 | // UNIT TESTS 106 | { 107 | files: ['*.test.ts', '*.test.tsx', '*.test.js', '*.test.jsx', 'fixtures.*'], 108 | plugins: ['jest', 'jest-dom', 'no-only-tests', 'testing-library'], 109 | env: { 'jest/globals': true }, 110 | extends: ['plugin:jest/recommended', 'plugin:testing-library/react'], 111 | rules: { 112 | // This is to keep eslint from complaining about @testing-library imports, 113 | // since they are included as dev dependencies rather than direct dependencies. 114 | 'import/no-extraneous-dependencies': 0, 115 | // Accessing container and nodes let us verify if vega renders svg correctly. 116 | 'testing-library/no-container': 0, 117 | 'testing-library/no-node-access': 0, 118 | }, 119 | }, 120 | // CONFIG FILES 121 | { 122 | files: ['webpack*.js', '.*rc.js', '*.config.js'], 123 | env: { node: true }, 124 | settings: { 125 | 'import/resolver': { 126 | node: {}, 127 | }, 128 | }, 129 | }, 130 | ], 131 | }; 132 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: npm 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | day: sunday 8 | time: "23:00" 9 | timezone: PST8PDT 10 | open-pull-requests-limit: 10 11 | - package-ecosystem: github-actions 12 | directory: "/" 13 | schedule: 14 | interval: monthly 15 | day: sunday 16 | time: "23:00" 17 | timezone: PST8PDT 18 | open-pull-requests-limit: 10 19 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Build and test 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | 15 | - name: Use Node.js 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: 16.10 19 | cache: 'yarn' 20 | - name: Install dependencies 21 | run: yarn install 22 | - name: Build 23 | run: yarn build 24 | - name: Test 25 | run: yarn test 26 | - name: Upload coverage to Codecov 27 | uses: codecov/codecov-action@v3.1.0 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Runtime data 2 | pids 3 | *.pid 4 | *.seed 5 | 6 | # Directory for instrumented libs generated by jscoverage/JSCover 7 | lib-cov 8 | 9 | # node-waf configuration 10 | .lock-wscript 11 | 12 | # Misc 13 | .env 14 | Dockerfile 15 | docker-compose.yml 16 | 17 | .DS_Store 18 | *.DS_Store 19 | *.sublime-workspace 20 | 21 | # Logs 22 | logs/ 23 | *.log 24 | *.tsbuildinfo 25 | 26 | # Cache 27 | tmp 28 | .publish 29 | .sass-cache 30 | .bundle/ 31 | .happo/ 32 | .idea/ 33 | .next/ 34 | .cache 35 | .eslintcache 36 | .idea 37 | .npm 38 | .vscode 39 | .yarnclean 40 | 41 | # Directories 42 | build/ 43 | coverage/ 44 | dist/ 45 | esm/ 46 | lib/ 47 | public/ 48 | node_modules/ 49 | tmp/ 50 | 51 | # Custom 52 | *.map 53 | *.min.js 54 | test-changelog.md 55 | 56 | # Lock files, libs should not have lock files 57 | npm-shrinkwrap.json 58 | package-lock.json 59 | 60 | # Storybook output 61 | storybook-static 62 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn commitlint --edit "$1" 5 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | yarn lint-staged 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | _gh-pages/ 2 | coverage/ 3 | node_modules/ 4 | public/ 5 | esm/ 6 | lib/ 7 | tmp/ 8 | dist/ 9 | lerna.json 10 | npm-shrinkwrap.json 11 | package.json 12 | package-lock.json 13 | tsconfig.json 14 | tsconfig.options.json 15 | tsconfig.eslint.json 16 | CHANGELOG.md 17 | *.geojson 18 | *-topo.json 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # [7.5.0](https://github.com/vega/react-vega/compare/v7.4.4...v7.5.0) (2022-04-07) 2 | 3 | 4 | ### Features 5 | 6 | * add containerRef param to onError ([#439](https://github.com/vega/react-vega/issues/439)) ([9e4ab17](https://github.com/vega/react-vega/commit/9e4ab178d8226614b34a20a2e0a10a0e5a0e6e16)) 7 | 8 | 9 | 10 | ## [7.4.4](https://github.com/vega/react-vega/compare/v7.4.3...v7.4.4) (2021-08-27) 11 | 12 | 13 | ### Bug Fixes 14 | 15 | * call embed finalize instead of view ([#421](https://github.com/vega/react-vega/issues/421)) ([20efe38](https://github.com/vega/react-vega/commit/20efe3844df09d754938382e981070f340f2c972)) 16 | 17 | 18 | 19 | ## [7.4.3](https://github.com/vega/react-vega/compare/v7.4.2...v7.4.3) (2021-05-01) 20 | 21 | 22 | ### Features 23 | 24 | * support react 17 ([#354](https://github.com/vega/react-vega/issues/354)) ([4843a7f](https://github.com/vega/react-vega/commit/4843a7ff54e4099e180c25b56554fb2d511ff4e8)) 25 | 26 | 27 | 28 | ## [7.4.2](https://github.com/vega/react-vega/compare/v7.4.1...v7.4.2) (2020-11-10) 29 | 30 | 31 | 32 | ## [7.4.1](https://github.com/vega/react-vega/compare/v7.4.0...v7.4.1) (2020-07-28) 33 | 34 | 35 | ### Bug Fixes 36 | 37 | * reexport types ([dd4f409](https://github.com/vega/react-vega/commit/dd4f409952a4799905163b01c7e75b377c077072)) 38 | 39 | 40 | 41 | # [7.4.0](https://github.com/vega/react-vega/compare/v7.3.0...v7.4.0) (2020-07-20) 42 | 43 | 44 | ### Features 45 | 46 | * export types ([#242](https://github.com/vega/react-vega/issues/242)) ([5baea7c](https://github.com/vega/react-vega/commit/5baea7c424fa77ffdc9967e38f645f44756b42a0)) 47 | 48 | 49 | 50 | # [7.3.0](https://github.com/vega/react-vega/compare/v7.2.1...v7.3.0) (2020-03-22) 51 | 52 | 53 | ### Features 54 | 55 | * support top-level width and height ([#144](https://github.com/vega/react-vega/issues/144)) ([1d75bc3](https://github.com/vega/react-vega/commit/1d75bc3abf743ae4fd43b17e4c0c12884e50b05a)) 56 | 57 | 58 | 59 | ## [7.2.1](https://github.com/vega/react-vega/compare/v7.2.0...v7.2.1) (2020-02-12) 60 | 61 | 62 | 63 | # [7.2.0](https://github.com/vega/react-vega/compare/v7.1.2...v7.2.0) (2020-02-06) 64 | 65 | 66 | ### Features 67 | 68 | * avoid creating new view when only width or height in spec changes ([#95](https://github.com/vega/react-vega/issues/95)) ([d4a87e7](https://github.com/vega/react-vega/commit/d4a87e785d795e1cf3f08a77c36ee6fefcb2d995)) 69 | 70 | 71 | 72 | ## [7.1.2](https://github.com/vega/react-vega/compare/v7.1.1...v7.1.2) (2020-02-05) 73 | 74 | 75 | ### Bug Fixes 76 | 77 | * autosize fail sometimes([#78](https://github.com/vega/react-vega/issues/78)) ([#80](https://github.com/vega/react-vega/issues/80)) ([f580611](https://github.com/vega/react-vega/commit/f580611101bc898bb2ce70936c82776c5f3b2d84)) 78 | * demo ([dc32f61](https://github.com/vega/react-vega/commit/dc32f61f4027b492c3403385003ba58e1430527a)) 79 | * replace any type with unknown ([#93](https://github.com/vega/react-vega/issues/93)) ([0f16622](https://github.com/vega/react-vega/commit/0f16622aadcdcc949188bf967abe97dc3bc3e0f8)) 80 | * use chaining ([1d78394](https://github.com/vega/react-vega/commit/1d783943963f4212f82a38e971a594c873fb6503)) 81 | 82 | 83 | 84 | ## [7.1.1](https://github.com/vega/react-vega/compare/v7.1.0...v7.1.1) (2019-11-19) 85 | 86 | 87 | 88 | # [7.1.0](https://github.com/vega/react-vega/compare/v7.0.1...v7.1.0) (2019-10-18) 89 | 90 | 91 | ### Features 92 | 93 | * add data support for layer ([#66](https://github.com/vega/react-vega/issues/66)) ([b63e3ae](https://github.com/vega/react-vega/commit/b63e3ae9ee800b5c48f9a1d8d442d58bed1bbf3d)) 94 | 95 | 96 | 97 | ## [7.0.1](https://github.com/vega/react-vega/compare/v7.0.0...v7.0.1) (2019-09-25) 98 | 99 | 100 | ### Bug Fixes 101 | 102 | * return type of onError ([#62](https://github.com/vega/react-vega/issues/62)) ([8980bc4](https://github.com/vega/react-vega/commit/8980bc4fbe94d0e125be8609206de04f949e593e)) 103 | 104 | 105 | ### Features 106 | 107 | * optimize data update ([#61](https://github.com/vega/react-vega/issues/61)) ([8e1baab](https://github.com/vega/react-vega/commit/8e1baab35bb29b0e5903d452a7ed1db2a7046ee6)) 108 | 109 | 110 | 111 | # [7.0.0](https://github.com/vega/react-vega/compare/v7.0.0-alpha.0...v7.0.0) (2019-09-20) 112 | 113 | 114 | ### Bug Fixes 115 | 116 | * list of dependencies in package.json ([#57](https://github.com/vega/react-vega/issues/57)) ([d15659a](https://github.com/vega/react-vega/commit/d15659a6199620b5846654fb7047fd216e283125)) 117 | 118 | 119 | ### Features 120 | 121 | * improve perf and avoid updating data or view when not necessary ([#58](https://github.com/vega/react-vega/issues/58)) ([20d99ca](https://github.com/vega/react-vega/commit/20d99ca00ad422406eee2ec60040cefe1cef4696)) 122 | * log parse error by default and catch more errors ([#56](https://github.com/vega/react-vega/issues/56)) ([c01862d](https://github.com/vega/react-vega/commit/c01862dbc63bea7f3cdf37aa0f3c0b129a8fb296)) 123 | 124 | 125 | 126 | # [7.0.0-alpha.0](https://github.com/vega/react-vega/compare/v6.1.0...v7.0.0-alpha.0) (2019-09-15) 127 | 128 | 129 | ### Features 130 | 131 | * rewrite react-vega in typescript ([#54](https://github.com/vega/react-vega/issues/54)) ([b923923](https://github.com/vega/react-vega/commit/b92392363d8ab5fc0d5c462beab7cf0402296de0)) 132 | 133 | 134 | 135 | # [6.1.0](https://github.com/vega/react-vega/compare/v6.0.1...v6.1.0) (2019-07-10) 136 | 137 | 138 | ### Bug Fixes 139 | 140 | * re-render should not register additonal hover listeners ([#42](https://github.com/vega/react-vega/issues/42)) ([5634efe](https://github.com/vega/react-vega/commit/5634efe04c4b2271c85364ab2a687e154bb4331e)), closes [#30](https://github.com/vega/react-vega/issues/30) 141 | 142 | 143 | ### Features 144 | 145 | * integrate vega embed to use tooltip, bug fixes for storybook ([#38](https://github.com/vega/react-vega/issues/38)) ([16aa8cc](https://github.com/vega/react-vega/commit/16aa8cc3763f01ab8d71914f16f92a8fd6a18b2b)) 146 | 147 | 148 | 149 | ## [6.0.1](https://github.com/vega/react-vega/compare/v6.0.0...v6.0.1) (2019-04-03) 150 | 151 | 152 | ### Features 153 | 154 | * add react-vega-lite ([87b3512](https://github.com/vega/react-vega/commit/87b3512bfc433e9245a8c24fcd1f650369631497)) 155 | * add react-vega-lite storybook ([4e8793f](https://github.com/vega/react-vega/commit/4e8793fa45ff9abdc872733e49d8a4d7360ccf3f)) 156 | 157 | 158 | 159 | # [6.0.0](https://github.com/vega/react-vega/compare/v5.0.0...v6.0.0) (2019-04-03) 160 | 161 | 162 | ### Bug Fixes 163 | 164 | * lint ([669df11](https://github.com/vega/react-vega/commit/669df11415f0d70d94b6f15e43801c811b7e3a89)) 165 | 166 | 167 | ### Build System 168 | 169 | * discontinue bower support ([e30dca6](https://github.com/vega/react-vega/commit/e30dca65cfff9516af5035f4aec19e72a8172e22)) 170 | 171 | 172 | ### Features 173 | 174 | * add storybook ([b4f1ecc](https://github.com/vega/react-vega/commit/b4f1ecc04ea6c99acd3af92b82f57d8970ee8d59)) 175 | 176 | 177 | ### BREAKING CHANGES 178 | 179 | * discontinue bower support 180 | 181 | 182 | 183 | # [5.0.0](https://github.com/vega/react-vega/compare/v4.0.2...v5.0.0) (2019-04-02) 184 | 185 | 186 | 187 | ## [7.4.4](https://github.com/vega/react-vega/compare/v7.4.3...v7.4.4) (2021-08-27) 188 | 189 | 190 | ### Bug Fixes 191 | 192 | * call embed finalize instead of view ([#421](https://github.com/vega/react-vega/issues/421)) ([20efe38](https://github.com/vega/react-vega/commit/20efe3844df09d754938382e981070f340f2c972)) 193 | 194 | 195 | ## [7.4.3](https://github.com/vega/react-vega/compare/v7.4.2...v7.4.3) (2021-05-01) 196 | 197 | 198 | ### Features 199 | 200 | * support react 17 ([#354](https://github.com/vega/react-vega/issues/354)) ([4843a7f](https://github.com/vega/react-vega/commit/4843a7ff54e4099e180c25b56554fb2d511ff4e8)) 201 | 202 | 203 | 204 | ## [7.4.2](https://github.com/vega/react-vega/compare/v7.4.1...v7.4.2) (2020-11-10) 205 | 206 | 207 | 208 | ## [7.4.1](https://github.com/vega/react-vega/compare/v7.4.0...v7.4.1) (2020-07-28) 209 | 210 | 211 | ### Bug Fixes 212 | 213 | * reexport types ([dd4f409](https://github.com/vega/react-vega/commit/dd4f409952a4799905163b01c7e75b377c077072)) 214 | 215 | 216 | 217 | # [7.4.0](https://github.com/vega/react-vega/compare/v7.3.0...v7.4.0) (2020-07-20) 218 | 219 | 220 | ### Features 221 | 222 | * export types ([#242](https://github.com/vega/react-vega/issues/242)) ([5baea7c](https://github.com/vega/react-vega/commit/5baea7c424fa77ffdc9967e38f645f44756b42a0)) 223 | 224 | 225 | 226 | # [7.3.0](https://github.com/vega/react-vega/compare/v7.2.1...v7.3.0) (2020-03-22) 227 | 228 | 229 | ### Features 230 | 231 | * support top-level width and height ([#144](https://github.com/vega/react-vega/issues/144)) ([1d75bc3](https://github.com/vega/react-vega/commit/1d75bc3abf743ae4fd43b17e4c0c12884e50b05a)) 232 | 233 | 234 | 235 | ## [7.2.1](https://github.com/vega/react-vega/compare/v7.2.0...v7.2.1) (2020-02-12) 236 | 237 | 238 | 239 | # [7.2.0](https://github.com/vega/react-vega/compare/v7.1.2...v7.2.0) (2020-02-06) 240 | 241 | 242 | ### Features 243 | 244 | * avoid creating new view when only width or height in spec changes ([#95](https://github.com/vega/react-vega/issues/95)) ([d4a87e7](https://github.com/vega/react-vega/commit/d4a87e785d795e1cf3f08a77c36ee6fefcb2d995)) 245 | 246 | 247 | 248 | ## [7.1.2](https://github.com/vega/react-vega/compare/v7.1.1...v7.1.2) (2020-02-05) 249 | 250 | 251 | ### Bug Fixes 252 | 253 | * autosize fail sometimes([#78](https://github.com/vega/react-vega/issues/78)) ([#80](https://github.com/vega/react-vega/issues/80)) ([f580611](https://github.com/vega/react-vega/commit/f580611101bc898bb2ce70936c82776c5f3b2d84)) 254 | * demo ([dc32f61](https://github.com/vega/react-vega/commit/dc32f61f4027b492c3403385003ba58e1430527a)) 255 | * replace any type with unknown ([#93](https://github.com/vega/react-vega/issues/93)) ([0f16622](https://github.com/vega/react-vega/commit/0f16622aadcdcc949188bf967abe97dc3bc3e0f8)) 256 | * use chaining ([1d78394](https://github.com/vega/react-vega/commit/1d783943963f4212f82a38e971a594c873fb6503)) 257 | 258 | 259 | 260 | ## [7.1.1](https://github.com/vega/react-vega/compare/v7.1.0...v7.1.1) (2019-11-19) 261 | 262 | 263 | 264 | # [7.1.0](https://github.com/vega/react-vega/compare/v7.0.1...v7.1.0) (2019-10-18) 265 | 266 | 267 | ### Features 268 | 269 | * add data support for layer ([#66](https://github.com/vega/react-vega/issues/66)) ([b63e3ae](https://github.com/vega/react-vega/commit/b63e3ae9ee800b5c48f9a1d8d442d58bed1bbf3d)) 270 | 271 | 272 | 273 | ## [7.0.1](https://github.com/vega/react-vega/compare/v7.0.0...v7.0.1) (2019-09-25) 274 | 275 | 276 | ### Bug Fixes 277 | 278 | * return type of onError ([#62](https://github.com/vega/react-vega/issues/62)) ([8980bc4](https://github.com/vega/react-vega/commit/8980bc4fbe94d0e125be8609206de04f949e593e)) 279 | 280 | 281 | ### Features 282 | 283 | * optimize data update ([#61](https://github.com/vega/react-vega/issues/61)) ([8e1baab](https://github.com/vega/react-vega/commit/8e1baab35bb29b0e5903d452a7ed1db2a7046ee6)) 284 | 285 | 286 | 287 | # [7.0.0](https://github.com/vega/react-vega/compare/v7.0.0-alpha.0...v7.0.0) (2019-09-20) 288 | 289 | 290 | ### Bug Fixes 291 | 292 | * list of dependencies in package.json ([#57](https://github.com/vega/react-vega/issues/57)) ([d15659a](https://github.com/vega/react-vega/commit/d15659a6199620b5846654fb7047fd216e283125)) 293 | 294 | 295 | ### Features 296 | 297 | * improve perf and avoid updating data or view when not necessary ([#58](https://github.com/vega/react-vega/issues/58)) ([20d99ca](https://github.com/vega/react-vega/commit/20d99ca00ad422406eee2ec60040cefe1cef4696)) 298 | * log parse error by default and catch more errors ([#56](https://github.com/vega/react-vega/issues/56)) ([c01862d](https://github.com/vega/react-vega/commit/c01862dbc63bea7f3cdf37aa0f3c0b129a8fb296)) 299 | 300 | 301 | 302 | # [7.0.0-alpha.0](https://github.com/vega/react-vega/compare/v6.1.0...v7.0.0-alpha.0) (2019-09-15) 303 | 304 | 305 | ### Features 306 | 307 | * rewrite react-vega in typescript ([#54](https://github.com/vega/react-vega/issues/54)) ([b923923](https://github.com/vega/react-vega/commit/b92392363d8ab5fc0d5c462beab7cf0402296de0)) 308 | 309 | 310 | 311 | # [6.1.0](https://github.com/vega/react-vega/compare/v6.0.1...v6.1.0) (2019-07-10) 312 | 313 | 314 | ### Bug Fixes 315 | 316 | * re-render should not register additonal hover listeners ([#42](https://github.com/vega/react-vega/issues/42)) ([5634efe](https://github.com/vega/react-vega/commit/5634efe04c4b2271c85364ab2a687e154bb4331e)), closes [#30](https://github.com/vega/react-vega/issues/30) 317 | 318 | 319 | ### Features 320 | 321 | * integrate vega embed to use tooltip, bug fixes for storybook ([#38](https://github.com/vega/react-vega/issues/38)) ([16aa8cc](https://github.com/vega/react-vega/commit/16aa8cc3763f01ab8d71914f16f92a8fd6a18b2b)) 322 | 323 | 324 | 325 | ## [6.0.1](https://github.com/vega/react-vega/compare/v6.0.0...v6.0.1) (2019-04-03) 326 | 327 | 328 | ### Features 329 | 330 | * add react-vega-lite ([87b3512](https://github.com/vega/react-vega/commit/87b3512bfc433e9245a8c24fcd1f650369631497)) 331 | * add react-vega-lite storybook ([4e8793f](https://github.com/vega/react-vega/commit/4e8793fa45ff9abdc872733e49d8a4d7360ccf3f)) 332 | 333 | 334 | 335 | # [6.0.0](https://github.com/vega/react-vega/compare/v5.0.0...v6.0.0) (2019-04-03) 336 | 337 | 338 | ### Bug Fixes 339 | 340 | * lint ([669df11](https://github.com/vega/react-vega/commit/669df11415f0d70d94b6f15e43801c811b7e3a89)) 341 | 342 | 343 | ### Build System 344 | 345 | * discontinue bower support ([e30dca6](https://github.com/vega/react-vega/commit/e30dca65cfff9516af5035f4aec19e72a8172e22)) 346 | 347 | 348 | ### Features 349 | 350 | * add storybook ([b4f1ecc](https://github.com/vega/react-vega/commit/b4f1ecc04ea6c99acd3af92b82f57d8970ee8d59)) 351 | 352 | 353 | ### BREAKING CHANGES 354 | 355 | * discontinue bower support 356 | 357 | 358 | 359 | # [5.0.0](https://github.com/vega/react-vega/compare/v4.0.2...v5.0.0) (2019-04-02) 360 | 361 | 362 | 363 | ## [4.0.2](https://github.com/vega/react-vega/compare/v4.0.1...v4.0.2) (2018-07-31) 364 | 365 | 366 | 367 | ## [4.0.1](https://github.com/vega/react-vega/compare/v4.0.0...v4.0.1) (2018-07-28) 368 | 369 | 370 | 371 | # [4.0.0](https://github.com/vega/react-vega/compare/v3.1.2...v4.0.0) (2018-07-25) 372 | 373 | 374 | 375 | ## [3.1.2](https://github.com/vega/react-vega/compare/v3.1.1...v3.1.2) (2018-01-11) 376 | 377 | 378 | 379 | ## [3.1.1](https://github.com/vega/react-vega/compare/v3.1.0...v3.1.1) (2017-06-22) 380 | 381 | 382 | 383 | # [3.1.0](https://github.com/vega/react-vega/compare/v3.0.1...v3.1.0) (2017-06-22) 384 | 385 | 386 | 387 | # [7.2.0](https://github.com/vega/react-vega/compare/v7.1.2...v7.2.0) (2020-02-06) 388 | 389 | 390 | ### Features 391 | 392 | * avoid creating new view when only width or height in spec changes ([#95](https://github.com/vega/react-vega/issues/95)) ([d4a87e7](https://github.com/vega/react-vega/commit/d4a87e785d795e1cf3f08a77c36ee6fefcb2d995)) 393 | 394 | 395 | 396 | ## [7.1.2](https://github.com/vega/react-vega/compare/v7.1.1...v7.1.2) (2020-02-05) 397 | 398 | 399 | ### Bug Fixes 400 | 401 | * autosize fail sometimes([#78](https://github.com/vega/react-vega/issues/78)) ([#80](https://github.com/vega/react-vega/issues/80)) ([f580611](https://github.com/vega/react-vega/commit/f580611101bc898bb2ce70936c82776c5f3b2d84)) 402 | * replace any type with unknown ([#93](https://github.com/vega/react-vega/issues/93)) ([0f16622](https://github.com/vega/react-vega/commit/0f16622aadcdcc949188bf967abe97dc3bc3e0f8)) 403 | * use chaining ([1d78394](https://github.com/vega/react-vega/commit/1d783943963f4212f82a38e971a594c873fb6503)) 404 | 405 | 406 | 407 | ## [7.1.1](https://github.com/vega/react-vega/compare/v7.1.0...v7.1.1) (2019-11-19) 408 | 409 | 410 | # [7.1.0](https://github.com/vega/react-vega/compare/v7.0.1...v7.1.0) (2019-10-18) 411 | 412 | 413 | ### Features 414 | 415 | * add data support for layer ([#66](https://github.com/vega/react-vega/issues/66)) ([b63e3ae](https://github.com/vega/react-vega/commit/b63e3ae9ee800b5c48f9a1d8d442d58bed1bbf3d)) 416 | 417 | 418 | 419 | ## [7.0.1](https://github.com/vega/react-vega/compare/v7.0.0...v7.0.1) (2019-09-25) 420 | 421 | 422 | ### Bug Fixes 423 | 424 | * return type of onError ([#62](https://github.com/vega/react-vega/issues/62)) ([8980bc4](https://github.com/vega/react-vega/commit/8980bc4fbe94d0e125be8609206de04f949e593e)) 425 | 426 | 427 | ### Features 428 | 429 | * optimize data update ([#61](https://github.com/vega/react-vega/issues/61)) ([8e1baab](https://github.com/vega/react-vega/commit/8e1baab35bb29b0e5903d452a7ed1db2a7046ee6)) 430 | 431 | 432 | 433 | # [7.0.0](https://github.com/vega/react-vega/compare/v7.0.0-alpha.0...v7.0.0) (2019-09-20) 434 | 435 | 436 | ### Bug Fixes 437 | 438 | * list of dependencies in package.json ([#57](https://github.com/vega/react-vega/issues/57)) ([d15659a](https://github.com/vega/react-vega/commit/d15659a6199620b5846654fb7047fd216e283125)) 439 | 440 | 441 | ### Features 442 | 443 | * improve perf and avoid updating data or view when not necessary ([#58](https://github.com/vega/react-vega/issues/58)) ([20d99ca](https://github.com/vega/react-vega/commit/20d99ca00ad422406eee2ec60040cefe1cef4696)) 444 | * log parse error by default and catch more errors ([#56](https://github.com/vega/react-vega/issues/56)) ([c01862d](https://github.com/vega/react-vega/commit/c01862dbc63bea7f3cdf37aa0f3c0b129a8fb296)) 445 | 446 | 447 | 448 | # [7.0.0-alpha.0](https://github.com/vega/react-vega/compare/v6.1.0...v7.0.0-alpha.0) (2019-09-15) 449 | 450 | ### Features 451 | 452 | * rewrite react-vega in typescript ([#54](https://github.com/vega/react-vega/issues/54)) ([b923923](https://github.com/vega/react-vega/commit/b923923)) 453 | 454 | ### 💔 BREAKING CHANGES: 455 | 456 | * Some props of `` are changed. 457 | * `react-vega-lite` package is deprecated. 458 | 459 | ### 🚚 Migration Guide 460 | 461 | #### Vega 462 | 463 | * `` changes to `` 464 | * `` changes to `` 465 | * `Vega`'s `onSignalXXX` signal listeners has been changed. 466 | 467 | ##### Previous versions 468 | 469 | ```js 470 | 471 | ``` 472 | 473 | ##### Now 474 | 475 | ```js 476 | // key is signal name 477 | const signalListeners = { hover: handleHover } /> 478 | 479 | 480 | ``` 481 | 482 | #### VegaLite 483 | 484 | Please use `react-vega` instead of `react-vega-lite`. 485 | 486 | ```js 487 | import { Vega, VegaLite, createClassFromSpec } from 'react-vega'; 488 | 489 | // Option 1. When spec has $schema field that is a valid vega-lite schema url. Vega will automatically parse vega-lite spec. 490 | 491 | // Option 2. Enforce mode manually. 492 | 493 | // Option 3. The new VegaLite component in react-vega is just a syntactic sugar of option 3. 494 | 495 | ``` 496 | 497 | # [6.1.0](https://github.com/vega/react-vega/compare/v6.0.1...v6.1.0) (2019-07-10) 498 | 499 | 500 | ### Bug Fixes 501 | 502 | * re-render should not register additonal hover listeners ([#42](https://github.com/vega/react-vega/issues/42)) ([5634efe](https://github.com/vega/react-vega/commit/5634efe)), closes [#30](https://github.com/vega/react-vega/issues/30) 503 | 504 | 505 | ### Features 506 | 507 | * integrate vega embed to use tooltip, bug fixes for storybook ([#38](https://github.com/vega/react-vega/issues/38)) ([16aa8cc](https://github.com/vega/react-vega/commit/16aa8cc)) 508 | 509 | 510 | 511 | ## [6.0.1](https://github.com/vega/react-vega/compare/v6.0.0...v6.0.1) (2019-04-03) 512 | 513 | 514 | ### Features 515 | 516 | * add `react-vega-lite` ([87b3512](https://github.com/vega/react-vega/commit/87b3512)) 517 | 518 | ### Documentation 519 | 520 | * add `react-vega-lite` storybook ([4e8793f](https://github.com/vega/react-vega/commit/4e8793f)) 521 | 522 | 523 | 524 | # [6.0.0](https://github.com/vega/react-vega/compare/v5.0.0...v6.0.0) (2019-04-03) 525 | 526 | 527 | ### Bug Fixes 528 | 529 | * linting ([669df11](https://github.com/vega/react-vega/commit/669df11)) 530 | 531 | ### Features 532 | 533 | * add storybook ([b4f1ecc](https://github.com/vega/react-vega/commit/b4f1ecc)) 534 | 535 | 536 | ### BREAKING CHANGES 537 | 538 | * output are now in `lib` and `esm` directories instead of `dist` 539 | * discontinue `bower` support 540 | 541 | 542 | # [5.0.0](https://github.com/vega/react-vega/compare/v4.0.2...v5.0.0) (2019-04-02) 543 | 544 | - Switch from `vega-lib` back to `vega. 545 | 546 | 547 | ## [4.0.2](https://github.com/vega/react-vega/compare/v4.0.1...v4.0.2) (2018-07-31) 548 | 549 | - Fix webpack config for amd/commonjs 550 | 551 | 552 | ## [4.0.1](https://github.com/vega/react-vega/compare/v4.0.0...v4.0.1) (2018-07-28) 553 | 554 | - Fix wrong webpack config that cause `react-vega` to accidentally bundle `vega-lib` inside it. (Issue #20) 555 | 556 | 557 | # [4.0.0](https://github.com/vega/react-vega/compare/v3.1.2...v4.0.0) (2018-07-25) 558 | 559 | - Switch from `vega` to `vega-lib` 560 | - Add tooltip handler support. Thanks @mdelrossi1. 561 | - Fix bug #14 562 | 563 | 564 | ## [3.1.2](https://github.com/vega/react-vega/compare/v3.1.1...v3.1.2) (2018-01-11) 565 | 566 | - Expand version to support React 16 567 | 568 | 569 | ## [3.1.1](https://github.com/vega/react-vega/compare/v3.1.0...v3.1.1) (2017-06-22) 570 | 571 | - Also add `vega` to devDependencies 572 | 573 | 574 | # [3.1.0](https://github.com/vega/react-vega/compare/v3.0.1...v3.1.0) (2017-06-22) 575 | 576 | - Move `vega` to peerDependencies 577 | 578 | 579 | ## [3.0.1](https://github.com/vega/react-vega/compare/v3.0.0...v3.0.1) (2017-05-09) 580 | 581 | 582 | # [3.0.0](https://github.com/vega/react-vega/compare/2.3.1...v3.0.0) (2017-05-09) 583 | 584 | - Support Vega 3 API changes ([Issue #6](https://github.com/kristw/react-vega/issues/6)) 585 | - Remove props `viewport` from `Vega` 586 | 587 | ## 2.3.0 588 | - Add props `updateOptions` 589 | 590 | ## 2.2.0 591 | - Support props `className` and `style` 592 | 593 | ## 2.1.2 594 | - Makes `createClassFromSpec(name, spec)` works when name is omitted (`createClassFromSpec(spec)`). This is for backward compatibility. 595 | 596 | ## 2.1.1 597 | - Fix eslint complaints 598 | 599 | ## 2.1.0 600 | - Implement `shouldComponentUpdate` to check if anything was changed. 601 | - Add static functions `isSamePadding` and `isSameViewport` to `Vega` class. 602 | 603 | # 2.0.0 604 | 605 | **Very likely to work fine if you are upgrading from 1.x.x.** There are breaking changes (of the features nobody seems to use) and I almost rewrite the whole thing so I think it is worth being considered a major version. Here are the list of changes: 606 | 607 | - Rewrite using preferred method recommended by React. `Vega` component now extends `React.Component` and use `ref` as a function instead of string. 608 | - Add check for props/data changes and only update when necessary. 609 | - Refactor code for clarity 610 | - Remove support for spec as a function 611 | - Add static functions `isSameData`, `isSameSpec` and `listenerName` to `Vega` class. 612 | 613 | ## 1.1.1 614 | - Fix bug to call `vis.update()` before setting new data 615 | 616 | ## 1.1.0 617 | - Support function as data and add static `getSpec()` 618 | 619 | ## 1.0.1 620 | - Avoid clearing data when that field is not set in the input. 621 | 622 | # 1.0.0 623 | - Change global export name to `ReactVega` instead of `reactVega` 624 | 625 | ## 0.1.2 626 | - Fix bug with umd export when using global 627 | 628 | ## 0.1.1 629 | - Fix bug with umd export when using global 630 | 631 | ## 0.1.0 632 | - Add support for dynamic spec via `` component. 633 | 634 | ## 0.0.2 635 | - Fix external lib bug 636 | 637 | ## 0.0.1 638 | - First release -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing 2 | 3 | Recommendations and requirements for how to best contribute to **react-vega**. As always, thanks for 4 | contributing, and we hope these guidelines make it easier and shed some light on our approach and 5 | processes. 6 | 7 | #### Key branches 8 | 9 | - `master` is the latest released version 10 | 11 | ### File organization 12 | 13 | [lerna](https://github.com/lerna/lerna/) is used to manage versions and dependencies between 14 | packages in this monorepo. 15 | 16 | Each package can inherit settings from project root and override its own build config, linting, and 17 | testing via beemo. You run all commands from root of the project except storybook. 18 | 19 | ``` 20 | react-vega/ 21 | lerna.json 22 | package.json 23 | ... 24 | packages/ 25 | package1/ 26 | package.json 27 | ... 28 | src/ 29 | test/ 30 | ... 31 | lib/ 32 | esm/ 33 | ... 34 | ... 35 | ``` 36 | 37 | ### Development 38 | 39 | #### Run storybook 40 | 41 | ```sh 42 | cd packages/react-vega-demo 43 | yarn storybook 44 | ``` 45 | 46 | ### Testing 47 | 48 | Run this command to test once. 49 | 50 | ```sh 51 | yarn test 52 | ``` 53 | 54 | Or run this command to test and retest when files are changed. 55 | 56 | ```sh 57 | yarn test:watch 58 | ``` 59 | 60 | ### Linting 61 | 62 | ```sh 63 | yarn lint 64 | # or this one if you want eslint to fix automatically when possible. 65 | yarn lint:fix 66 | ``` 67 | 68 | ### Committing 69 | 70 | This repository follows 71 | [conventional commits](https://www.conventionalcommits.org/en/v1.0.0-beta.3/) guideline for commit 72 | messages and has a `commitlint` hook which will require you to have the valid commit message before 73 | committing. 74 | 75 | You can use `yarn commit` to help you create a commit message. 76 | 77 | ### Publishing 78 | 79 | **Prerequisite:** You'll need an [npmjs.com](https://npmjs.com) account and given write access to 80 | `react-vega` and `react-vega-lite`. 81 | 82 | 1. Make sure you're logged in to NPM from your shell. Run `npm login` if necessary. 83 | 2. To make the release, run `yarn release` and follow the prompts. 84 | 85 | #### Deploy Storybook to github pages 86 | 87 | This is done automatically if you use `yarn release`. 88 | 89 | ```sh 90 | yarn postrelease 91 | ``` 92 | 93 | ### License 94 | 95 | By contributing your code, you agree to license your contributions under the terms of the 96 | [Apache-2.0 license](https://github.com/kristw/react-vega/blob/master/LICENSE) 97 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2016 Krist Wongsuphasawat (http://kristw.yellowpigz.com) 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build and test](https://github.com/vega/react-vega/actions/workflows/test.yml/badge.svg)](https://github.com/vega/react-vega/actions/workflows/test.yml) 2 | 3 | # react-vega 4 | 5 | > `react` + `vega`|`vega-lite` 6 | 7 | ### Demo 8 | 9 | http://vega.github.io/react-vega/ 10 | 11 | ### Packages 12 | 13 | | Package | Version | | 14 | | ----------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | 15 | | [react-vega](https://github.com/vega/react-vega/tree/master/packages/react-vega) | [![Version](https://img.shields.io/npm/v/react-vega.svg?style=flat-square)](https://npmjs.org/package/react-vega) | [Documentation](https://github.com/vega/react-vega/tree/master/packages/react-vega) | 16 | | ~~[react-vega-lite](https://github.com/vega/react-vega/tree/master/packages/react-vega-lite)~~ (deprecated) | [![Version](https://img.shields.io/npm/v/react-vega-lite.svg?style=flat-square)](https://npmjs.org/package/react-vega-lite) | Use `react-vega` instead. | 17 | 18 | ### Migration 19 | 20 | If you are upgrading from `react-vega` or `react-vega-lite` version `6.x.x` to `7.x.x`, read this 21 | [migration guide](https://github.com/vega/react-vega/blob/master/CHANGELOG.md#-migration-guide). 22 | 23 | ### License 24 | 25 | Apache-2.0 26 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | const isEsm = process.env.BABEL_OUTPUT === 'esm'; 2 | 3 | const envOptions = { 4 | loose: true, 5 | modules: isEsm ? false : 'commonjs', 6 | shippedProposals: true, 7 | targets: false, 8 | bugfixes: false, 9 | }; 10 | 11 | const config = { 12 | ignore: [ 13 | 'coverage/', 14 | 'node_modules/', 15 | 'public/', 16 | 'esm/', 17 | 'lib/', 18 | 'tmp/', 19 | 'dist/', 20 | '*.d.ts', 21 | '__tests__', 22 | '__mocks__', 23 | ], 24 | plugins: [ 25 | [ 26 | 'babel-plugin-transform-dev', 27 | { 28 | evaluate: false, 29 | }, 30 | ], 31 | 'babel-plugin-typescript-to-proptypes', 32 | '@babel/plugin-proposal-class-properties', 33 | ], 34 | presets: [['@babel/preset-env', envOptions], '@babel/preset-react', '@babel/preset-typescript'], 35 | }; 36 | 37 | // Override to allow transpile es modules inside vega-lite 38 | config.ignore = config.ignore.filter(item => item !== 'node_modules/'); 39 | config.ignore.push('node_modules/(?!(vega-lite|lodash-es))'); 40 | 41 | if (process.env.NODE_ENV === 'test') { 42 | envOptions.targets = { node: 'current' }; 43 | config.plugins.push('babel-plugin-dynamic-import-node'); 44 | } 45 | 46 | module.exports = config; 47 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = require('@superset-ui/commit-config/commitlint.config'); 2 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | coverageDirectory: './coverage', 3 | coveragePathIgnorePatterns: ['node_modules/', 'public/', 'esm/', 'lib/', 'tmp/', 'dist/'], 4 | coverageReporters: ['lcov'], 5 | globals: { 6 | __DEV__: true, 7 | }, 8 | moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx', 'json'], 9 | roots: ['/packages'], 10 | testEnvironment: 'jest-environment-jsdom', 11 | testMatch: ['**/?(*.)+(spec|test).{js,jsx,ts,tsx}'], 12 | testURL: 'http://localhost/', 13 | transform: { 14 | '^.+\\.(t|j)sx?$': 'babel-jest', 15 | }, 16 | transformIgnorePatterns: ['node_modules/(?!vega-lite)'], 17 | verbose: true, 18 | }; 19 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "packages": [ 4 | "packages/*" 5 | ], 6 | "useWorkspaces": true, 7 | "version": "7.6.0" 8 | } 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-vega-monorepo", 3 | "version": "0.0.0", 4 | "description": "Home of react-vega", 5 | "author": "Krist Wongsuphasawat (http://kristw.yellowpigz.com)", 6 | "keywords": [], 7 | "repository": "git@github.com:vega/react-vega.git", 8 | "bugs": { 9 | "url": "https://github.com/vega/react-vega/issues" 10 | }, 11 | "private": true, 12 | "license": "Apache-2.0", 13 | "scripts": { 14 | "postpublish": "git push; git push --tags", 15 | "build": "yarn babel && yarn type", 16 | "babel": "yarn babel:cjs && yarn babel:esm", 17 | "babel:cjs": "lerna exec --stream --concurrency 10 --scope 'react-vega' -- babel --config-file='../../babel.config.js' src --extensions '.ts,.tsx,.js,.jsx' --copy-files --out-dir lib", 18 | "babel:esm": "BABEL_OUTPUT=esm lerna exec --stream --concurrency 10 --scope 'react-vega' -- babel --config-file='../../babel.config.js' src --extensions '.ts,.tsx,.js,.jsx' --copy-files --out-dir esm", 19 | "clean": "rm -rf ./packages/**/{lib,esm,tsconfig.tsbuildinfo}", 20 | "commit": "superset-commit", 21 | "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 20", 22 | "format": "yarn prettier", 23 | "jest": "NODE_ENV=test jest --coverage --verbose", 24 | "lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .", 25 | "lint:fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .", 26 | "prettier": "prettier --write './packages/**/*{.js,.jsx,.ts,.tsx,.css,.less,.scss,.sass}'", 27 | "test": "yarn jest", 28 | "test:watch": "yarn lint:fix && yarn jest --watch", 29 | "type": "lerna exec --stream --concurrency 3 --scope 'react-vega' -- ../../scripts/tsc.sh --build", 30 | "prepare-release": "git checkout master && git pull --rebase origin master && yarn && yarn test", 31 | "prerelease": "yarn build", 32 | "pretest": "yarn lint", 33 | "release": "yarn prepare-release && lerna publish --exact && yarn postrelease", 34 | "postrelease": "lerna run deploy-demo", 35 | "storybook": "cd packages/react-vega-demo && yarn storybook", 36 | "prepare": "husky install" 37 | }, 38 | "devDependencies": { 39 | "@babel/cli": "^7.11.5", 40 | "@babel/compat-data": "^7.9.6", 41 | "@babel/core": "^7.8.7", 42 | "@babel/eslint-parser": "^7.16.0", 43 | "@babel/node": "^7.8.7", 44 | "@babel/plugin-proposal-class-properties": "^7.8.3", 45 | "@babel/plugin-proposal-optional-chaining": "^7.8.3", 46 | "@babel/plugin-syntax-dynamic-import": "^7.8.3", 47 | "@babel/plugin-transform-runtime": "^7.8.3", 48 | "@babel/preset-env": "^7.8.7", 49 | "@babel/preset-react": "^7.8.3", 50 | "@babel/preset-typescript": "^7.12.7", 51 | "@babel/register": "^7.8.6", 52 | "@superset-ui/commit-config": "^0.0.9", 53 | "@testing-library/react": "^13.3.0", 54 | "@types/jest": "^27.4.1", 55 | "@types/react-test-renderer": "^18.0.0", 56 | "@typescript-eslint/eslint-plugin": "^5.3.0", 57 | "@typescript-eslint/parser": "^5.3.0", 58 | "babel-jest": "^27.5.1", 59 | "babel-plugin-transform-dev": "^2.0.1", 60 | "babel-plugin-typescript-to-proptypes": "^2.0.0", 61 | "canvas": "^2.9.1", 62 | "eslint": "^7.32.0", 63 | "eslint-config-airbnb": "^18.2.1", 64 | "eslint-config-prettier": "^7.1.0", 65 | "eslint-import-resolver-typescript": "^2.3.0", 66 | "eslint-import-resolver-webpack": "^0.13.0", 67 | "eslint-plugin-babel": "^5.3.1", 68 | "eslint-plugin-compat": "^4.0.2", 69 | "eslint-plugin-promise": "^6.0.0", 70 | "eslint-plugin-import": "^2.22.1", 71 | "eslint-plugin-jest": "^26.1.3", 72 | "eslint-plugin-jest-dom": "^4.0.1", 73 | "eslint-plugin-jsx-a11y": "^6.4.1", 74 | "eslint-plugin-no-only-tests": "^2.4.0", 75 | "eslint-plugin-prettier": "^3.3.1", 76 | "eslint-plugin-react": "^7.29.4", 77 | "eslint-plugin-react-hooks": "^4.4.0", 78 | "eslint-plugin-testing-library": "^5.2.1", 79 | "eslint-plugin-unicorn": "^40.1.0", 80 | "husky": "^7.0.0", 81 | "jest": "^27.5.1", 82 | "lerna": "^3.20.2", 83 | "lint-staged": "^13.0.0", 84 | "prettier": "^2.4.1", 85 | "react": "^18", 86 | "react-dom": "^18", 87 | "typescript": "^4.6.3", 88 | "vega": "^5.10.0", 89 | "vega-lite": "^5.2.0", 90 | "webpack": "^4.42.0" 91 | }, 92 | "engines": { 93 | "node": ">=16", 94 | "npm": ">=6.8.0", 95 | "yarn": ">=1.13.0" 96 | }, 97 | "workspaces": [ 98 | "./packages/*" 99 | ], 100 | "browserslist": [ 101 | "last 3 chrome versions", 102 | "last 3 firefox versions", 103 | "last 3 safari versions", 104 | "last 3 edge versions" 105 | ], 106 | "lint-staged": { 107 | "./packages/*/{src,test,storybook}/**/*.{js,jsx,ts,tsx,json,md}": [ 108 | "yarn prettier", 109 | "git add" 110 | ] 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /packages/react-vega-demo/.storybook/addons.js: -------------------------------------------------------------------------------- 1 | import '@storybook/addon-actions/register'; 2 | import '@storybook/addon-links/register'; 3 | -------------------------------------------------------------------------------- /packages/react-vega-demo/.storybook/config.js: -------------------------------------------------------------------------------- 1 | import { addParameters, configure } from '@storybook/react'; 2 | 3 | addParameters({ 4 | options: { 5 | name: '✨ React+Vega', 6 | addonPanelInRight: false, 7 | enableShortcuts: false, 8 | goFullScreen: false, 9 | hierarchyRootSeparator: null, 10 | hierarchySeparator: /\|/, 11 | selectedAddonPanel: undefined, // The order of addons in the "Addon panel" is the same as you import them in 'addons.js'. The first panel will be opened by default as you run Storybook 12 | showAddonPanel: true, 13 | showSearchBox: false, 14 | showStoriesPanel: true, 15 | sidebarAnimations: true, 16 | sortStoriesByKind: false, 17 | url: '#', 18 | }, 19 | }); 20 | 21 | // automatically import all files ending in *.stories.js 22 | const req = require.context('../stories', true, /\.stories\.(j|t)sx?$/); 23 | function loadStories() { 24 | req.keys().forEach(filename => req(filename)); 25 | } 26 | 27 | configure(loadStories, module); 28 | -------------------------------------------------------------------------------- /packages/react-vega-demo/.storybook/webpack.config.js: -------------------------------------------------------------------------------- 1 | module.exports = async ({ config }) => { 2 | config.module.rules.push({ 3 | loader: require.resolve('babel-loader'), 4 | options: { 5 | presets: [ 6 | ['@babel/preset-env', { useBuiltIns: 'entry' }], 7 | '@babel/preset-react', 8 | '@babel/preset-typescript', 9 | ], 10 | plugins: [ 11 | '@babel/plugin-proposal-object-rest-spread', 12 | '@babel/plugin-proposal-class-properties', 13 | '@babel/plugin-syntax-dynamic-import', 14 | ], 15 | }, 16 | test: /\.tsx?$/, 17 | exclude: /node_modules/, 18 | }); 19 | 20 | config.resolve.extensions.push('.ts', '.tsx'); 21 | 22 | return config; 23 | }; 24 | -------------------------------------------------------------------------------- /packages/react-vega-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-vega-demo", 3 | "version": "7.5.0", 4 | "description": "Convert Vega spec into React class conveniently", 5 | "author": "Krist Wongsuphasawat (http://kristw.yellowpigz.com)", 6 | "keywords": [], 7 | "repository": "git@github.com:vega/react-vega.git", 8 | "bugs": { 9 | "url": "https://github.com/vega/react-vega/issues" 10 | }, 11 | "private": true, 12 | "sideEffects": false, 13 | "main": "lib/index.js", 14 | "module": "esm/index.js", 15 | "files": [ 16 | "src", 17 | "esm", 18 | "lib", 19 | "types" 20 | ], 21 | "dependencies": { 22 | "@storybook/addon-actions": "^5.3.9", 23 | "@storybook/addon-links": "^5.3.9", 24 | "@storybook/addons": "^6.2.1", 25 | "@storybook/react": "^5.3.9", 26 | "@types/react": "^16.9.43", 27 | "@types/react-dom": "^17.0.3", 28 | "@types/react-timeout": "^1.1.1", 29 | "react": "^16.12.0", 30 | "react-dom": "^16.12.0", 31 | "react-timeout": "^2.0.1" 32 | }, 33 | "devDependencies": { 34 | "@babel/core": "^7.8.3", 35 | "babel-loader": "^8.0.6", 36 | "gh-pages": "^3.1.0", 37 | "react-dom": "^16.12.0" 38 | }, 39 | "license": "Apache-2.0", 40 | "publishConfig": { 41 | "access": "public" 42 | }, 43 | "scripts": { 44 | "demo:clean": "rm -rf _gh-pages", 45 | "demo:build": "build-storybook -o _gh-pages", 46 | "demo:publish": "gh-pages -d _gh-pages", 47 | "deploy-demo": "npm run demo:clean && npm run demo:build && npm run demo:publish && npm run demo:clean", 48 | "storybook": "start-storybook -p 9001" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /packages/react-vega-demo/stories/ChangingDimensionDemo.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { VegaLite } from '../../react-vega/src'; 3 | 4 | const values = []; 5 | 6 | for (let i = 0; i < 100; i += 1) { 7 | values.push({ 8 | a: `X${i}`, 9 | b: Math.round(Math.random() * 1000), 10 | }); 11 | } 12 | 13 | export default class ChangingDimensionDemo extends React.Component< 14 | {}, 15 | { 16 | width: number; 17 | height: number; 18 | padding: 19 | | number 20 | | { 21 | top?: number; 22 | bottom?: number; 23 | left?: number; 24 | right?: number; 25 | }; 26 | grow: boolean; 27 | } 28 | > { 29 | interval: NodeJS.Timeout; 30 | 31 | constructor(props) { 32 | super(props); 33 | this.state = { 34 | width: 100, 35 | height: 100, 36 | padding: 20, 37 | grow: true, 38 | }; 39 | } 40 | 41 | componentDidMount() { 42 | this.interval = setInterval(() => { 43 | this.setState(({ width, height, grow }) => ({ 44 | width: width + (grow ? 1 : -1), 45 | height: height + (grow ? 1 : -1), 46 | grow: (grow && width < 400) || (!grow && width === 100), 47 | })); 48 | }, 10); 49 | } 50 | 51 | componentWillUnmount() { 52 | clearInterval(this.interval); 53 | } 54 | 55 | render() { 56 | const { width, height, padding } = this.state; 57 | 58 | const SPEC = { 59 | $schema: 'https://vega.github.io/schema/vega-lite/v4.json', 60 | width, 61 | height, 62 | padding, 63 | data: { 64 | values, 65 | name: 'source', 66 | }, 67 | selection: { 68 | a: { type: 'single' }, 69 | }, 70 | mark: 'bar', 71 | encoding: { 72 | x: { field: 'a', type: 'ordinal' }, 73 | y: { field: 'b', type: 'quantitative' }, 74 | tooltip: { field: 'b', type: 'quantitative' }, 75 | color: { 76 | condition: { selection: 'a', value: 'steelblue' }, 77 | value: 'grey', 78 | }, 79 | }, 80 | } as const; 81 | 82 | return ; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /packages/react-vega-demo/stories/ReactVegaDemo.tsx: -------------------------------------------------------------------------------- 1 | /* eslint-disable no-magic-numbers */ 2 | import React from 'react'; 3 | import { action } from '@storybook/addon-actions'; 4 | import { Vega, createClassFromSpec, VisualizationSpec } from '../../react-vega/src'; 5 | import data1 from './vega/data1'; 6 | import spec1 from './vega/spec1'; 7 | import spec2 from './vega/spec2'; 8 | 9 | const BarChart = createClassFromSpec({ spec: spec1 }); 10 | 11 | const code1 = ``; 12 | 13 | const code2 = `const BarChart = ReactVega.createClassFromSpec(barSpec); 14 | `; 15 | 16 | type State = { 17 | data: Record; 18 | info: string; 19 | spec: VisualizationSpec; 20 | }; 21 | 22 | export default class Demo extends React.PureComponent<{}, State> { 23 | handlers: { 24 | tooltip: (...args: unknown[]) => void; 25 | }; 26 | 27 | constructor(props) { 28 | super(props); 29 | this.state = { 30 | data: data1, 31 | info: '', 32 | spec: spec1, 33 | }; 34 | 35 | this.handleHover = this.handleHover.bind(this); 36 | this.handleToggleSpec = this.handleToggleSpec.bind(this); 37 | this.handleUpdateData = this.handleUpdateData.bind(this); 38 | this.handleErrorSpec = this.handleErrorSpec.bind(this); 39 | this.handlers = { tooltip: this.handleHover }; 40 | } 41 | 42 | handleHover(...args) { 43 | action('hover', { 44 | limit: 5, 45 | })(args); 46 | this.setState({ 47 | info: JSON.stringify(args), 48 | }); 49 | } 50 | 51 | handleErrorSpec() { 52 | const spec: VisualizationSpec = { 53 | signals: [ 54 | { name: 'foo' }, 55 | { name: 'foo' }, // create error: Duplicate signal name 56 | ], 57 | }; 58 | action('error spec')(spec); 59 | this.setState({ spec }); 60 | } 61 | 62 | handleToggleSpec() { 63 | const { spec } = this.state; 64 | action('toggle spec')(spec); 65 | if (spec === spec1) { 66 | this.setState({ spec: spec2 }); 67 | } else { 68 | this.setState({ spec: spec1 }); 69 | } 70 | } 71 | 72 | handleUpdateData() { 73 | const table = []; 74 | for (let i = 1; i <= 20; i += 1) { 75 | table.push({ 76 | amount: Math.round(Math.random() * 100), 77 | category: String.fromCharCode(65 + i), 78 | }); 79 | } 80 | action('update data')(table); 81 | this.setState({ data: { table } }); 82 | } 83 | 84 | render() { 85 | const { data, spec, info } = this.state; 86 | 87 | return ( 88 |
89 |
90 |