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(chart): create bare entrypoint to reduce bundle size #687

Merged
merged 22 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
f281e5f
feat(chart): create bare entrypoint to reduce bundle size
May 12, 2023
bcbcfb4
refactor(chart): update canvas pointer to using ref
May 15, 2023
6d46264
chore(chart): unregister chartjs features to be bare
May 15, 2023
51108cf
refactor(chart): chart bare entry PR (#691)
wsuwt May 17, 2023
24b31c7
Merge remote-tracking branch 'origin/v7' into chart/new-entrypoint
May 17, 2023
d5983dd
refactor(chart): restructure file to make it cleaner
May 18, 2023
fc72459
docs(chart): rewrite to make it understandable
May 18, 2023
70cdf82
Merge branch 'migrate-chartjs4' into chart/new-entrypoint
May 18, 2023
166d3d1
docs(chart): remove unwanted line break
May 18, 2023
736d3a6
docs(chart): add missing comma
May 18, 2023
ffb4854
Update packages/elements/src/chart/elements/chart.ts
Theeraphat-Sorasetsakul May 18, 2023
a669a5b
Update packages/elements/src/chart/elements/chart.ts
Theeraphat-Sorasetsakul May 18, 2023
5b7b038
docs(chart): remove TODO comment
May 18, 2023
2ae0115
Merge branch 'chart/new-entrypoint' of github.com:Refinitiv/refinitiv…
May 18, 2023
68a2700
Update packages/elements/src/chart/elements/chart.ts
Theeraphat-Sorasetsakul May 18, 2023
e314cba
Update packages/elements/src/chart/plugins/index.ts
Theeraphat-Sorasetsakul May 18, 2023
7cd2627
docs(chart): revise reduce bundle size section
wattachai-lseg May 18, 2023
7096bab
refactor(chart): fix export way
May 18, 2023
51bd222
docs(chart): add more examples
May 18, 2023
f8ec22a
fix(chart): prevent vulnerable code
May 19, 2023
14e2b94
docs(chart): fix wording to be readable
May 19, 2023
94889d9
fix(chart): fix regex to be vulnerable
May 19, 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
20 changes: 20 additions & 0 deletions documents/src/pages/elements/chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -1225,3 +1225,23 @@ ef-chart {
```
::

## Reduce bundle size

`import "@refinitiv-ui/chart";` is a default way to add a module. This means your bundle file size will be needlessly large. Because it will get all features of Chart.js. To reduce it, `import "@refinitiv-ui/chart/bare";` is optional way to add nessassary features by your request. This way can most likely reduce the size around ~20%. Here is a list of nessessary of each chart type, [Chart.js integration](https://www.chartjs.org/docs/4.2.1/getting-started/integration.html).

```javascript
// Examples of using doughnutCenterLabel plugin with doughnut chart.
import '@refinitiv-ui/elements/chart/bare';
import { doughnutCenterLabelPlugin } from '@refinitiv-ui/elements/chart/plugins';

import {
Chart as ChartJS,
DoughnutController,
ArcElement
} from 'chart.js';
ChartJS.register(
DoughnutController
ArcElement,
doughnutCenterLabelPlugin
);
```
4 changes: 3 additions & 1 deletion packages/elements/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
"./card/themes/solar/charcoal": "./lib/card/themes/solar/charcoal/index.js",
"./card/themes/solar/pearl": "./lib/card/themes/solar/pearl/index.js",
"./chart": "./lib/chart/index.js",
"./chart/bare": "./lib/chart/bare.js",
"./chart/plugins": "./lib/chart/plugins/index.js",
"./chart/themes/halo/dark": "./lib/chart/themes/halo/dark/index.js",
"./chart/themes/halo/light": "./lib/chart/themes/halo/light/index.js",
"./chart/themes/solar/charcoal": "./lib/chart/themes/solar/charcoal/index.js",
Expand Down Expand Up @@ -366,4 +368,4 @@
"publishConfig": {
"access": "public"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,25 @@
export const snapshots = {};

snapshots["chart/Chart Check chart types DOM structure is correct"] =
`<div container="">
`<div part="container">
<div part="chart">
<canvas id="canvas">
<canvas>
</canvas>
</div>
</div>
`;
/* end snapshot chart/Chart Check chart types DOM structure is correct */

snapshots["chart/Chart Check chart types DOM structure of chart with config is correct"] =
`<div container="">
<ef-header level="2">
`<div part="container">
<ef-header
level="2"
part="title"
>
Line Chart - Price of TRI.N in 2016
</ef-header>
<div part="chart">
<canvas id="canvas">
<canvas>
</canvas>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions packages/elements/src/chart/bare.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './elements/chart.js';
Loading