2.6.8 • Published 2 months ago

bento-charts v2.6.8

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Bento Charts

Coverage Status npm version

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

Installation

Add bento-charts as a dependency to another project:

npm install bento-charts

To install bento-charts with map support:

npm install bento-charts leaflet react-leaflet

Usage

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

import { ChartConfigProvider } from 'bento-charts';
<ChartConfigProvider Lng={language}>
  <App />
</ChartConfigProvider>

Language can be either 'en' or 'fr'.

You also can provide your own theme and translation dictionary.

<ChartConfigProvider
  Lng={language}
  theme={theme}
  translations={translations}
>
    <App />
</ChartConfigProvider>

refer to theme and translations 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

import { BarChart, PieChart } from 'bento-charts';

Refer to Props for information on their props.

Using a Map

Maps can be imported using a command like the following:

import { ChoroplethMap } from 'bento-charts/dist/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 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.

Please follow the instructions bellow when writing your commits.

Semantic release

Bento-Charts adheres to the semver versioning convention (Semantic Versioning). This repository uses the 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.

Commit message guidelines

Semantic-release uses the Conventional Commits specification in order to parse relevant information.

<type>(<scope>): <short summary>
  │       │             │
  │       │             └─⫸ Summary in present tense. Not capitalized. No period at the end.
  │       │
  │       └─⫸ Commit Scope: Optional, what was changed.
  │
  └─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test

Both <type> and <short summary> are mandatory, while <scope> is optional, but recommended for pretty release notes.

Example commit messages

After fixing a dependency issue:

fix(dependencies): resolve peer dependencies issues caused by React version

After adding a new Rechart feature:

feat(charts): add support for mixmarchart

After adding unit tests to the charts

test(charts): add unit tests for mixbarchart

Commit with commitlint

Commitlint is a safeguard for commit message formats, which you can use to help write semver-compliant commits. Husky is a git hooks tool that binds commitlint to the git commit command.

Installation

Run these steps once to setup commitlint + husky.

# Install dev dependencies (commitlint & husky)
npm install
# Install husky git hook
npx husky install
# Add commitlint as a hook to husky
npx husky add .husky/commit-msg  'npx --no -- commitlint --edit ${1}'

Usage

Use the git cli as you normally would to make your commits, commitlint will intercept your commit if it is malformed.

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

    # 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.

    - "bento-charts": "2.0.0",
    + "bento-charts": "file:~/bento-charts/packs/bento-charts-2.0.0.tgz",
  3. Install the dependencies in the project

    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

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:

npm test
2.6.8

2 months ago

2.6.7

2 months ago

2.6.6

2 months ago

2.6.5

2 months ago

2.6.4

3 months ago

2.6.3

3 months ago

2.6.2

4 months ago

2.6.1

4 months ago

2.6.0

4 months ago

2.5.1

5 months ago

2.3.0

9 months ago

2.2.0

10 months ago

2.5.0

6 months ago

2.4.1

8 months ago

2.4.0

8 months ago

2.4.2

7 months ago

2.1.1

11 months ago

2.1.0

11 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago