[]
        
在线Demo 免费试用
(Showing Draft Content)

集成仪表板设计器

Wyn 支持把仪表板设计器嵌入到 Web 应用程序的 DIV 容器中去,为最终的用户提供在线直接设计仪表板的能力。

本文为您介绍具体的集成方法。

操作介绍

1. 安装最新的集成包。

https://www.npmjs.com/package/@grapecity/wyn-integration

npm install @grapecity/wyn-integration

2. 集成。

将仪表板设计器添加到 DIV容器 “wyn-root”中:

import { WynIntegration } from "@grapecity/wyn-integration";

let designer:any = null;
const createViewer = (baseURL, token, dashboardId) => {
    if (designer){
        designer.destroy();
    }
    
    WynIntegration.createDashboardDesigner({
        baseUrl: baseURL, //'http://example.com:51980',
        token: token,
        defaults: {
            dashboardId: dashboardId,
        },
        features: {
        }
    }, '#wyn-root').then(instance => {
        designer = instance;
    });
}

参数说明:

defaults: {
     datasetId: datasetId
},

datasetId 可以从 Wyn 的文档列表获取。

image

如此,在集成之后的设计器中,添加组件时则会自动加载数据集。

image

通过 defaults 对象的 dashboardId 指的是仪表板文档 Id,可以从 Wyn 的文档列表获取。如果 dashboardId 为空,设计器会创建一个空的文档。

image

    // 通过组件模板添加组件
    designer.addVisualByTemplateId(componentTemplateId, left, top);
    
    // 添加嵌入式仪表板
    designer.addVisual("embeddedDashboard", width, height, left, top, { documentId });
    
    // 添加嵌入式报表
    designer.addVisual("embeddedReport", width, height, left, top, { doumentcId });

更多的示例参见 Wyn 嵌入式分析体验 (https://wyn.grapecity.com.cn/playground/index.html)

完整示例包下载

wyn-integration-vue.zip

wyn-integration-react.zip