ECharts 中的 brush(区域选择组件)有一系列属性可以配置,以满足不同的需求。以下是一些常用的 brush 属性及其说明:

1. toolbox: 用于配置工具栏中的 brush 图标,指定可用的 brush 功能。可以配置的值有:

   - 'rect': 矩形选择
   - 'polygon': 任意形状选择
   - 'lineX': 横向选择
   - 'lineY': 纵向选择
   - 'keep': 保持选择
   - 'clear': 清除选择
   brush: {
       toolbox: ['rect', 'polygon', 'lineX', 'lineY', 'keep', 'clear'],
   }

2. xAxisIndex/yAxisIndex: 设置 brush 生效的轴。可以通过指定 xAxisIndex 和 yAxisIndex 来指定 brush 生效的轴的索引。
   brush: {
       xAxisIndex: 0,  // 在第一个 x 轴上进行 brush
   }

3. brushLink: 多个 brush 组件联动,设置成数组序号可联动对应的 brush 组件。
   brush: {
       brushLink: [0, 1],  // 与序号为0和1的 brush 组件联动
   }

4. brushType: 设置 brush 的类型,有 'rect'(矩形)和 'polygon'(多边形)两种。
   brush: {
       brushType: 'rect',  // 或 'polygon'
   }

5. transformable: 是否可以通过拖拽、缩放来修改选择区域。
   brush: {
       transformable: true,
   }

6. toolbox.icon: 设置工具栏中 brush 图标的样式,包括 color、borderColor、borderWidth 等。
   brush: {
       toolbox: {
           icon: {
               color: 'red',
               borderColor: 'blue',
               borderWidth: 2,
           }
       }
   }

7. title: 设置 brush 工具栏中每个功能按钮的标题。
   brush: {
       toolbox: {
           title: {
               rect: '矩形选择',
               polygon: '任意形状选择',
               lineX: '横向选择',
               lineY: '纵向选择',
               keep: '保持选择',
               clear: '清除选择',
           }
       }
   }

8. throttleType/throttleDelay: 用于设置 brush 触发频率的节流方式和延迟时间。
   brush: {
       throttleType: 'debounce',  // 或 'fixRate'
       throttleDelay: 300,        // 节流延迟时间,单位ms
   }

以上是一些常用的 brush 属性,你可以根据具体需求选择性配置。请注意,ECharts 的版本可能有所不同,建议查阅相应版本的官方文档以获取最准确的信息。


转载请注明出处:http://www.zyzy.cn/article/detail/5332/ECharts