在 ECharts 的 toolbox 中,feature 属性用于配置工具栏的功能按钮。这里列举一些常见的 feature 属性及其功能按钮:

1. 保存为图片(Save As Image):
   - 功能:保存当前图表为图片。
   
   toolbox: {
       feature: {
           saveAsImage: {}  
       }
   }

2. 数据视图(Data View):
   - 功能:查看当前图表的原始数据。
   
   toolbox: {
       feature: {
           dataView: {}     
       }
   }

3. 数据区域缩放(Data Zoom):
   - 功能:支持缩放和平移,可以在图表上选择特定区域进行放大。
   
   toolbox: {
       feature: {
           dataZoom: {}  
       }
   }

4. 还原(Restore):
   - 功能:还原图表到初始状态。
   
   toolbox: {
       feature: {
           restore: {}     
       }
   }

5. 刷新(Refresh):
   - 功能:刷新图表,重新加载数据。
   
   toolbox: {
       feature: {
           refresh: {}     
       }
   }

6. 选择(Data Picker):
   - 功能:支持选择特定的数据。
   
   toolbox: {
       feature: {
           dataZoom: {}, // 配合 dataZoom 使用
           brush: {}      // Data Picker 功能
       }
   }

7. 图表类型切换(Magic Type):
   - 功能:切换不同的图表类型,例如折线图、柱状图等。
   
   toolbox: {
       feature: {
           magicType: {}  
       }
   }

8. 自定义功能按钮(自定义扩展):
   - 功能:可以自定义添加其他功能按钮,如用户自定义的功能。
   
   toolbox: {
       feature: {
           myCustomFeature: {
               show: true,
               title: '自定义功能',
               icon: 'path://M512 96c247.42 0 448 200.58 448 448s-200.58 448-448 448S64 791.42 64 544 264.58 96 512 96zm0 800c176.81 0 320-143.19 320-320s-143.19-320-320-320S192 575.19 192 752s143.19 320 320 320zm-64-168V312c0-13.25 10.75-24 24-24s24 10.75 24 24v416c0 13.25-10.75 24-24 24s-24-10.75-24-24z',
               onclick: function () {
                   // 在这里定义自定义按钮的点击事件
                   console.log('自定义按钮被点击了!');
               }
           }
       }
   }

这些是一些常见的 feature 属性配置示例,你可以根据实际需求选择相应的功能按钮,并进行定制。


转载请注明出处:http://www.pingtaimeng.com/article/detail/5318/ECharts