折旧
这个套件已经贬值,有利于 @luzmo/反应-嵌入
反应-积分-dashboard
这是用于嵌入的 React 库 卡穆尔.io 反应应用程序中的仪表板.
目录
安装指令
npm i @cumul.io/react-cumulio-dashboard
使用量
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>
);
}
...
属性
以下列出仪表板上可用的属性
| 财产 | 类型 | 说明 |
|---|---|---|
dashboardId | 字符串 | 您想要嵌入的 Cumul.io 仪表板的标识 |
dashboardSlug | 字符串 | 您想要嵌入的 Cumul.io 仪表板的弹片( 如果提供仪表板Id, 将使用) |
itemId | 字符串 | 您想要嵌入的 Cumul.io 项的 ID |
itemDimensions | {宽:数/弦;高:数/弦;} | 只有在提供了项目ID时才适用项目的宽度和高度。 接受 JSON 字符串. |
authKey | 字符串 | 通过 Cumul.io API 生成的授权密钥 |
authToken | 字符串 | 通过 Cumul.io API 生成的授权令牌 |
language | 字符串 | 仪表板语言: 如"en"(默认:"auto") |
screenMode | 字符串 | 您的仪表板的屏幕模式 : “ 移动 ” 、 “ 平板 ” 、 “ 桌面 ” 、 “ 大屏幕 ” 、 “ 固定 ” 或 “ 自动 ” (默认 : “ 自动 ” ) |
switchScreenModeOnResize | 布尔 | 真:嵌入式仪表板可以在改变容器大小时切换屏幕Modes,假:Dashboard会保留同一种屏幕Mode(默认:真实) |
loaderBackground | 字符串 | 加载器元素的背景颜色( 默认 : '# f9f9f9' ) |
loaderFontColor | 字符串 | 装入器文字的字体颜色( 默认 : '# 5a5a5a5a' ) |
loaderSpinnerColor | 字符串 | 装入器的自旋颜色( 默认 : “ rgba( 255, 165, 0, 0. 7) ”) |
loaderSpinnerBackground | 字符串 | 旋转器的背景颜色( 默认 : “ rgba( 169, 169, 169, 0. 14) ”) |
appServer | 字符串 | Cumul.io 连接的租借(默认:"https://app.cumul.io/" 美国设置的应用程序Server 到"https://app.us.cumul.io/") |
timezoneId | 字符串 | 你想在仪表板上使用的时区 这个时区 id 需要是一个有效的 id , 可以在 IANA 时区数据库例如:欧洲/布鲁塞尔或美洲/纽约. |
apiHost | 字符串 | 要连接的 API 服务器 (default: 'https://api. cumul.io/' for USs set apiHost to 'https://api.us.cumul.io/') |
editMode | 字符串 | 指定嵌入式仪表板是否可编辑。 接受值:"视图","编辑Limited","编辑Full". 不希望嵌入式仪表板可编辑时使用"视图". (过失:"观" |
mainColor | 字符串 | 对嵌入式仪表板编辑器白标签中使用的主色调可选更改. 如果不提供,则使用组织上所设置的白色标签颜色的主要颜色。 应当指定为 rgb 值的字符串(即 “ rgb( 50, 50, 50) ”) . |
accentColor | 字符串 | 嵌入式仪表板编辑器的白标签中使用的口音颜色的可选覆盖. 如果不提供,则使用组织上所设置的白标签颜色的口音颜色。 应当指定为 rgb 值的字符串(即 “ rgb( 50, 50, 50) ”) . |
活动
| 名称 | 说明 | 事件参数 |
|---|---|---|
| 已更改 过滤器 | 过滤器被更改时退出 | ChangedFiltersEvent |
| 自定义事件 | 解除自定义事件时退出 | CustomEvent |
| 导出 | 导出完成或失败时发出 | ExportedEvent |
| 已招标的项目 | 当所有物品都提供时, 才被放出 | ItemsRenderedEvent |
| 装入 | 装入仪表板时放出 | LoadEvent |
公共方法
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 .
更改日志
移徙
从 3.x.x 迁移到 4.x.x
- 过滤器显示为
FilterGroup数组代替一个Filter阵列.FilterGroup是一个包含过滤器列表和(或)描述其关系的条件的对象.FilterGroup也可以有儿童组支持复杂的过滤逻辑
// 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()方法响应和changedFilters事件数据现在包含过滤器,作为FilterGroup对象代替Filter对象
getFilters(): Promise<FilterGroup[]>
// changedFilters event data
{
changed: FilterGroup[]; // changed filters
filters: FilterGroup[]; // all filters
// ... other event properties
}
从 2.x.x 迁移到 3.x.x
- 无更改
从 1.x.x 迁移到 2.x.x
- 所有被调用用于储存的方法现在应调用组件参考(可用
useRef to obtain a ref) (中文(简体) ). chartId现在叫做itemId, (中文(简体) ),charts-rendered现在叫做items-rendered- 所有事件现在都属于格式
{ data: { ...eventData } }, (中文(简体) ),eventData属于格式
{
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 现在返回一系列过滤器.
[...objectOfFilters], (中文(简体) ),objectOfFilters属于格式
[{
expression: string;
parameters: [];
properties: {
id: string;
ignore?: string[];
origin: string;
type: string;
viz: string;
}
}]
为了更多 迁移请点击此处。 。 。 .