Highcharts Dashboards with React
To create a dashboard with React please follow the steps below:
Install the Dashboards package.
npm install @highcharts/dashboardsImport the Dashboards package.
import * as Dashboards from '@highcharts/dashboards';To fully utilize the Dashboards potential, consider additional packages like Highcharts or DataGrid.
First install the package.
npm install highchartsThen import the package and the dedicated plug to connect it to the Dashboards.
import Highcharts from 'highcharts';import Dashboards from '@highcharts/dashboards';import DataGrid from '@highcharts/dashboards/datagrid';Dashboards.HighchartsPlugin.custom.connectHighcharts(Highcharts);Dashboards.DataGridPlugin.custom.connectDataGrid(DataGrid);Dashboards.PluginHandler.addPlugin(Dashboards.HighchartsPlugin);Dashboards.PluginHandler.addPlugin(Dashboards.DataGridPlugin);Create a HTML structure for the dashboard.
There are two ways to do it:- Use the `dashboards` layout system.To do that first import the `layout` module and initialize it:```typescriptimport LayoutModule from '@highcharts/dashboards/modules/layout';LayoutModule(Dashboards);```Then add a div where you want to render the dashboard:```html<div id="dashboard"></div>```You can refer to the element by its id or you can use the `ElementRef` to get the element.- Declare your own HTML structure. Read more in the [documentation](https://www.highcharts.com/docs/dashboards/layout-description).Create a dashboard using the factory function
Dashboards.board
. The function takes three arguments:container
- the element where the dashboard will be rendered, can be an id of the element or the direct reference to the elementoptions
- the options object for the dashboardisAsync
- whether the dashboard should be rendered asynchronously or not- useful when using external data resources
Demos
See how it works in the demos like below: