Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: add map chart components #7

Merged
merged 40 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f009e62
refact!(charts): re-structure types to make non-categorical chart typ…
davidlougheed Aug 21, 2023
7a73f7e
chore(deps): add dependencies for maps
davidlougheed Aug 21, 2023
73f71e7
chore(deps): add react-leaflet types
davidlougheed Aug 21, 2023
edd02da
feat(charts): add BentoPointMap component
davidlougheed Aug 21, 2023
e823add
chore(charts): tweak point model for point map
davidlougheed Aug 21, 2023
2f83b5e
feat(maps): add BentoChoroplethMap component
davidlougheed Sep 18, 2023
42e11a7
test: add test site with webpack builder
davidlougheed Sep 18, 2023
7d93bdb
lint
davidlougheed Sep 18, 2023
2170826
lint: eslint
davidlougheed Sep 18, 2023
c5f157d
fix(package): lint script
davidlougheed Sep 18, 2023
e2ce908
lint: replace some import with import type
davidlougheed Sep 18, 2023
ae407b1
fix(package): add geojson peer dep
davidlougheed Sep 18, 2023
13d2c3b
chore(maps): support discrete legends in choropleth
davidlougheed Sep 18, 2023
a49f620
lint
davidlougheed Sep 18, 2023
3a54015
style(maps): consistent styling between map popups
davidlougheed Sep 18, 2023
da9c650
test: rename test data file
davidlougheed Sep 19, 2023
cdf6a89
fix(maps): allow addl arbitrary props in geojson feature collection
davidlougheed Sep 19, 2023
6796983
chore(maps): support custom choropleth popup body rendering
davidlougheed Sep 19, 2023
74e84d0
lint
davidlougheed Sep 19, 2023
5d90f08
fix(maps): various issues with BentoPointMap
davidlougheed Sep 19, 2023
b0452a0
test(maps): use antd for styling + add point map test
davidlougheed Sep 19, 2023
c7aad02
refact(maps): factor out bento map container component
davidlougheed Sep 19, 2023
d513aa6
refact(maps): move base map components into Maps folder
davidlougheed Sep 19, 2023
cc94ccf
docs: rewrite intro and mention testing server
davidlougheed Sep 19, 2023
2d8173c
chore(deps): move geojson to be a non-peer dependency
davidlougheed Sep 19, 2023
f60ca3b
chore(package): add webpack dev server script as `npm test`
davidlougheed Sep 21, 2023
c20e846
fix(maps): missing dependency in useCallback
davidlougheed Sep 21, 2023
90b80ac
lint(maps): rename geojson shape onclick function type
davidlougheed Sep 21, 2023
99362bf
feat(maps): configurable tile layer react element
davidlougheed Sep 21, 2023
c0f2110
refact(maps): separate map types&components from main pkg
davidlougheed Sep 21, 2023
3e53331
chore(package): mark leaflet dependencies as optional & lint
davidlougheed Sep 21, 2023
9031bb2
chore(package): move geojson to dev dependencies
davidlougheed Sep 21, 2023
90a679a
chore(package): mark leaflet peer deps as optional in lockfile
davidlougheed Sep 21, 2023
a4b6414
refact(maps): use leaflet ControlPosition type for legends
davidlougheed Sep 21, 2023
cce8149
docs: document importing maps in README
davidlougheed Sep 25, 2023
9ffbb3d
docs: spacing
davidlougheed Sep 25, 2023
78d6ea4
docs: mention map props and which components are available
davidlougheed Sep 27, 2023
23f9871
chore(maps): add filter/map transforms for choropleth map
davidlougheed Sep 27, 2023
e498d3d
lint(maps)
davidlougheed Sep 27, 2023
5b3ef40
test: add chartconfigprovider to test app
davidlougheed Sep 27, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules/*
test/
.DS_Store
.idea/
.vscode/
117 changes: 94 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,37 @@
[![Coverage Status](https://coveralls.io/repos/github/bento-platform/Bento-Charts/badge.svg?branch=master)](https://coveralls.io/github/bento-platform/Bento-Charts?branch=master)
[![npm version](https://badge.fury.io/js/bento-charts.svg)](https://badge.fury.io/js/bento-charts)

This repository hosts the code for Bento-Charts, a library in React, TypeScript and Recharts.
This repository hosts the code for `bento-charts`, a library written in TypeScript for React projects, which wraps
Recharts and Leaflet in easy-to-use components compatible with the Bento platform.

The following components are currently available:

* Bar chart
* Pie chart
* Choropleth map
* Point map


Bento charts offers Bar and Pie charts for Bento project UI web applications in React.

## Installation
Add Bento-Charts as a dependency to another project:

Add `bento-charts` as a dependency to another project:

```bash
npm install bento-charts
```

To install `bento-charts` with map support:

```bash
npm install bento-charts leaflet react-leaflet
```



## Usage
Wrap your app in the ChartConfigProvider and pass in the Language of your site.

Wrap your app in the `ChartConfigProvider` and pass in the Language of your site.

```jsx
import { ChartConfigProvider } from 'bento-charts';
Expand All @@ -40,26 +58,60 @@ You also can provide your own theme and translation dictionary.
<App />
</ChartConfigProvider>
```
refer to [theme](https://github.com/bento-platform/Bento-Charts/blob/eee46541eec68e2dd7f62f8d786148480ce5105f/src/types/chartTypes.ts#L20) and [translations](https://github.com/bento-platform/Bento-Charts/blob/eee46541eec68e2dd7f62f8d786148480ce5105f/src/types/chartTypes.ts#L47) for more information.
## Using a Chart
refer to [theme](https://github.com/bento-platform/Bento-Charts/blob/main/src/types/chartTypes.ts#L20)
and [translations](https://github.com/bento-platform/Bento-Charts/blob/main/src/types/chartTypes.ts#L47)
for more information.

Right now, no properties from `ChartConfigProvider` are used for any map components, but they may do so in the future.


## Usage

### Using a Chart

```jsx
import { BarChart, PieChart } from 'bento-charts';
```
Refer to [Props](https://github.com/bento-platform/Bento-Charts/blob/eee46541eec68e2dd7f62f8d786148480ce5105f/src/types/chartTypes.ts#L51) for information on their props.
Refer to [Props](https://github.com/bento-platform/Bento-Charts/blob/main/src/types/chartTypes.ts#L51)
for information on their props.


### Using a Map

Maps can be imported using a command like the following:

```jsx
import { ChoroplethMap } from 'bento-charts/maps';
```

Here, note the sub-path on the import - this separation allows us to have the
map-related peer dependencies marked as "optional".

The following map components are available:

* `ChoroplethMap` for showing a choropleth map, coloured by
* `PointMap` (for showing a list of point coordinates; this uses a different data structure than the other components)

See [map component properties](https://github.com/bento-platform/bento_charts/blob/main/src/types/mapTypes.ts)
for more information.



## Release procedure

A commit on the `main` branch will trigger a build and release of the package to the npm Registry, no need to manually create tags thanks to semantic-release.
A commit on the `main` branch will trigger a build and release of the package to the npm Registry, no need to manually
create tags thanks to semantic-release.

**Please follow the instructions bellow when writing your commits.**


### Semantic release
Bento-Charts adheres to the [semver](https://semver.org/) versioning convention (Semantic Versioning). This repository uses the
[semantic-release](https://github.com/semantic-release/semantic-release) library to automate the release of semver compliant packages to
the npm Registry.

Semantic-release parses the commit messages in the release branch in order to determine the versioning changes. It does not rely on magic to work, but rather on specific commit message formats, which are described bellow.
Semantic-release parses the commit messages in the release branch in order to determine the versioning changes. It does
not rely on magic to work, but rather on specific commit message formats, which are described bellow.

### Commit message guidelines
Semantic-release uses the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification in order to parse relevant information.
Expand Down Expand Up @@ -93,9 +145,12 @@ After adding unit tests to the charts
test(charts): add unit tests for mixbarchart
```

## Commit with commitlint
[Commitlint](https://commitlint.js.org/#/) is a safeguard for commit message formats, which you can use to help write semver
compliant commits. [Husky](https://github.com/typicode/husky) is a git hooks tool that binds commitlint to the `git commit` command.


## Commit with `commitlint`

[Commitlint](https://commitlint.js.org/#/) is a safeguard for commit message formats, which you can use to help write
semver-compliant commits. [Husky](https://github.com/typicode/husky) is a git hooks tool that binds commitlint to the `git commit` command.

### Installation
Run these steps once to setup commitlint + husky.
Expand All @@ -116,24 +171,40 @@ Example:
git commit -m "ci(semantic-release): add commitlint and husky as dev tools to write valid commits"
```



## Local development

For local development in a React/Recharts app that uses bento-charts, you can follow these steps for your setup:

1. `build` and `pack` bento-charts
```bash
# Builds package and creates a pack file in the "./packs" dir
npm run buildpack
```
```bash
# Builds package and creates a pack file in the "./packs" dir
npm run buildpack
```

2. In the project using bento-charts, modify the bento-charts dependency in package.json so that the version number is now the absolute path to the pack file.
```diff
- "bento-charts": "2.0.0",
+ "bento-charts": "file:~/bento-charts/packs/bento-charts-2.0.0.tgz",
```
```diff
- "bento-charts": "2.0.0",
+ "bento-charts": "file:~/bento-charts/packs/bento-charts-2.0.0.tgz",
```

3. Install the dependencies in the project
```bash
npm install
```

**Note: you will need to repeat steps 1 and 3 everytime you want the changes to be applied to the app using
`bento-charts`**



## Testing
davidlougheed marked this conversation as resolved.
Show resolved Hide resolved

A small web application is included in the `test` folder to provide an easy manual testing bed for components.

This application can be launched with the following command:

```bash
npm install
npm test
```

**Note: you will need to repeat steps 1 and 3 everytime you want the changes to be applied to the app using bento-charts**
Loading