Customizing the UI
DATA VIZ provides a way to extend the UI by adding custom components. This guide will show you how to add a custom component to the UI.
Prerequisites​
- Node.js version 20 or above (which can be checked by running
node -v).
Setup​
We provide a sample template that you can use to get started. You can find the sample template in the front/custom/ui-customizer directory.
Steps​
-
Clone the repository and navigate to the
front/custom/ui-customizerdirectory. -
Copy the
front/custom/ui-customizerintocustom/ui-customizerin your project root directory.
cp -r front/custom/ui-customizer custom/ui-customizer
- Install the dependencies by running the following command:
- npm
- pnpm
- Yarn
- Bun
npm install
pnpm install
yarn install
bun install
- Start the development server by running the following command:
- npm
- pnpm
- Yarn
- Bun
npm run watch
pnpm run watch
yarn watch
bun run watch
- The above command will compile the JSX files that can be accessed by the
front/uimain project. You can now start the main project by running the following command:
- npm
- pnpm
- Yarn
- Bun
npm run dev
pnpm run dev
yarn dev
bun run dev
Folder Structure​
The custom/ui-customizer directory contains the following files:
├── Dockerfile
├── package-lock.json
├── package.json
└── src
├── example-project-embedded
│ └── index.js
├── images
│ └── green_arrow_active.svg
├── index.js
└── scss
├── _vars.scss
├── index.scss
└── theme
├── _body.scss
├── _carousel.scss
├── _charts.scss
├── _colors.scss
├── _content.scss
├── _download.scss
├── _featured-partner.scss
├── _featured.scss
├── _filter.scss
├── _floating.scss
├── _fonts.scss
├── _footer.scss
├── _header.scss
├── _index.scss
├── _inline-list.scss
├── _latest-resources.scss
├── _map.scss
├── _myths.scss
├── _newsLetter.scss
├── _nodata.scss
├── _pagegallery.scss
├── _pagemodules.scss
├── _partners.scss
├── _production-overview.scss
├── _resources.scss
├── _responsive.scss
├── _sankey.scss
├── _showCase.scss
├── _structures.scss
└── _tabbed.scss
Creating a Custom Component​
To create a custom component, you can follow the steps below:
-
Create a new directory in the
srcdirectory with the name of your component. -
Create a new file in the directory with the name
index.jsthat should be exported as a React component. -
Register the component in the
src/index.jsfile. Example code:
import ExampleProjectEmbedded from './example-project-embedded';
export default {
ExampleProjectEmbedded,
};