DataViz WebApp extension process |
The DataViz WebApp supports customizing the Logo link, the Tabs on the left, the point and line symbol sets in vector layers. In this section, we will describe the extension process of DataViz WebApp in detail.
In /META-INF/resources/apps/dataviz/libs/plugins directory of the unzipped webjar-dataviz-*.jar found in the [iPortal product package] /webapps/iportal/WEB-INF/lib directory, you can obtain PluginsConfig.js, symbol-point.json and symbol-line.json, which are configuration files related to DataViz WebApp extension customization.
let plugins = new DataViz.Plugins.DatavizPlugins({
changeTabCallback: changeMenuTab
});
window.DataViz.Plugins = {
// By default, clicking the Logo will open the iPortal home page.
logoHref: "",
// By default, clicking the Logo will open a new browser tab.
logoHrefTargetSelf: false,
//The Tabs page to be displayed on the left
menus: [{
//Layer Tab (provided in the default interface)
id: 'dv-layers',
title: DataViz.Language.layerManagement,
iconClass: 'supermapol-icons-layers'
},{
//Setting Tab (provided in the default interface)
id: 'dv-settings',
title: DataViz.Language.mapSetting,
iconClass: 'supermapol-icons-setting'
}
,{
//Extended example tab
id: 'dv-extension',
title: 'Extension',
iconClass: 'supermapol-icons-roadnetwork'
}
]
,
//The extended js file (relative path)
jsFile: ['sample/Sample.js'],
//The extended css file (relative path)
cssFile: ['sample/Sample.css']
}
The table below shows a detailed description of the menus, jsFile, and cssFile parameters:
Parameter | Type | Description |
menus | array | The Tabs array displayed in the left panel. The system displays the elements on the interface from top to bottom. The array elements are of object type. In the object: id:the id of the dom panel corresponding to the Tab page title:the title of the Tab page iconClass:the class name of the Tab page icon |
jsFile | array | The extended Tab js file path (relative to the PluginsConfig.js configuration file). |
cssFile | array | The extended Tab css file path (relative to the PluginsConfig.js configuration file). |
Note:
window.DataViz.Plugins = {
// By default, clicking the Logo will open the iPortal home page.
logoHref: "",
// By default, clicking the Logo will open a new browser tab.
logoHrefTargetSelf: false,
//The Tabs page to be displayed on the left
menus: [{
id: 'dv-layers',
title: DataViz.Language.layerManagement,
iconClass: 'supermapol-icons-layers'
},{
id: 'dv-settings',
title: DataViz.Language.mapSetting,
iconClass: 'supermapol-icons-setting'
}
]
}
The table below shows a detailed description of the logoHref and logoHrefTargetSelf parameters:
Parameter | Type | Description |
logoHref | String | The link address of the DataViz Logo. Empty means using the iPortal homepage. |
logoHrefTargetSelf | boolean | Whether to open the Logo link in the current browser window |
{
"Vector": {
},
"Image": {
}
}
You can extend point symbols of Vector and Image types. Vector point symbols support svg format that can be accessed online or at relative addresses such as static/imgs/layer_editor/point_imgs_v1/xxx.svg. Image point symbols can be accessed online or in the png/jpg/jpeg format of relative addresses such as static/imgs/layer_editor/point_imgs_v1/xxx.png.
{
"Vector": {
//Extension demonstration of vector point symbol
"customVectorSymbol1": [
"http://fakeurl:8081/demo/test1.svg",
"http://fakeurl:8081/demo/test2.svg",
]
},
"Image": {
//Extension demonstration of image point symbol
"customImageSymbol1": [
"http://fakeurl:8081/demo/bigimgs/biji.png",
"http://fakeurl:8081/demo/bigimgs/biaoqian.png",
],
}
}
{
"traffic": {
"label": "Traffic", // The Tab label of line symbol set
"items": [] // The line symbols in Tab page
}
{
"traffic": {
"label": "Traffic", // The Tab label of line symbol set
"items": [] // The line symbols in Tab page
{
"id": "ordinaryRail", // The unique id of the line symbol
"label": "OrdinaryRail", // The label of the line symbol
"thumbnail": "static/imgs/layer_editor/lineType/dark/ordinaryrail.svg", //The address of line symbol thumbnail, which can be a relatively static directory or an online address.
// styleConfigs is used to configure rendering interface or others, the data format of it is an array of objects corresponding to each style.
"styleConfigs": [
{
"strokeColor": {
"label": "dashLineColor1", // The label of configuration item
"controlType": "color" // The control type of configuration item.
},
"strokeWidth": {
"label": "dashLineWidth1",
"controlType": "number"
},
"strokeOpacity": {
"label": "dashLineOpacity1",
"controlType": "percent"
},
"lineCap": {
"label": "dashLineCap1",
"controlType": "select"
}
},
{
"strokeColor": {
"label": "dashLineColor2",
"controlType": "color"
},
"strokeWidth": {
"label": "dashLineWidth2",
"controlType": "number"
},
"strokeOpacity": {
"label": "dashLineOpacity2",
"controlType": "percent"
}
}
],
//styles support setting strokeColor, strokeWidth, strokeOpacity, lineCap and lineJoin currently.
"styles": [
{
"strokeColor": "#BFBFBF", // Configure line color
"strokeWidth": 4.16, // Configure line width, unit: pixel
"strokeOpacity": 1, // Configure line opacity
"lineCap": "round" // Configure line cap, the optional values include round, butt, or square
},
{
"strokeColor": "#ffffff",
"strokeWidth": 3,
"lineDash": [13.23, 13.23], // Configure dot and dash line, unit: pixel
"strokeOpacity": 1,
"lineJoin": "round" //Configure line join style, the optional values include round, butt, or square
}
]
}
]
}
}
After extension customization has been completed, refering to your extension items, copy the extended js, css files and configuration files (PluginsConfig.js, symbol-point.json, symbol-line.json) to the [iPortal product package]/webapps/iportal/apps/dataviz/libs/plugins/ directory (if no such directory, create it), or recompress them into the iPortal product package/webapps/iportal/WEB-INF/lib/webjar-dataviz-*.jar (location: /META-INF/resources/apps/dataviz/libs/plugin/) as required. If both locations have been placed the extended files, the former will take effect.
Files involved in different extension customization items:
Tab pages extension: extension code (js, CSS files), PluginsConfig. Js
Customization of DataViz WebApp Logo links: PluginsConfig. Js
Customization of point and line symbol sets: symbol-point.json or symbol-line.json
After placing the extension files, check extension effect in DataViz WebApp in iPortal (no need to restart iPortal, and if the extension items doesn't show, please clear the browser cache and try again). The extended effect of the point and line symbol sets can be checked in Point styles and Line styles under the Base tab in panels of the point and line layers, respectively.