2020-08-10 10:44:28 +08:00
|
|
|
|
---
|
|
|
|
|
title: 3D 柱图
|
|
|
|
|
order: 5
|
|
|
|
|
---
|
2021-12-29 17:08:46 +08:00
|
|
|
|
|
2020-11-21 03:51:18 +08:00
|
|
|
|
`markdown:docs/common/style.md`
|
2020-08-20 17:09:45 +08:00
|
|
|
|
|
|
|
|
|
3D 柱图地理区域上方会显示不同高度的柱体,主题的高度与其在数据集中的数值会成正比。
|
2020-08-10 10:44:28 +08:00
|
|
|
|
|
|
|
|
|
## 使用
|
|
|
|
|
|
2020-08-20 17:09:45 +08:00
|
|
|
|
3D 柱图通过 PointLayer 对象实例化,将 shape 设置成不同的 3Dshape
|
|
|
|
|
|
2020-08-10 10:44:28 +08:00
|
|
|
|
### shape
|
|
|
|
|
|
|
|
|
|
3D Shape 支持
|
|
|
|
|
|
2020-08-20 17:09:45 +08:00
|
|
|
|
- cylinder
|
2020-08-10 10:44:28 +08:00
|
|
|
|
- triangleColumn
|
|
|
|
|
- hexagonColumn
|
|
|
|
|
- squareColumn
|
|
|
|
|
|
|
|
|
|
### size
|
|
|
|
|
|
2020-08-20 17:09:45 +08:00
|
|
|
|
3D 柱图 size 需要设置三个维度 [w, l, z]
|
|
|
|
|
|
|
|
|
|
- w 宽
|
|
|
|
|
- l 长
|
|
|
|
|
- z 高度
|
2020-08-10 10:44:28 +08:00
|
|
|
|
|
2020-08-20 17:09:45 +08:00
|
|
|
|
size 设置成常量
|
2020-08-10 10:44:28 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
layer.size([2,2,3])
|
2020-08-20 17:09:45 +08:00
|
|
|
|
```
|
|
|
|
|
|
2020-08-10 10:44:28 +08:00
|
|
|
|
size 回调函数设置
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
layer.size('unit_price', h => {
|
|
|
|
|
return [ 6, 6, h / 500 ];
|
|
|
|
|
})
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
const column = new PointLayer({})
|
2020-08-20 17:09:45 +08:00
|
|
|
|
.source(data)
|
|
|
|
|
.shape('name', [
|
|
|
|
|
'cylinder',
|
|
|
|
|
'triangleColumn',
|
|
|
|
|
'hexagonColumn',
|
|
|
|
|
'squareColumn',
|
|
|
|
|
])
|
|
|
|
|
.size('unit_price', (h) => {
|
|
|
|
|
return [6, 6, h / 500];
|
|
|
|
|
})
|
|
|
|
|
.color('name', ['#5B8FF9', '#70E3B5', '#FFD458', '#FF7C6A'])
|
|
|
|
|
.style({
|
|
|
|
|
opacity: 1.0,
|
|
|
|
|
});
|
2020-08-10 10:44:28 +08:00
|
|
|
|
```
|
2021-12-29 17:08:46 +08:00
|
|
|
|
|
2021-12-23 14:01:44 +08:00
|
|
|
|
### animate
|
2021-12-29 17:08:46 +08:00
|
|
|
|
|
|
|
|
|
3D 柱图支持生长动画
|
2021-12-23 14:01:44 +08:00
|
|
|
|
animate 方法支持的布尔值和对象参数
|
2021-12-06 17:06:44 +08:00
|
|
|
|
|
2021-12-23 14:01:44 +08:00
|
|
|
|
```javascript
|
|
|
|
|
animate(true)
|
|
|
|
|
animate(false)
|
|
|
|
|
|
|
|
|
|
animate(animateOptions)
|
|
|
|
|
|
|
|
|
|
animateOptions: {
|
|
|
|
|
enable: boolean;
|
|
|
|
|
speed?: number = 0.01;
|
|
|
|
|
repeat?: number = 1;
|
|
|
|
|
}
|
|
|
|
|
```
|
2021-12-29 17:08:46 +08:00
|
|
|
|
|
2021-12-06 17:06:44 +08:00
|
|
|
|
## 额外的 style 配置
|
|
|
|
|
|
|
|
|
|
- sourceColor 设置 3D 柱图起始颜色(3D 柱图设置颜色渐变时会覆盖 color 设置的颜色)
|
|
|
|
|
|
|
|
|
|
- targetColor 设置 3D 柱图终止颜色
|
|
|
|
|
|
|
|
|
|
- opacityLinear 设置 3D 柱图透明度渐变
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
style({
|
|
|
|
|
opacityLinear: {
|
|
|
|
|
enable: true, // true - false
|
2021-12-29 17:08:46 +08:00
|
|
|
|
dir: 'up', // up - down
|
|
|
|
|
},
|
|
|
|
|
});
|
2021-12-06 17:06:44 +08:00
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
- lightEnable 是否开启光照
|
|
|
|
|
|
|
|
|
|
```javascript
|
|
|
|
|
layer.style({
|
|
|
|
|
opacity: 0.8,
|
|
|
|
|
sourceColor: 'red',
|
|
|
|
|
targetColor: 'yellow',
|
|
|
|
|
});
|
|
|
|
|
```
|
2021-12-29 17:08:46 +08:00
|
|
|
|
|
2021-12-06 17:06:44 +08:00
|
|
|
|
[光标柱图](../../../../examples/point/column#column_light)
|
|
|
|
|
[渐变柱图](../../../../examples/point/column#column_linear)
|
|
|
|
|
|
2020-11-16 15:19:41 +08:00
|
|
|
|
`markdown:docs/common/layer/base.md`
|