diff --git a/bindings/kepler.gl-jupyter/.gitignore b/bindings/kepler.gl-jupyter/.gitignore deleted file mode 100644 index 1a04f53a30..0000000000 --- a/bindings/kepler.gl-jupyter/.gitignore +++ /dev/null @@ -1,36 +0,0 @@ -*.egg-info/ -*.py[cod] -*/__pycache__/ -.ipynb_checkpoints/ - -dist/ -# labextension build -keplergl-jupyter/ -build/ -*.py[cod] -node_modules/ -env/ -ENV/ -ENV3/ - -# OS X -.DS_Store -.vs_code/ - -# Compiled javascript -keplergl/static/* - -setup.orig.py -setup.orig2.py - -notebooks/*.html -notebooks/*.sh -notebooks/*.js -notebooks/ignore_* - -*/*.tgz -package/ - -*.old* -*test* -js/temp.* diff --git a/bindings/kepler.gl-jupyter/Dockerfile b/bindings/kepler.gl-jupyter/Dockerfile deleted file mode 100644 index b8e344a705..0000000000 --- a/bindings/kepler.gl-jupyter/Dockerfile +++ /dev/null @@ -1,36 +0,0 @@ -# NOTE: PLEASE run `yarn build` before running this dockerfile -FROM ubuntu:latest - -# Install python3 -RUN apt-get update && apt-get install -y python3 python3-pip python3-venv - -# Install gdal -RUN apt-get install -y gdal-bin - -# Fix: No such file or directory: 'gdal-config' -RUN apt-get install -y libgdal-dev - -# Make the current directory the working directory -WORKDIR /kepler.gl - -# The current directory is /bindings/kepler.gl-jupyter -# Copy the root directory contents into the working directory -COPY . . - -# Create a virtual environment .venv -RUN python3 -m venv .venv - -# Activate the virtual environment -RUN . .venv/bin/activate - -# Install jupyter_packaging using pip -RUN .venv/bin/pip install jupyter_packaging - - -# Install keplergl-jupyter in the virtual environment from the current directory -RUN .venv/bin/pip install . - -# Run jupyter notebook with token exposed in logs -CMD [".venv/bin/jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--NotebookApp.log_level='INFO'"] - -EXPOSE 8888 diff --git a/bindings/kepler.gl-jupyter/MANIFEST.in b/bindings/kepler.gl-jupyter/MANIFEST.in deleted file mode 100644 index 071f7865e0..0000000000 --- a/bindings/kepler.gl-jupyter/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -recursive-include keplergl/static *.* -recursive-include keplergl-jupyter/labextension *.* -include keplergl-jupyter.json diff --git a/bindings/kepler.gl-jupyter/README.md b/bindings/kepler.gl-jupyter/README.md deleted file mode 100644 index 01b3339806..0000000000 --- a/bindings/kepler.gl-jupyter/README.md +++ /dev/null @@ -1,375 +0,0 @@ -# kepler.gl for Jupyter - -This is the [kepler.gl](http://kepler.gl) jupyter widget, an advanced geospatial visualization tool, to render large-scale interactive maps in Jupyter Notebook. - -![Kepler.gl for Jupyter][jupyter_widget] - -Table of contacts -- [Installation](#installation) -- [Quick Start](#quick-start) -- [Demo Notebooks](#demo-notebooks) -- [Usage](#usage) -- [Local Development Setup](#local-development-setup) -- [FAQ & Troubleshoot](#faq--troubleshoot) - -## Installation - -[![Anaconda-Server Badge](https://anaconda.org/conda-forge/keplergl/badges/version.svg)](https://anaconda.org/conda-forge/keplergl) [![PyPI version](https://badge.fury.io/py/keplergl.svg)](https://badge.fury.io/py/keplergl) - -### 1. For Jupyter Notebook - -#### Using conda: - -```shell -conda install -c conda-forge keplergl -``` - -##### Prerequisites - - Python >= 3.7 - -#### Using pip: - -```shell -pip install keplergl -``` - -##### Prerequisites - - For kelplergl <= 0.3.0 - - Python >= 2 - - ipywidgets >= 7.0.0 - -If you're on Mac, used `pip install`, and you're running Notebook 5.3 and above, you don't need to run the following: - -```shell -jupyter nbextension install --py --sys-prefix keplergl # can be skipped for notebook 5.3 and above -jupyter nbextension enable --py --sys-prefix keplergl # can be skipped for notebook 5.3 and above -``` - -NOTE: For No Module named 'keplergl' error, please make sure your virtual environment is activated and has been added to the Jupyter kernel. - -Use the following command to check the kernel list: -```shell -jupyter kernelspec list -``` - -Use the following command to add the virtual environment to the Jupyter kernel: -```shell -python -m ipykernel install --user --name=myenv -``` - -The `--name` parameter is your preferred name to identify the virtual environment - - -### 2. For Google Colab: - -`keplergl` (>0.3.0) works with Google Colab. You can install it using pip. - -```python -# Install keplergl (>0.3.0) -!pip install keplergl -``` - -### 3. For JupyterLab - -#### JupyterLab 3 - -NOTE: `keplergl` <=0.3.0 doesn't work with JupyterLab 3. You need to make sure the python package `keplergl` > 0.3.0 is installed. - -Installation using pip: -```shell -pip install keplergl -``` -Installation using conda: -```shell -conda install keplergl -``` - -There is no need to use `jupyter labextension install` for `keplergl` > 0.3.0 with JupyterLab3. - -#### JupyterLab 1 - -For JupyterLab1, you need to install `keplergl-jupyter` labextension from NPM registry. There is no need to install `keplergl` python package. - -First, install `jupyterlab-manager` for JupyterLab1: -```shell -jupyter labextension install @jupyter-widgets/jupyterlab-manager@1.1 -``` - -Then, install `keplergl-jupyter` labextension from NPM registry: -```shell -jupyter labextension install keplergl-jupyter -``` - -##### Prerequisites: - - Node >= 12 - - Python 3 - -#### JupyterLab 2 - -For JupyterLab2, you need to install `keplergl-jupyter` labextension from NPM registry. There is no need to install `keplergl` python package. - -First, install `jupyterlab-manager` for JupyterLab2: -```shell -jupyter labextension install @jupyter-widgets/jupyterlab-manager@2 -``` - -To install `keplergl-jupyter` from NPM registry, JupyterLab2 has following requirements of dependencies: -``` -JupyterLab Extension Package ->=16.9.0 <16.10.0 >=17.0.0 <18.0.0 react ->=16.9.0 <16.10.0 >=17.0.0 <18.0.0 react-dom -``` - -However, `keplergl-jupyter`<=0.3.0 depends on `react` >= 17.0.2. Therefore, the latest `keplergl-jupyter` can’t be installed with JupyterLab2: if you use `jupyter labextension install keplergl-jupyter`, the version 0.2.2 as a fallback will be installed. Unfortunately, version 0.2.2 does NOT work with JupyterLab2. - -A workaround is to modify the file `lib/python3.x/site-packages/jupyterlab/staging/package.json` and remove “react” and “react-dom” from “singletonPackages” object. Then, install keplergl-jupyter using this command: -``` -jupyter labextension install keplergl-jupyter -``` - -##### Prerequisites: - - Node >= 12 - - Python 3 - -## Quick Start - -### For Jupyter Notebook and JupyterLab: - -NOTE: please make sure the python kernel is correctly specified in the notebook. - -```python -# Load kepler.gl with an empty map -from keplergl import KeplerGl -map_1 = KeplerGl(height=400) -map_1 - -# Load kepler.gl with map data and config -# Since keplergl 0.3.4, you can pass `use_arrow=True` to load and render data faster using GeoArrow, e.g. `KeplerGl(data={'data_1': df}, config=config, use_arrow=True)` -map_2 = KeplerGl(height=400, data={'data_1': df}, config=config) -map_2 - -# Add data to map -# Since keplergl 0.3.4, you can pass `use_arrow=True` to load and render data faster using GeoArrow, e.g. `map_1.add_data(df, 'data_1', use_arrow=True)` -map_1.add_data(df, 'data_1') - -# Apply config -map_1.config(config) - -# print data and config -map_1.data -map_1.config - -# save map to html -map_1.save_to_html(file_name='keplergl_map.html') -``` - -### For Google Colab: - -Keplergl (>0.3.0) works with Google Colab. You can install it using pip. - -```python -# Install keplergl (>0.3.0) -!pip install keplergl - -# Load Kepler.gl with an empty map -from keplergl import KeplerGl -map_1 = KeplerGl() - -# Display map -map_1.show() -``` - -The function `show()` is newly introduced for displaying map in Google Colab. The function is defined as: -```python -def show(self, data=None, config=None, read_only=False, center_map=False) -``` -with input parameters: -- data: a data dictionary {"name": data}, if not provided, will use current map data -- config: map config dictionary, if not provided, will use current map config -- read_only: if read_only is True, hide side panel to disable map customization -- center_map: if center_map is True, the bound of the map will be updated according to the current map data - -Please note that the map is not interactive due to the limitation of Google Colab. For example, when applying config to the map in Colab, the map won't be updated and one needs to call `show()` again to render a new map in a new cell. - -## Demo Notebooks -- [Load kepler.gl](https://github.com/keplergl/kepler.gl/blob/master/bindings/kepler.gl-jupyter/notebooks/Load%20kepler.gl.ipynb): Load kepler.gl widget, add data and config -- [Geometry as String](https://github.com/keplergl/kepler.gl/blob/master/bindings/kepler.gl-jupyter/notebooks/Geometry%20as%20String.ipynb): Embed Polygon geometries as `GeoJson` and `WKT` inside a `CSV` -- [GeoJSON](https://github.com/keplergl/kepler.gl/blob/master/bindings/kepler.gl-jupyter/notebooks/GeoJSON.ipynb): Load GeoJSON to kepler.gl -- [DataFrame](https://github.com/keplergl/kepler.gl/blob/master/bindings/kepler.gl-jupyter/notebooks/DataFrame.ipynb): Load DataFrame to kepler.gl -- [GeoDataFrame](https://github.com/keplergl/kepler.gl/blob/master/bindings/kepler.gl-jupyter/notebooks/GeoDataFrame.ipynb): Load GeoDataFrame to kepler.gl - - -https://docs.kepler.gl/docs/keplergl-jupyter#1-load-keplergl-map -## Usage - - [1. Load kepler.gl](https://docs.kepler.gl/docs/keplergl-jupyter#1-load-keplergl-map) - - [`keplergl.KeplerGl()`](https://docs.kepler.gl/docs/keplergl-jupyter#keplergl) - - [2. Add Data](https://docs.kepler.gl/docs/keplergl-jupyter#2-add-data) - - [`.add_data()`](https://docs.kepler.gl/docs/keplergl-jupyter#add_data) - - [`.data`](https://docs.kepler.gl/docs/keplergl-jupyter#data) - - [3. Data Format](https://docs.kepler.gl/docs/keplergl-jupyter#3-data-format) - - [`CSV`](https://docs.kepler.gl/docs/keplergl-jupyter#csv) - - [`GeoJSON`](https://docs.kepler.gl/docs/keplergl-jupyter#geojson) - - [`DataFrame`](https://docs.kepler.gl/docs/keplergl-jupyter#dataframe) - - [`GeoDataFrame`](https://docs.kepler.gl/docs/keplergl-jupyter#geodataframe) - - [`WKT`](https://docs.kepler.gl/docs/keplergl-jupyter#wkt) - - [4. Customize the map](https://docs.kepler.gl/docs/keplergl-jupyter#4-customize-the-map) - - [5. Save and load config](https://docs.kepler.gl/docs/keplergl-jupyter#5-save-and-load-config) - - [`.config`](https://docs.kepler.gl/docs/keplergl-jupyter#config) - - [6. Match config with data](https://docs.kepler.gl/docs/keplergl-jupyter#6-match-config-with-data) - - [7. Save Map](https://docs.kepler.gl/docs/keplergl-jupyter#7-save-map) - - [`.save_to_html()`](https://docs.kepler.gl/docs/keplergl-jupyter#save_to_html) - -## Local Development Setup - -### Environment Setup -You will need to install node, yarn and Jupyter Notebook. - -#### 1. Node and Yarn -Install [node](https://nodejs.org/en/download/package-manager/#macos) `> 12`, and [yarn](https://yarnpkg.com/en/docs/install#mac-stable). Use [nvm](https://github.com/creationix/nvm) for better node version management e.g. `nvm install 12`. - - -#### 2. Install Jupyter - -- Using conda -```shell -conda install jupyter -conda install notebook 6.0.1 -``` - -- Using pip - -```shell -pip install jupyter -pip install notebook==6.0.1 -``` - -#### 3. Install GeoPandas - -- Using conda -```shell -conda install geopandas -``` - -- Using pip - -```shell -pip install geopandas -``` - -### Download and run keplergl in your local Jupyter Notebook - -#### Clone Repo -```shell -git clone https://github.com/keplergl/kepler.gl.git -``` - -### Setup JS -#### 1. Install Js module -```sh -cd bindings/kepler.gl-jupyter -cd js -yarn -``` - -#### 2. Load mapbox token -Add [Mapbox access token](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/) to Node env. - -```sh -export MapboxAccessTokenJupyter= -``` - -#### 3. Build js module, start a local server to watch for changes - -```shell -npm start -``` - -You need to run step 2 and 3 to restart the js program. And step 1-3 if any js dependency has changed (Usually after pulling new changes from master). - -### Setup jupyter - -#### 1. Install python module and enable extension from local files -This command must be run **AFTER** the `js` setup, and folder `static/` was created. It only needs to be run once. - -```sh -# dev install from folder containing setup.py -pip install -e . - -# only needed in dev mode, not in normal mode. -jupyter nbextension install --py --symlink --sys-prefix keplergl - -# only needed in dev mode, not in normal mode. -jupyter nbextension enable --py --sys-prefix keplergl -``` - -NOTE: The above command `jupyter nbextension install -py --symlink --sys-prefix keplergl` is trying to create a symbolic link of the folder `bindings/kepler.gl-jupyter/keplergl/static` under the jupyter's folder `nbextensions`. Please check if there is already a folder "nbextensions/kepler-jupyter" existed, and you might need to remove it first. - -To find the location of `nbextensions` folder, you can use the following command: -```shell -$ where jupyter -/Users/test/opt/anaconda3/envs/test37/bin/jupyter - -# the nbextensions should be at: /Users/test/opt/anaconda3/envs/test37/share/jupyter/nbextensions -``` - - -#### 2. Start jupyter notebook - -```shell -cd notebooks -jupyter notebook -``` - - -#### Have fun! - -You can now start editing the .js and .py files to see changes reflected in your local notebook. After changing files in the js folder, the local start script will recompile the js files and put them in to `keplergl/static` folder. You need to reload the jupyter notebook page to reload the files. - - -#### 3. Development for JupyterLab - -To test the development work in previous 2 steps for JupyterLab. You can build the `keplergl labextension` under the `js` directory: - -```shell -jupyter labextension build . -``` - -The output of the jupyter labextension is defined in the file `js/package.json`: -```javascript -... -"jupyterlab": { - "extension": "babel/labplugin", - "outputDir": "../keplergl-jupyter/labextension", - "sharedPackages": { - "@jupyter-widgets/base": { - "bundled": false, - "singleton": true - } - } -} -``` - -Then, you can either install this labextension to test it: -```shell -jupyter labextension install . -``` -or, you can manually create a symbolic link for the folder `bindings/kepler.gl-jupyter/kepler-jupyter/labextension` under the jupyter's folder `labextensions`, e.g. `/Users/test/opt/anaconda3/envs/test37/share/jupyter/labextensions`. You will need to reload the jupyter lab page. - -[jupyter_widget]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_widget.png -[empty_map]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_empty_map.png -[geodataframe_map]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_geodataframe.png -[map_interaction]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_custom_map.gif -[load_map_w_data]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_load_map_w_data.gif -[map_add_data]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_add_data.png -[connect_data_config]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_connect_data_w_config.png -[save_widget_state]: https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/documentation/jupyter_save_state.png - -[wkt]: https://dev.mysql.com/doc/refman/5.7/en/gis-data-formats.html#gis-wkt-format -[geojson]: https://tools.ietf.org/html/rfc7946 -[feature_collection]: https://tools.ietf.org/html/rfc7946#section-3.3 -[features]: https://tools.ietf.org/html/rfc7946#section-3.2 -[data_frame]: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.html -[geo_data_frame]: https://geopandas.readthedocs.io/en/latest/data_structures.html#geodataframe - -[match-config-w-data]: #match-config-with-data -[data_format]: #3-data-format diff --git a/bindings/kepler.gl-jupyter/RELEASE.md b/bindings/kepler.gl-jupyter/RELEASE.md deleted file mode 100644 index 98af134976..0000000000 --- a/bindings/kepler.gl-jupyter/RELEASE.md +++ /dev/null @@ -1,55 +0,0 @@ -# Kepler.gl Jupyter Releases - -## Release a new version - -When release a new version, the `keplergl-jupyter` js module will be published on NPM and the `keplergl` python module will be published on PyPI. - -NOTE: __Version number of the js module **`kelergl-jupyter`** and the python module **`keplergl`** should match__ - -### Step1: - -Update `version_info` in keplergl/_version.py in bindings/kepler.gl-jupyter folder. -Update `"version": "0.x.x"` to match the version info in js/package.json in bindings/kepler.gl-jupyter folder. -Update `EXTENSION_SPEC_VERSION` to match the js module version. - -``` -git add keplergl/_version.py -git add js/package.json -git commit -am "keplergl==" -``` - - -### Step2: - -Create a tag: `-jupyter` e.g. v0.3.4-jupyter - -``` -git tag -a -jupyter -m "-jupyter" -git push origin -jupyter -``` - -The new tag will trigger the Github Action `build-publish-pypi.yml`: __"Build KeplerGL Python and NPM packages"__. The packages will be built and tested, then published to NPM and PyPI using the secret tokens. - -### Step3: - -For conda-forge release, please use the repo: https://github.com/conda-forge/keplergl-feedstock - -The new version should be automatically picked and built from PyPi by conda-forge. If you want to submit a manual build: - -Edit `meta.yaml` under directory `recipes/`: - -* Update the version number - -```python -{% set version = "0.3.0" %} -``` - -* Update the sha256 value of the latest tarball in PyPi that is published in Step2. - -```python -source: - url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/{{ name }}-{{ version }}.tar.gz - sha256: cb21047b2104413af1c00ef1ac75794a19e0b578e51c69c86713911d97370167 -``` - -* Create a pull request and wait for checking from conda-forge team. diff --git a/bindings/kepler.gl-jupyter/js/.gitignore b/bindings/kepler.gl-jupyter/js/.gitignore deleted file mode 100644 index 12df7c4fdd..0000000000 --- a/bindings/kepler.gl-jupyter/js/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -node_modules/ -dist/ -temp.* -babel/ - -yarn-error.log -package-lock.json diff --git a/bindings/kepler.gl-jupyter/js/README.md b/bindings/kepler.gl-jupyter/js/README.md deleted file mode 100644 index d80e3fa866..0000000000 --- a/bindings/kepler.gl-jupyter/js/README.md +++ /dev/null @@ -1,67 +0,0 @@ -# keplergl-jupyter - -This is a simple jupyter widget for kepler.gl, an advanced geospatial visualization tool, to render large-scale interactive maps. - -## Package Install - ---- - -**Prerequisites** - -- [node](http://nodejs.org/) >=8.15.0 -- [yarn](https://yarnpkg.com/en/docs/install#mac-stable) >=1.6.0 - -**More links** - -- [Jupyter Widget](https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Custom.html) -- [Widget Cookiecutter](https://github.com/jupyter-widgets/widget-cookiecutter) - -## Local Dev - ---- - -### Local Dev Installation for Classic Notebook - -To develop this package against the classic notebook, run: - -- `pip install -e .` (installs python package for development, runs `npm install` and `npm run build`) -- `jupyter nbextension install --py --symlink --sys-prefix keplergl`\ - (symlinks `static/` directory into `/nbextensions/keplergl/`). Now the notebook has access to the frontend code. -- `jupyter nbextension enable --py --sys-prefix keplergl`\ - (copies `.json` into `/etc/jupyter/nbconfig/notebook.d/` directory). Now the notebook will load your frontend code on page load. - -Now make some changes to your source code. Then: - -- After making Python code changes, restarting the notebook kernel will be enough to reflect changes -- After making JavaScript code changes: - - `cd js` - - `npm run build` - - Refresh browser to reflect changes - -### Local Dev Installation for JupyterLab - -To develop this package against JupyterLab, run: - -- `pip install -e .` (installs python package for development, runs `npm install` and `npm run build`) -- `jupyter labextension install @jupyter-widgets/jupyterlab-manager`: this install lab widgets manager. -- `jupyter labextension install js`: this installs the current labextension into JupyterLab and enables it. -- `jupyter lab --watch` starts JupyterLab, but in `--watch` mode: it will rebuild itself incrementally if it detects changes. - -Now make some changes to your source code. Then: - -- After making Python code changes, restarting the notebook kernel will be enough to reflect changes -- After making JavaScript code changes: - - - `cd js` - - `npm run build:lab` - - Refresh browser to reflect changes - -- By default, the application will load from the JupyterLab staging directory (default is /share/jupyter/lab/staging. Check the correct version of `@jupyter-widgets/jupyterlab-manager` and `@jupyter-widgets/base` is install in `yarn.lock` - -#### JupyterLab widget Dependencies - -Install correct version of jupyterlab-manager based on your Jupyter Lab version. Make sure `@jupyter-widgets/base` version in the widget does not conflict with requirements in `jupyterlab-manager`. - -- [@jupyter-widgets/jupyterlab-manager](https://github.com/jupyter-widgets/ipywidgets/tree/master/packages/jupyterlab-manager) -- [@jupyter-widgets/base](https://github.com/jupyter-widgets/ipywidgets/tree/master/packages/base) -- [@jupyter-widgets/base-manager](https://github.com/jupyter-widgets/ipywidgets/tree/master/packages/base-manager) diff --git a/bindings/kepler.gl-jupyter/js/babel.config.js b/bindings/kepler.gl-jupyter/js/babel.config.js deleted file mode 100644 index 67f44c4dd3..0000000000 --- a/bindings/kepler.gl-jupyter/js/babel.config.js +++ /dev/null @@ -1,35 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright contributors to the kepler.gl project - -const KeplerPackage = require('./package'); - -module.exports = function babel(api) { - api.cache(true); - - const presets = ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript']; - const plugins = [ - '@babel/plugin-transform-modules-commonjs', - '@babel/plugin-transform-class-properties', - '@babel/plugin-transform-optional-chaining', - '@babel/plugin-transform-logical-assignment-operators', - '@babel/plugin-transform-nullish-coalescing-operator', - '@babel/plugin-transform-export-namespace-from', - 'transform-inline-environment-variables', - [ - 'search-and-replace', - { - rules: [ - { - search: '__PACKAGE_VERSION__', - replace: KeplerPackage.version - } - ] - } - ] - ]; - - return { - presets, - plugins - }; -}; diff --git a/bindings/kepler.gl-jupyter/js/lib/embed.js b/bindings/kepler.gl-jupyter/js/lib/embed.js deleted file mode 100644 index ff8142f6e5..0000000000 --- a/bindings/kepler.gl-jupyter/js/lib/embed.js +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright contributors to the kepler.gl project - -// Entry point for the unpkg bundle containing custom model definitions. -// -// It differs from the notebook bundle in that it does not need to define a -// dynamic baseURL for the static assets and may load some css that would -// already be loaded by the notebook otherwise. - -// Export widget models and views, and the npm package version number. -module.exports = require('./keplergl-plugin'); -module.exports.version = require('../package.json').version; diff --git a/bindings/kepler.gl-jupyter/js/lib/extension.js b/bindings/kepler.gl-jupyter/js/lib/extension.js deleted file mode 100644 index b028cf0944..0000000000 --- a/bindings/kepler.gl-jupyter/js/lib/extension.js +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright contributors to the kepler.gl project - -// This file contains the javascript that is run when the notebook is loaded. -// It contains some requirejs configuration and the `load_ipython_extension` -// which is required for any notebook extension. -// -// Some static assets may be required by the custom widget javascript. The base -// url for the notebook is not known at build time and is therefore computed -// dynamically. - -/* eslint-disable no-undef */ -__webpack_public_path__ = `${document.querySelector('body').getAttribute('data-base-url') }nbextensions/keplergl-jupyter`; -/* eslint-enable no-undef */ - -// Configure requirejs -if (window.require) { - window.require.config({ - map: { - "*" : { - "keplergl-jupyter": "nbextensions/keplergl-jupyter/index" - } - } - }); -} - -// Export the required load_ipython_extension -module.exports = { - load_ipython_extension() {} -}; diff --git a/bindings/kepler.gl-jupyter/js/lib/index.js b/bindings/kepler.gl-jupyter/js/lib/index.js deleted file mode 100644 index d4d59be3b1..0000000000 --- a/bindings/kepler.gl-jupyter/js/lib/index.js +++ /dev/null @@ -1,6 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright contributors to the kepler.gl project - -// Export widget models and views, and the npm package version number. -module.exports = require('./keplergl-plugin'); -module.exports.version = require('../package.json').version; diff --git a/bindings/kepler.gl-jupyter/js/lib/keplergl-plugin.js b/bindings/kepler.gl-jupyter/js/lib/keplergl-plugin.js deleted file mode 100644 index dc9951fce2..0000000000 --- a/bindings/kepler.gl-jupyter/js/lib/keplergl-plugin.js +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright contributors to the kepler.gl project - -import * as widgets from '@jupyter-widgets/base'; -import KeplerGlJupyter from './keplergl/kepler.gl'; -import log from './log'; - -// Custom Model. Custom widgets models must at least provide default values -// for model attributes, including -// -// - `_view_name` -// - `_view_module` -// - `_view_module_version` -// -// - `_model_name` -// - `_model_module` -// - `_model_module_version` -// -// when different from the base class. - -// When serializing the entire widget state for embedding, only values that -// differ from the defaults will be specified. -// Note: in JavaScript, class.extend does not inherently inherit static functions. -export class KeplerGlModal extends widgets.DOMWidgetModel { - defaults() { - return { - ...super.defaults(), - _model_name: 'KeplerGlModal', - _model_module: 'keplergl-jupyter', - _view_name: 'KeplerGlView', - _view_module: 'keplergl-jupyter', - data: {}, - config: {} - }; - } -} - -export class KeplerGlView extends widgets.DOMWidgetView { - render() { - log('KeplerGlModal start render'); - this.keplergl = new KeplerGlJupyter(); - - this.keplergl.create(this); - - // event listener - this.model.on('change:data', this.data_changed, this); - this.model.on('change:config', this.config_changed, this); - - window.dom = this.el; - } - - data_changed() { - log('KeplerGlModal start data_changed'); - - this.keplergl.onDataChange(this); - } - - config_changed() { - log('KeplerGlModal start config_change'); - - this.keplergl.onConfigChange(this); - } -} diff --git a/bindings/kepler.gl-jupyter/js/lib/keplergl/components/app.js b/bindings/kepler.gl-jupyter/js/lib/keplergl/components/app.js deleted file mode 100644 index d013d5f2d2..0000000000 --- a/bindings/kepler.gl-jupyter/js/lib/keplergl/components/app.js +++ /dev/null @@ -1,136 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright contributors to the kepler.gl project - -import React, {useEffect, useState, useRef} from 'react'; -import styled from 'styled-components'; -const ReactHelmet = require('react-helmet'); -const Helmet = ReactHelmet ? ReactHelmet.Helmet : null; - -import { - SidebarFactory, - AddDataButtonFactory, - PanelHeaderFactory, - CustomPanelsFactory, - injectComponents -} from '@kepler.gl/components'; - -import CustomPanelHeaderFactory from './panel-header'; -import CustomSidebarFactory from './side-bar'; -import CustomCustomPanelsFactory from './config-panel'; -export const KEPLER_GL_JUPYTER_VERSION = '__PACKAGE_VERSION__'; - -const CustomAddDataButtonFactory = () => { - const CustomAddDataButton = () =>
; - return CustomAddDataButton; -}; - -const KeplerGl = injectComponents([ - [AddDataButtonFactory, CustomAddDataButtonFactory], - [SidebarFactory, CustomSidebarFactory], - [PanelHeaderFactory, CustomPanelHeaderFactory], - [CustomPanelsFactory, CustomCustomPanelsFactory] -]); - -const MAPBOX_TOKEN = process.env.MapboxAccessTokenJupyter; // eslint-disable-line - -const StyledContainer = styled.div` - width: 100%; - height: 100%; - .kepler-gl .ReactModal__Overlay.ReactModal__Overlay--after-open { - position: absolute !important; - } - - .kepler-gl .side-panel__content > div { - display: flex; - height: 100%; - flex-direction: column; - } -`; - -function App() { - const rootElm = useRef(null); - const [windowDimension, setDimension] = useState({}); - - const handleResize = () => { - if (!rootElm.current) { - return; - } - - const width = rootElm.current.offsetWidth; - const height = rootElm.current.offsetHeight; - const dimensionToSet = { - ...(width && width !== windowDimension.width ? {width} : {}), - ...(height && height !== windowDimension.height ? {height} : {}) - }; - - setDimension(dimensionToSet); - }; - - // in Jupyter Lab, parent component has transition when window resize. - // need to delay call to get the final parent width, - const resizeDelay = () => window.setTimeout(handleResize, 500); - - useEffect(() => { - window.addEventListener('resize', resizeDelay); - handleResize(); - return () => window.removeEventListener('resize', resizeDelay); - }, []); - - return ( - - {Helmet ? ( - - - - - - - - - ) : null} - - - ); -} - -export default App; diff --git a/bindings/kepler.gl-jupyter/js/lib/keplergl/components/config-panel.js b/bindings/kepler.gl-jupyter/js/lib/keplergl/components/config-panel.js deleted file mode 100644 index 11b6494fc3..0000000000 --- a/bindings/kepler.gl-jupyter/js/lib/keplergl/components/config-panel.js +++ /dev/null @@ -1,102 +0,0 @@ -// SPDX-License-Identifier: MIT -// Copyright contributors to the kepler.gl project - -import React, {useState} from 'react'; - -import {Button, Icons, TextArea, withState} from '@kepler.gl/components'; -import {KeplerGlSchema} from '@kepler.gl/schemas'; -import {visStateLens, mapStateLens, mapStyleLens} from '@kepler.gl/reducers'; -import {CopyToClipboard} from 'react-copy-to-clipboard'; -import styled from 'styled-components'; - -const Params = { - true: 'True', - false: 'False', - null: 'None' -}; - -export const StyleCopyConfig = styled.div.attrs({ - className: 'copy-config' -})` - width: 100%; - display: flex; - flex-direction: column; - height: 100%; - .copy-button { - position: absolute; - margin-top: -45px; - right: 28px; - } - textarea { - overflow-y: scroll; - white-space: pre-wrap; - width: 100%; - height: 100%; - resize: none; - } -`; - -// convert config from string to pything dictionary -function configStringify(config) { - // replace true => True; false => False; null => None - const configStr = JSON.stringify(config, null, 2); - return configStr.replace(/: ([a-z]+)/g, function(_, key) { - return ': ' + Params[key] || ': ' + key; - }); -} - -export const CopyConfig = ({config}) => { - const [copied, setCopy] = useState(false); - const value = configStringify(config); - return ( - - setCopy(true)} className="copy-button"> - - -