# @cumul.io/react-native-cumulio-dashboard

> # React-native-cumulio-dashboard

Latest version **4.0.8** (published 2024-01-23) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @cumul.io/react-native-cumulio-dashboard
pnpm add @cumul.io/react-native-cumulio-dashboard
yarn add @cumul.io/react-native-cumulio-dashboard
bun add @cumul.io/react-native-cumulio-dashboard
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 4.0.8 |
| Published | 2024-01-23 |
| First published | 2022-02-07 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 26.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | luzmoteam, cumul.io_team |
| Keywords | front-end, development, dashboard, visualization, chart, react, react-native, component |

## Links

- npm: https://www.npmjs.com/package/@cumul.io/react-native-cumulio-dashboard
- npm.io page: https://npm.io/package/@cumul.io/react-native-cumulio-dashboard

## Dependencies (3)

- [react-native](https://npm.io/package/react-native.md) 0.71.11
- [react-native-webview](https://npm.io/package/react-native-webview.md) 13.2.0
- [@cumul.io/shared-cumulio-dashboard](https://npm.io/package/@cumul.io/shared-cumulio-dashboard.md) 4.0.1

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 4.0.8 (latest) — 2024-01-23
- 4.0.7 — 2024-01-23
- 4.0.6 — 2023-07-24
- 4.0.5 — 2023-07-10
- 4.0.4 — 2023-06-28
- 4.0.3 — 2023-06-16
- 4.0.2 — 2023-06-09
- 4.0.1 — 2023-06-09
- 4.0.0 — 2023-03-22
- 3.2.0 — 2023-02-13
- 3.1.7 — 2023-01-19
- 3.1.6 — 2022-12-14
- 3.1.5 — 2022-11-01
- 3.1.3 — 2022-09-16
- 3.1.1 — 2022-06-30
- … 12 more at https://npm.io/package/@cumul.io/react-native-cumulio-dashboard/versions

## README

# Deprecated
# This package has been deprecated in favor of [@luzmo/react-native-embed](https://www.npmjs.com/package/@luzmo/react-native-embed) 

# React-native-cumulio-dashboard

This is a React native library for embedding [Cumul.io](https://cumul.io/main) dashboards in your React native application.

## Table of contents

1. [Installation instructions](#installation-instructions)
2. [Usage](#usage)
3. [Events](#events)
4. [Public methods](#public-methods)
5. [Changelog](#changelog)
6. [Migration](#migration)
7. [Quick links](#quick-links)

## Installation instructions

```bash
npm i @cumul.io/react-native-cumulio-dashboard
```

## Usage

```ts
import CumulioDashboardComponent, { CumulioDashboard } from '@cumul.io/react-native-cumulio-dashboard';
import { useRef } from 'react';
import { Button } from 'react-native';
...
  function CumulioWrapper() {
    const ref = useRef<CumulioDashboard>(null);
    return (
      <div className="App">
        <Button
          title='Get Filters'
          onPress={async (e) => console.log(await ref.current.getFilters())}
        >
          Get Filters
        </Button>
        <CumulioDashboardComponent
          ref={ref}
          authKey="<!-- your generated authKey -->"
          authToken="<!-- your generated authToken -->"
          dashboardSlug="test"
          switchScreenModeOnResize={false}
          loaderSpinnerColor="rgb(0, 81, 126)"
          loaderSpinnerBackground="rgb(236 248 255)"
          itemsRendered={(e) => console.log('itemsRendered', e)}>
        </CumulioDashboardComponent>
      </div>
    );
  }
...
```

**Properties**

Below a list of available properties on the dashboard react native component

| Property                   | Type                                             | Description                                                                                                                                                                                                                                                                 |
| -------------------------- | ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `dashboardId`              | string                                           | The id of the Cumul.io dashboard you wish to embed                                                                                                                                                                                                                          |
| `dashboardSlug`            | string                                           | The slug of the Cumul.io dashboard you wish to embed (if a dashboardId is supplied that one will be used)                                                                                                                                                                   |
| `itemId`                   | string                                           | The id of the Cumul.io item you wish to embed                                                                                                                                                                                                                               |
| `itemDimensions`           | { width: number/string; height: number/string; } | width and height of item only applies when itemId is provided.                                                                                                                                                                                                              |
| `authKey`                  | string                                           | Authorization key generated via Cumul.io API                                                                                                                                                                                                                                |
| `authToken`                | string                                           | Authorization token generated via Cumul.io API                                                                                                                                                                                                                              |
| `language`                 | string                                           | The language of the dashboard: eg. 'en' (Default: 'auto')                                                                                                                                                                                                                   |
| `screenMode`               | string                                           | The screen mode of your dashboard: 'mobile', 'tablet', 'desktop', 'largeScreen', 'fixed' or 'auto' (Default: 'auto')                                                                                                                                                        |
| `switchScreenModeOnResize` | boolean                                          | true: the embedded dashboard can switch screenModes on resize of the container , false: Dashboard will keep the same screenMode (Default: true)                                                                                                                             |
| `loaderBackground`         | string                                           | Background color of the loader element (Default: '#f9f9f9')                                                                                                                                                                                                                 |
| `loaderFontColor`          | string                                           | Font color of the text of the loaders (Default: '#5a5a5a')                                                                                                                                                                                                                  |
| `loaderSpinnerColor`       | string                                           | Spinner color of the loader (Default: 'rgba(255, 165, 0, 0.7)')                                                                                                                                                                                                             |
| `loaderSpinnerBackground`  | string                                           | Background color of the spinner (Default: 'rgba(169, 169, 169, 0.14)')                                                                                                                                                                                                      |
| `appServer`                | string                                           | Tenancy of cumul.io to connect to (Default: 'https://app.cumul.io/' for US set appServer to 'https://app.us.cumul.io/')                                                                                                                                                     |
| `timezoneId`               | string                                           | The timezone you you wish to use in your dashboard. This timezone id needs to be a valid id that is available in the [IANA timezone database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List), for example: Europe/Brussels or America/New_York.         |
| `apiHost`                  | string                                           | API server to connect to (Default: 'https://api.cumul.io/' for US set apiHost to 'https://api.us.cumul.io/')                                                                                                                                                                |
| `mainColor`                | string                                           | Optional override of the main color used in the whitelabeling of the embedded dashboard editor. If not provided, the main color of the whitelabeling colors set on the organization will be used. Should be specified as a string of rgb values (i.e. "rgb(50,50,50)").     |
| `accentColor`              | string                                           | Optional override of the accent color used in the whitelabeling of the embedded dashboard editor. If not provided, the accent color of the whitelabeling colors set on the organization will be used. Should be specified as a string of rgb values (i.e. "rgb(50,50,50)"). |

[//]: # '| `editMode`                 | string  | Specifies if the embedded dashboard should be editable or not. Accepted values: "view" , "editLimited" , "editFull" . Use "view" if you don\'t want the embedded dashboard to be editable. (Default: "view" )                                                        |'

<br/><br/>

## Events

| Name           | Description                          | Event Arguments       |
| -------------- | ------------------------------------ | --------------------- |
| changedFilters | Emitted when filters are changed     | `ChangedFiltersEvent` |
| customEvent    | Emitted when a custom event is fired | `CustomEvent`         |
| itemsRendered  | Emitted when all items are rendered  | `ItemsRenderedEvent`  |
| load           | Emitted when dashboard is loaded     | `LoadEvent`           |

[//]: # '| exported       | Emitted when export completes or fails | `ExportedEvent`       |'

<br/>

## Public methods

```typescript
getData(itemId: string): Promise<ItemData>
// Promise that returns an array with the data of a item.

getFilters(): Promise<FilterGroup[]>
// Promise that returns an array of filters.

setAuthorization(key: string, token: string): Promise<void>
// Sets a new pair of authKey & authToken for the dashboard

refreshData(itemId?: string): Promise<void>
// Refreshes the data of a specific item/chart when the id of that item is supplied. Without a itemId this refreshes the data in all items.

reloadDashboard(): Promise<void>
// Reloads the dashboard. (useful when the authorization is changed, and dashboard needs to be reloaded)

getAccessibleDashboards(): Promise<AccessibleDashboard[]>
// Retrieves a list of all dashboards an integration has access to. authKey and authToken needs to be set for this function to work.
```

<!-- - `exportDashboard(type?: 'png' | 'pdf'): Promise<void>`: Exports the current dashboard as either pdf or png. -->
<!-- - `setEditMode(editMode: string): Promise<void>` : Sets the editMode of the current dashboard. Accepted parameters: view , editLimited , editFull . -->
<br/>

## Changelog

- [Changelog](https://embed-libs.cumul.io/changelogs/react-native-cumulio-dashboard/)

## Migration

### Migration from 3.X.X to 4.X.X

- Filters are represented as a `FilterGroup` array instead of a `Filter` array. `FilterGroup` is an object containing the list of filters and AND/OR condition describing their relation. `FilterGroup` also can have child groups to support complex filtering logic

```typescript
// FilterGroup
{
  id: string;
  condition: 'and' | 'or';
  filters: Filter[];
  subGroups: FilterGroup[];
  origin: string;
  datasetId?: string; // dataset id in case of dahsboard level filters
  itemId?: string; // chart id in case of chart level filters
}

// Filter
{
  expression: string;
  parameters: [];
  properties: {
    id: string;
    origin: string;
    type: string;
    itemId: string;
    ignore?: string[];
  }
}
```

- `getFilters()` method response and `changedFilters` event data now contain filters as an array of `FilterGroup` objects instead of `Filter` objects

```typescript
getFilters(): Promise<FilterGroup[]>
```

```typescript
// changedFilters event data
{
  changed: FilterGroup[]; // changed filters
  filters: FilterGroup[]; // all filters
  // ... other event properties
}
```

### Migrating from 2.x.x to 3.x.x

- No Changes.

### Migrating from 1.x.x to 2.x.x

- All methods that were called on dispatched to store shall now be called on component ref (Which can be obtained using `useRef to obtain a ref`).
- `chartId` is now called `itemId`, `charts-rendered` is now called `items-rendered`
- All events are now of the format `{ data: eventData }`, `eventData` is of the format

```ts
{
  dashboardId?: string;
  dashboardSlug?: string;
  itemId?: string;
  language: string;
  name: string;
  screenMode: string;
  type: string;
  dimensions?: object; // populated depending on the event
  changed?: [];  // populated depending on the event
  filters?: [];  // populated depending on the event
  item?: string;    // populated depending on the event
  origin?: string;  // populated depending on the event
  object?: string;  // populated depending on the event
  data?: object;       // populated depending on the event
}
```

- getFilters now returns a promise that resolves to an array of filters. `[...objectOfFilters]`, `objectOfFilters` is of the format

```ts
[{
  expression: string;
  parameters: [];
  properties: {
    id: string;
    ignore?: string[];
    origin: string;
    type: string;
    viz: string;
  }
}]
```

For more [migrations click here](https://embed-libs.cumul.io/migrations/react-native-cumulio-dashboard/).

## Quick links

[Cumul.io](https://cumul.io) |
[Snack Expo Example](https://snack.expo.dev/@paresh_cumul/react-native-cumulio) |
[Changelog](https://embed-libs.cumul.io/changelogs/react-native-cumulio-dashboard/) |
[Migration](https://embed-libs.cumul.io/migrations/react-native-cumulio-dashboard/)

---
_Source: https://npm.io/package/@cumul.io/react-native-cumulio-dashboard · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
