@cumul.io/react-cumulio-dashboard

中文文档
4.0.2发布于 2024/01/23TypeScriptES Module近 30 天下载 3158

react-cumulio-dashboard

此软件包已被标记为弃用

Deprecated in favor of @luzmo/react-embed

原始使用文档
文档目录11 节
  1. Table of contents
  2. Installation instructions
  3. Usage
  4. Events
  5. Public methods
  6. Changelog
  7. Migration
  8. Migration from 3.x.x to 4.x.x
  9. Migration from 2.x.x to 3.x.x
  10. Migrating from 1.x.x to 2.x.x
  11. Quick links

Deprecated

This package has been deprecated in favor of @luzmo/react-embed

react-cumulio-dashboard

This is a React library for embedding Cumul.io dashboards in your React application.

Table of contents

  1. Installation instructions
  2. Usage
  3. Events
  4. Public methods
  5. Changelog
  6. Migration
  7. Quick links

Installation instructions

npm i @cumul.io/react-cumulio-dashboard

Usage

import { CumulioDashboardComponent, CumulioDashboard } from '@cumul.io/react-cumulio-dashboard';
import { useRef } from 'react';
...
  function CumulioWrapper() {
    const ref = useRef<CumulioDashboard>(null);
    return (
      <div className="App">
        <button
          onClick={async (e) => console.log(await ref.current.exportDashboard())}
        >
          Export Dashboard
        </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 component

PropertyTypeDescription
dashboardIdstringThe id of the Cumul.io dashboard you wish to embed
dashboardSlugstringThe slug of the Cumul.io dashboard you wish to embed (if a dashboardId is supplied that one will be used)
itemIdstringThe 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. Accepts a JSON string.
authKeystringAuthorization key generated via Cumul.io API
authTokenstringAuthorization token generated via Cumul.io API
languagestringThe language of the dashboard: eg. 'en' (Default: 'auto')
screenModestringThe screen mode of your dashboard: 'mobile', 'tablet', 'desktop', 'largeScreen', 'fixed' or 'auto' (Default: 'auto')
switchScreenModeOnResizebooleantrue: the embedded dashboard can switch screenModes on resize of the container , false: Dashboard will keep the same screenMode (Default: true)
loaderBackgroundstringBackground color of the loader element (Default: '#f9f9f9')
loaderFontColorstringFont color of the text of the loaders (Default: '#5a5a5a')
loaderSpinnerColorstringSpinner color of the loader (Default: 'rgba(255, 165, 0, 0.7)')
loaderSpinnerBackgroundstringBackground color of the spinner (Default: 'rgba(169, 169, 169, 0.14)')
appServerstringTenancy of cumul.io to connect to (Default: 'https://app.cumul.io/' for US set appServer to 'https://app.us.cumul.io/')
timezoneIdstringThe 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, for example: Europe/Brussels or America/New_York.
apiHoststringAPI server to connect to (Default: 'https://api.cumul.io/' for US set apiHost to 'https://api.us.cumul.io/')
editModestringSpecifies 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" )
mainColorstringOptional 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)").
accentColorstringOptional 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)").



Events

NameDescriptionEvent Arguments
changedFiltersEmitted when filters are changedChangedFiltersEvent
customEventEmitted when a custom event is firedCustomEvent
exportedEmitted when export completes or failsExportedEvent
itemsRenderedEmitted when all items are renderedItemsRenderedEvent
loadEmitted when dashboard is loadedLoadEvent

Public methods

getDashboards(): Promise<CumulioDashboard[]>
// Returns an instantly resolved promise with an array of all the visible dashboards on a page with their information.

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)

exportDashboard(type?: ExportType): Promise<ExportDashboard>
// Exports the current dashboard as either pdf or png.

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.

setEditMode(editMode: string): Promise<SetEditMode>
// Sets the editMode of the current dashboard. Accepted parameters: view , editLimited , editFull .

Changelog

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
// 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
getFilters(): Promise<FilterGroup[]>
// changedFilters event data
{
  changed: FilterGroup[]; // changed filters
  filters: FilterGroup[]; // all filters
  // ... other event properties
}

Migration 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
{
  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 an array of filters. [...objectOfFilters], objectOfFilters is of the format
[{
  expression: string;
  parameters: [];
  properties: {
    id: string;
    ignore?: string[];
    origin: string;
    type: string;
    viz: string;
  }
}]

For more migrations click here.

Cumul.io | Codesandbox example | Migrations | Changelog

版本与发布记录

@cumul.io/react-cumulio-dashboard 共发布 38 个版本,首次发布于 2021/10/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
4.0.2latest2024/01/232 年前
4.0.12023/06/163 年前
4.0.02023/03/223 年前
3.2.02023/02/133 年前
3.1.132023/01/273 年前
3.1.122023/01/203 年前

关于 @cumul.io/react-cumulio-dashboard 的常见问题

@cumul.io/react-cumulio-dashboard 是什么?

react-cumulio-dashboard注意:该包已被作者标记为弃用——Deprecated in favor of @luzmo/react-embed

如何安装 @cumul.io/react-cumulio-dashboard?

在项目目录运行 npm install @cumul.io/react-cumulio-dashboard,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:react(^16 || ^17 || ^18)、react-dom(^16 || ^17 || ^18)、@cumul.io/cumulio-dashboard(4.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@cumul.io/react-cumulio-dashboard 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cumul.io/react-cumulio-dashboard 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@cumul.io/react-cumulio-dashboard 可以商用吗?

@cumul.io/react-cumulio-dashboard 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@cumul.io/react-cumulio-dashboard 的下载量有多少?

根据 npm 官方下载统计,@cumul.io/react-cumulio-dashboard 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,158 次,日均约 105 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cumul.io/react-cumulio-dashboard 还在维护吗?

最新版本 4.0.2 发布于 2024/01/23(2 年前);至今共发布 38 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/10/19。作者已将其标记为弃用,新项目建议寻找替代方案。