1.9.1 • Published 16 days ago

@oecd-pac/chart v1.9.1

Weekly downloads
-
License
ISC
Repository
github
Last release
16 days ago

OECD chart

OECD Chart library

Getting started

npm install @oecd-pac/chart --save

Then simply import and use the Chart component:

import React from 'react';
import { Chart } from '@oecd-pac/chart';

const App = () => (
  <div style={{ width: '800px', height: '600px' }}>
    <Chart chartId="xxxxxxx" />
  </div>
);

export default App;

The only required prop is chartId but if the corresponding chart is configured to use variables, var1, var2, var3, var4 and var5 can be used as well:

<Chart chartId="xxxxxxx" var1="FRA" var2="USA" />

Note about sizing

A chart does not have an intrinsic size like an image (it can be any size) and therefore the Chart component cannot "guess" the desired size.

By default (if width and height are omitted) the chart will use all available space within its parent container.

A width can be passed (number or string are accepted: e.g.: width={300}, width="300", width="300px", width="50%"...)

The Chart component also accepts a height (number only; any non numerical values will be ignored, e.g.: height="300px", height="50%")

Specifying height or not makes a subtle difference when the chart has controls and this allows two sizing strategies:

Strategy 1: Omit height

The chart will take as much space as it can (within the constraints of the parent container):

<div style={{ width: '100%', maxWidth: '400px', height: '300px' }}>
  <Chart chartId="xxxxxxx" />
</div>
  • Pro: The height of the chart (including controls) is guaranteed.
  • Cons: If the chart contains controls, it is not guaranteed that they will be displayed; the controls might stack (for instance, when the width is very low) and the controls may be automatically hidden as they are considered less important than the chart itself.

Strategy 2: Pass height explicitly

It is important to note that height implicitly means "chart height" (not including potential controls).

When using this approach, the parent container has to use minHeight (not height):

<div style={{ width: '100%', maxWidth: '400px', minHeight: '300px' }}>
  <Chart chartId="xxxxxxx" width={400} height={300} />
</div>
  • Pro: The controls are guaranteed to be displayed, even if the total height of the chart + controls is more than the specified height (300 in the previous example).
  • Con: The total height of the chart + controls is not guaranteed.

Lazy loading

The charts are lazy loaded by befault (when the top edge is 100px from viewport).

It can be disabled using lazyLoad={false}.

Language

When a chart exists in multiple languages, the language prop can be used, e.g.: language="fr".

If omitted (or the requested language has not been configured) the default one will be used.

Web components

Even though this is a React library, the charts can be used in pages / apps that are not React based. For this purpose "web components" are also exported. Note that React (18) and ReactDOM still have to be in scope.

The bundle can be found here: node_modules\@oecd-pac\chart\dist\oecd-chart-latest.js

Once loaded, charts can be used as follow:

<div style="width: 400px; height: 300px">
  <oecd-chart chart-id="xxxxxxx"></oecd-chart>
</div>
1.9.1

16 days ago

1.9.1-new-design

16 days ago

1.9.0

24 days ago

1.8.21

1 month ago

1.8.20

1 month ago

1.8.19-new-design

2 months ago

1.8.19

2 months ago

1.8.18-new-design

2 months ago

1.8.18

2 months ago

1.8.17-new-design

2 months ago

1.8.16-new-design

3 months ago

1.8.16

3 months ago

1.8.15-new-design

4 months ago

1.8.15

4 months ago

1.8.14-new-design

4 months ago

1.8.13-new-design

4 months ago

1.8.13

4 months ago

1.8.14

4 months ago

1.8.12-new-design

5 months ago

1.8.12

5 months ago

1.8.11-new-design

5 months ago

1.8.1

5 months ago

1.8.1-new-design

5 months ago

1.8.11

5 months ago

1.8.0-new-design

5 months ago

1.8.0

5 months ago

1.7.92-new-design

5 months ago

1.7.91

5 months ago

1.7.0-new-design

7 months ago

1.7.9

5 months ago

1.7.8

5 months ago

1.7.6

6 months ago

1.6.59

10 months ago

1.6.91-new-design

7 months ago

1.6.88-new-design

8 months ago

1.6.98-new-design

7 months ago

1.6.97-new-design

7 months ago

1.7.4-new-design

6 months ago

1.7.7-new-design

6 months ago

1.6.9

8 months ago

1.6.8

9 months ago

1.6.7

10 months ago

1.6.6

10 months ago

1.7.1-new-design

7 months ago

1.6.85-new-design

8 months ago

1.6.95-new-design

7 months ago

1.7.5-new-design

6 months ago

1.6.82

8 months ago

1.6.81

8 months ago

1.6.84

8 months ago

1.6.83

8 months ago

1.6.86

8 months ago

1.6.85

8 months ago

1.6.87

8 months ago

1.7.6-new-design

6 months ago

1.6.87-new-design

8 months ago

1.6.95

7 months ago

1.6.94

7 months ago

1.6.99

7 months ago

1.6.98

7 months ago

1.7.8-new-design

5 months ago

1.6.92-new-design

7 months ago

1.6.9-new-design

8 months ago

1.7.2-new-design

6 months ago

1.7.2

6 months ago

1.7.0

7 months ago

1.6.62

10 months ago

1.6.61

10 months ago

1.7.3-new-design

6 months ago

1.7.91-new-design

5 months ago

1.6.96-new-design

7 months ago

1.6.93-new-design

7 months ago

1.6.71

10 months ago

1.6.73

9 months ago

1.6.72

10 months ago

1.6.86-new-design

8 months ago

1.6.99-new-design

7 months ago

1.6.89-new-design

8 months ago

1.6.55

11 months ago

1.6.54

11 months ago

1.6.57

11 months ago

1.6.56

11 months ago

1.6.58

11 months ago

1.6.42

12 months ago

1.6.44

12 months ago

1.6.43

12 months ago

1.6.51

11 months ago

1.6.53

11 months ago

1.6.52

11 months ago

1.6.5

11 months ago

1.6.4

1 year ago

1.6.3

1 year ago

1.6.2

1 year ago

1.5.3

1 year ago

1.6.1

1 year ago

1.5.2

1 year ago

1.6.0

1 year ago

1.5.1

1 year ago

1.5.0

1 year ago

1.6.41

1 year ago

1.4.9

1 year ago

1.4.8

1 year ago

1.4.7

1 year ago

1.4.6

1 year ago

1.4.5

1 year ago

1.4.4

1 year ago

1.4.3

1 year ago

1.4.2

1 year ago

1.2.0

1 year ago

1.3.7

1 year ago

1.3.6

1 year ago

1.3.5

1 year ago

1.3.4

1 year ago

1.3.3

1 year ago

1.4.1

1 year ago

1.3.2

1 year ago

1.4.0

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.3.81

1 year ago

1.3.8

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago