Skip to content

Commit 4765ef6

Browse files
committed
【SDK】【服务】【优化renderer说明】
1 parent c8374a5 commit 4765ef6

File tree

4 files changed

+62
-13
lines changed

4 files changed

+62
-13
lines changed

src/service/base/renderer/ColorVariable.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { VisualVariable } from './VisualVariable';
77
* @class mapgis.renderer.ColorVariable
88
* @classdesc 视觉变量-颜色视觉变量
99
* @param {String} [type] 视觉变量类型,只能是 'color'
10-
* @param {String} [normalizationField] 标准化数据所依据的数字属性字段的名称,将数据值除以对应字段数据值
10+
* @param {String} [field] 视觉变量字段
11+
* @param {String} [valueExpression] 计算表达式,用来对要素中的单/多个属性进行数学计算
12+
* @param {String} [valueExpressionTitle] 计算表达式标题
13+
* @param {String} [normalizationType] 归一化类型,可选 "field"|"percent-of-total"|"log"
14+
* @param {String} [normalizationField] 归一化字段,将renderer中对应字段数据值除以归一化字段数据值
15+
* @param {Number} [normalizationTotal] 归一化值,将renderer中对应字段数据值除以所有数据值的总和
1116
* @param {Array<ColorStop>} [stops] 视觉变量颜色数组,定义在一系列停靠点中应用于要素的连续色带的颜色
1217
*/
1318
export default class ColorVariable extends VisualVariable {
@@ -16,8 +21,13 @@ export default class ColorVariable extends VisualVariable {
1621
var options = option ? option : {};
1722
const { type = "color" } = options;
1823
this.type = type;
19-
const { normalizationField, stops } = options;
24+
const { field, valueExpression, valueExpressionTitle, normalizationType, normalizationField, normalizationTotal, stops } = options;
25+
this.field = field;
26+
this.valueExpression = valueExpression;
27+
this.valueExpressionTitle = valueExpressionTitle;
28+
this.normalizationType = normalizationType;
2029
this.normalizationField = normalizationField;
30+
this.normalizationTotal = normalizationTotal;
2131
this.stops = stops;
2232
}
2333

@@ -36,8 +46,13 @@ export default class ColorVariable extends VisualVariable {
3646
json = json || {};
3747
const { type = "color" } = json;
3848
this.type = type;
39-
const { normalizationField, stops } = json;
49+
const { field, valueExpression, valueExpressionTitle, normalizationType, normalizationField, normalizationTotal, stops } = json;
50+
this.field = field;
51+
this.valueExpression = valueExpression;
52+
this.valueExpressionTitle = valueExpressionTitle;
53+
this.normalizationType = normalizationType;
4054
this.normalizationField = normalizationField;
55+
this.normalizationTotal = normalizationTotal;
4156
this.stops = stops;
4257
}
4358

@@ -48,7 +63,12 @@ export default class ColorVariable extends VisualVariable {
4863
toJSON() {
4964
return {
5065
type: this.type,
66+
field: this.field,
67+
valueExpression: this.valueExpression,
68+
valueExpressionTitle: this.valueExpressionTitle,
69+
normalizationType: this.normalizationType,
5170
normalizationField: this.normalizationField,
71+
normalizationTotal: this.normalizationTotal,
5272
stops: this.stops,
5373
};
5474
}

src/service/base/renderer/OpacityVariable.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import { VisualVariable } from './VisualVariable';
77
* @class mapgis.renderer.OpacityVariable
88
* @classdesc 视觉变量-透明度视觉变量
99
* @param {String} [type] 视觉变量类型,只能是 'opacity'
10-
* @param {String} [normalizationField] 标准化数据所依据的数字属性字段的名称,将数据值除以对应字段数据值
10+
* @param {String} [field] 视觉变量字段
11+
* @param {String} [valueExpression] 计算表达式,用来对要素中的单/多个属性进行数学计算
12+
* @param {String} [valueExpressionTitle] 计算表达式标题
13+
* @param {String} [normalizationType] 归一化类型,可选 "field"|"percent-of-total"|"log"
14+
* @param {String} [normalizationField] 归一化字段,将renderer中对应字段数据值除以归一化字段数据值
15+
* @param {Number} [normalizationTotal] 归一化值,将renderer中对应字段数据值除以所有数据值的总和
1116
* @param {Array<OpacityStop>} [stops] 视觉变量透明度数组,定义在一系列停靠点中应用于要素的透明度
1217
*/
1318
export default class OpacityVariable extends VisualVariable {
@@ -16,8 +21,13 @@ export default class OpacityVariable extends VisualVariable {
1621
var options = option ? option : {};
1722
const { type = "opacity" } = options;
1823
this.type = type;
19-
const { normalizationField, stops } = options;
24+
const { field, valueExpression, valueExpressionTitle, normalizationType, normalizationField, normalizationTotal, stops } = options;
25+
this.field = field;
26+
this.valueExpression = valueExpression;
27+
this.valueExpressionTitle = valueExpressionTitle;
28+
this.normalizationType = normalizationType;
2029
this.normalizationField = normalizationField;
30+
this.normalizationTotal = normalizationTotal;
2131
this.stops = stops;
2232
}
2333

@@ -36,8 +46,13 @@ export default class OpacityVariable extends VisualVariable {
3646
json = json || {};
3747
const { type = "opacity" } = json;
3848
this.type = type;
39-
const { normalizationField, stops } = json;
49+
const { field, valueExpression, valueExpressionTitle, normalizationType, normalizationField, normalizationTotal, stops } = json;
50+
this.field = field;
51+
this.valueExpression = valueExpression;
52+
this.valueExpressionTitle = valueExpressionTitle;
53+
this.normalizationType = normalizationType;
4054
this.normalizationField = normalizationField;
55+
this.normalizationTotal = normalizationTotal;
4156
this.stops = stops;
4257
}
4358

@@ -48,7 +63,12 @@ export default class OpacityVariable extends VisualVariable {
4863
toJSON() {
4964
return {
5065
type: this.type,
66+
field: this.field,
67+
valueExpression: this.valueExpression,
68+
valueExpressionTitle: this.valueExpressionTitle,
69+
normalizationType: this.normalizationType,
5170
normalizationField: this.normalizationField,
71+
normalizationTotal: this.normalizationTotal,
5272
stops: this.stops,
5373
};
5474
}

src/service/base/renderer/SimpleRenderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { PointSymbol3D, PolygonSymbol3D, LineSymbol3D } from "../symbols/index";
1212
* @param {Symbol} [symbol] 专题图符号样式
1313
* @param {String} [label] 专题图图例标签,用来描述分配了默认符号的元素
1414
* @param {Array<VisualVariable>} [visualVariables] 专题图视觉变量,可选 "color"|"opacity"|"size"|"rotation"
15+
* @param {Object} [legendOptions] 专题图图例选项,用来在图例中展示符号信息
1516
*/
1617
export default class SimpleRenderer extends Renderer {
1718
constructor(option) {

src/service/base/symbols/ExtrudeSymbol3DLayer.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,31 @@ import Symbol3DLayer from './Symbol3DLayer';
77
* 三维线图层
88
* @author 基础平台-潘卓然
99
* @class mapgis.symbols.ExtrudeSymbol3DLayer
10-
* @classdesc 三维线图层
10+
* @classdesc 三维区图层
1111
* @param {String} [type] 类型,只能是'extrude'
1212
* @param {Object} [castShadows=true] 阴影,默认激活
1313
* @param {Edges3D} [edges] 轮廓线
1414
* @param {Object} [material] 材质
1515
* @param {String} [material.color='rgb(255,255,255)'] 材质-颜色,默认白色
16-
* @param {Number} [size=1] 大小
16+
* @param {Number} [size=1] 大小,当设置sizeField后size不起作用,通过sizeField和sizeRatio计算,若未设置sizeField则直接使用size值
17+
* @param {Number} [sizeField] 拉伸字段
18+
* @param {Number} [sizeRatio=1] 拉伸比例
1719
*/
1820
export default class ExtrudeSymbol3DLayer extends Symbol3DLayer {
1921
constructor(option) {
2022
super(option);
2123
var option = option ? option : {};
22-
const { castShadows = true, edges = undefined } = option;
24+
const { castShadows = true, edges = undefined, sizeField = undefined } = option;
2325
const { material = { color: 'rgb(255,255,255)' } } = option;
24-
const { size = 1 } = option;
26+
const { size = 1, sizeRatio = 1 } = option;
2527

2628
this.type = 'extrude';
2729
this.castShadows = castShadows;
2830
this.edges = edges;
2931
this.material = material;
3032
this.size = size;
33+
this.sizeField = sizeField;
34+
this.sizeRatio = sizeRatio;
3135
}
3236

3337
/**
@@ -44,15 +48,17 @@ export default class ExtrudeSymbol3DLayer extends Symbol3DLayer {
4448
fromJSON(json) {
4549
json = json || {};
4650
const { type = 'extrude' } = json;
47-
const { castShadows = true, edges = undefined } = json;
51+
const { castShadows = true, edges = undefined, sizeField = undefined } = json;
4852
const { material = { color: 'rgb(255,255,255)' } } = json;
49-
const { size = 1 } = json;
53+
const { size = 1, sizeRatio = 1 } = json;
5054
this.type = type;
5155

5256
this.castShadows = castShadows;
5357
this.edges = edges;
5458
this.material = material;
5559
this.size = size;
60+
this.sizeField = sizeField;
61+
this.sizeRatio = sizeRatio;
5662
}
5763

5864
/**
@@ -65,7 +71,9 @@ export default class ExtrudeSymbol3DLayer extends Symbol3DLayer {
6571
castShadows: this.castShadows,
6672
edges: this.edges,
6773
material: this.material,
68-
size: this.size
74+
size: this.size,
75+
sizeField: this.sizeField,
76+
sizeRatio: this.sizeRatio
6977
};
7078
}
7179
}

0 commit comments

Comments
 (0)