找回密码
 立即注册

QQ登录

只需一步,快速开始

@Martin.Zhang
超级版主   /  发表于:2024-2-4 15:19  /   查看:551  /  回复:0
显示效果:

image.png521556396.png
实现步骤:
1.使用Echarts图表
image.png803407897.png
2.绑定数据
image.png177255858.png
3.属性中调整自定义属性
image.png192875670.png
代码内容:
  1. var data1 = option.series[0].data.map((x)=>{
  2.         return x.value
  3.     });
  4.     var data2 = option.series[1].data.map((x)=>{
  5.         return x.value
  6.     });
  7.     //定义两个上下箭头的矢量路径
  8.     var up = 'path://M286.031,265l-16.025,3L300,223l29.994,45-16.041-3-13.961,69Z';
  9.     var down = 'path://M216.969,292l16.025-3L203,334l-29.994-45,16.041,3,13.961-69Z'
  10.     //遍历data2里面元素的正负定义一个矢量路径的数组
  11.     var path = [up,down,up,down,down,down,up]



  12.     const _option = {
  13.         color: ['#3398DB'],
  14.         tooltip: {
  15.             trigger: 'axis',
  16.             axisPointer: {            // 坐标轴指示器,坐标轴触发有效
  17.                 type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
  18.             }
  19.         },
  20.         grid: {
  21.             top:option.grid.top,
  22.             left: option.grid.left,
  23.             right: option.grid.right-104,
  24.             bottom:option.grid.bottom,
  25.             containLabel: true,
  26.         },
  27.         xAxis: option.xAxis,
  28.         yAxis: option.yAxis[0],
  29.         series: [
  30.             {
  31.                 "name": "",
  32.                 type: 'pictorialBar',
  33.                 symbol: function(data,params){
  34.                     if(data2[params.dataIndex]>0){
  35.                         return up
  36.                     }else{
  37.                         return down
  38.                     }

  39.                 },
  40.                 symbolSize: [20, 30],
  41.                 symbolOffset: [0, -40],
  42.                 color:'orange',
  43.                 symbolPosition: 'end',
  44.                 "label": {
  45.                     "show": true,
  46.                     "color": "#ffffff",
  47.                     "fontStyle": "normal",
  48.                     "fontWeight": "normal",
  49.                     "fontFamily": "font-34b4f28e-178a-45fa-87ad-37c48a8f32bf",
  50.                     "fontSize": 13.333333333333334,
  51.                     "position": "top",
  52.                     "alignTo": "none",
  53.                     "textBorderColor": "transparent",
  54.                     "bleedMargin": 0
  55.                 },
  56.                 data: data1
  57.             },
  58.             {
  59.                 name: '直接访问',
  60.                 type: 'bar',
  61.                 barWidth: '40%',
  62.                 data: data1
  63.             }
  64.         ]
  65.     };
  66. return _option;
复制代码
运行,浏览效果。
示例案例: wyn-export-20240204151842.zip (398.72 KB, 下载次数: 18)

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部