[{"id":"840f0737-df1d-47ae-bb0a-359b01fe0608","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"d5d9cdef-8854-4505-89be-a2bbc3cb4482","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"3dc3dd55-35b0-4d23-bf62-47bc3650e4ee","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"80d84fbc-d0f8-4e4a-947f-e3e4de9b49b2","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]},{"id":"9152b7ca-0186-4fe3-a26f-5a05f322db07","tags":[{"product":null,"links":null,"id":"adf72f47-7f61-4239-8392-b9bcc127fa80","name":"\u65B0\u589E","color":"green","productId":"0995490e-43fc-4d6e-bc8d-8e66f38b0c63"}]}]
        
(Showing Draft Content)

集成仪表板以及可视化组件

用户可以把整张仪表板嵌入到 Web 应用程序的 DIV 容器中去,实现嵌入式的数据分析。

Wyn 提供了两种仪表板查看器:标准分析查看器和高级分析查看器。高级分析查看器提供了更多自助式分析的功能,而标准分析查看器更适用于大屏展示,性能更优。两种查看器的详细差异请参见标准分析模式&高级分析模式

两种仪表板查看器均提供了DIV 的集成方式,集成方法如下:

安装最新的集成包

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

npm install @grapecity/wyn-integration

集成过程

以下根据不同的场景具体介绍集成方法。

1. 集成仪表板标准查看器

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

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

参数说明:

2. 集成可视化组件(仪表板标准查看器)

一些应用场景下,用户希望将单个的可视化组件集成到应用程序,而不是整张仪表板。这个时候在集成仪表板查看器代码的基础上,只需要指定可视化组件的名称即可。

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

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

参数 scenario 指的是可视化组件的名称,可以在仪表板设计器中获取。

image

3. 集成仪表板高级查看器

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

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

参数说明:

4. 集成可视化组件(仪表板高级查看器)

一些应用场景下,用户希望将单个的可视化组件集成到应用程序,而不是整张仪表板,这个时候在集成仪表板查看器代码的基础上,只需要指定可视化组件的名称。

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

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

参数 scenario 指的是可视化组件的名称,可以在仪表板设计器中获取。

image

完整示例包下载

wyn-integration-react.zip

wyn-integration-vue.zip