echarts疑难杂症

1.标注最大值最小值,区域渐变,设置高亮区域

在这里插入图片描述

option = {
  title: {
    text: '标题',
    left: 'center',
    textStyle: {
      fontSize: '24',
      fontWeight: 'normal'
    }
  },
  tooltip: {
    trigger: 'axis'
  },
  xAxis: {
    type: 'category',
    data: [
      '02/01',
      '02/02',
      '02/03',
      '02/04',
      '02/05',
      '02/06',
      '02/07',
      '02/08',
      '02/09',
      '02/10',
      '02/11',
      '02/12',
      '02/13',
      '02/14',
      '06/15',

    ],
    axisLabel: {
      fontSize: 20
    }
  },
  yAxis: {
    type: 'value',
    name: '用电指数',
    nameTextStyle: {
      fontSize: 20
    },
    axisLabel: {
      fontSize: 20
    }
  },
  series: [
    {
      data: [
        '0.99',
        '2.08',
        '1.14',
        '1.02',
        '0.90',
        '0.55',
        '1.97',
        '1.08',
        '1.46',
        '1.48',
        '1.58',
        '0.66',
        '0.59',
        '0.53',
        '0.70',
        
      ],
      type: 'line',
      color: '#45C0F7',
      areaStyle: {
        normal: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
            { offset: 0, color: '#45C0F7' },
            { offset: 0.5, color: '#45C0F7' },
            { offset: 1, color: 'white' }
          ])
        }
      }, //填充区域样式 蓝色渐变
      markPoint: {
        data: [
          { type: 'max', name: '最大值' },
          { type: 'min', name: '最小值' }
        ]
      }, //显示最大值 最小值
      markArea: {//标注特殊区域 设置颜色
        itemStyle: {
          color: 'rgba(255, 173, 177, 0.4)'
        },
        data: [
          [
            {
              name: '',
              xAxis: '02/05'
            },
            {
              xAxis: '02/06'
            }
          ],
          [
            {
              name: '',
              xAxis: '02/12'
            },
            {
              xAxis: '02/13'
            }
          ],
          
        ]
      }
    }
  ]
};


2.x轴竖版显示,柱状图渐变色

在这里插入图片描述

option = {
  title: {
        text: 'title-text',
        left: 'center',
        textStyle: {
          fontSize: 26,
          fontWeight: 'normal',
        },
      },
      tooltip: {
        trigger: 'axis',
        formatter: '{b}:{c}',
      },
      xAxis: {
        type: 'category',
        data: ["朝阳区", "怀柔区", "房山区", "昌平区", "西城区", "延庆区", "密云区", "海淀区"],
        tooltip: {
          trigger: 'axis',
        },
        axisLabel: {
          fontSize: 17,
          formatter: function (value) {
            //x轴的文字改为竖版显示
            var str = value.split('');
            return str.join('\n');
          },
        },
      },
      yAxis: {
        type: 'value',
        name: '增幅企业数量(家)',
        nameTextStyle: {
          fontSize: 16,
        },
        axisLabel: {
          fontSize: 20,
        },
      },
      series: [
        {
          data: [2,3,1,5,2,5,4,3],
          type: 'bar',
          barWidth: '20px',
          itemStyle: {
            normal: {
              label: {
                show: true,
                position: 'top',
              },
              color: new echarts.graphic.LinearGradient(
                0,
                1,
                0,
                0,
                [
                  {
                    offset: 0,
                    color: '#fff',
                  },
                  {
                    offset: 0.6,
                    color: '#45C0F7',
                  },
                  {
                    offset: 1,
                    color: '#45C0F7',
                  },
                ],
                false
              ),
            },
          },
        },
      ],
    
};
3.实现横向柱状图

在这里插入图片描述

let histo1 = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow',
      },
    },
    legend: {
      top: '-10%',
      left: '22%',
      data: ['大兴区'],
      itemWidth: 0,
      textStyle: {
        fontWeight: 'normal',
        fontSize: '15',
        color: '#fff',
        textAlign: 'center',
      },
    },
    grid: {
      width: '75%',
      top: '0%',
      left: '5%',
      right: '0%',
      bottom: '0%',
      containLabel: true,
    },
    xAxis: {
      type: 'value',
      // boundaryGap: [0, 0.01],
      show: false,
      splitLine: {
        // 网格线
        show: false,
      },
      axisTick: {
        //y轴刻度线
        show: false,
      },
      axisLine: {
        //轴线
        show: false,
      },
    },
    yAxis: {
      type: 'category',
      data: className,
      splitLine: {
        // 网格线
        show: false,
      },
      axisTick: {
        show: true,
        inside: true,
        length: 5,
        lineStyle: {
          color: '#8ad474',
          width: 2,
        },
      },
      axisLabel: {
        show: true,
        interval: 0,
        color: '#fff',
        fontSize: 15,
        padding: [10, 5, 10, 10],
        formatter: function (value, i) {
          return `{title|${className[i].title}} ${className[i].value ? `{value|${className[i].value}}` : ''}`;
        },
        rich: {
          title: {
            fontSize: 14,
            padding: 0,
            margin: 0,
            left: 10,
            bottom: 0,
            top: 0,
            right: 0,
          },
          value: {
            fontSize: 14,
            verticalAlign: 'bottom',
            padding: 0,
            margin: 0,
          },
        },
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: '#8ad474',
          width: 2,
        },
      },
    },
    series: [
      {
        // name: '大兴区',
        type: 'bar',
        data: dataDaxing,
        left: '1%',
        right: '1%',
        bottom: '1%',
        top: '10%',
        barWidth: 10,
        barGap: '5%',
        itemStyle: {
          color: '#8ad474',
        },
        label: {
          //数据
          show: true,
          position: 'right',
          color: '#8ad474',
          textStyle: {
            fontWeight: 'normal',
            fontSize: '15',
            fontWeight: 700,
            textAlign: 'center',
          },
        },
      },
    ],
  };
  let histo2 = {
    tooltip: {
      trigger: 'axis',
      axisPointer: {
        type: 'shadow',
      },
    },
    legend: {
      top: '5%',
      right: '10%',
      data: ['北京市'],
      itemWidth: 0,
      textStyle: {
        fontWeight: 'normal',
        fontSize: '15',
        color: '#fff',
        textAlign: 'center',
      },
    },
    grid: {
      width: '60%',
      top: '0%',
      right: '0%',
      bottom: '0%',
      containLabel: true,
    },
    xAxis: {
      type: 'value',
      // boundaryGap: [0, 0.01],
      inverse: true,
      show: false,
      splitLine: {
        // 网格线
        show: false,
      },
      axisLine: {
        //轴线
        show: true,
        lineStyle: {
          color: '#318ef1',
        },
      },
    },
    yAxis: {
      type: 'category',
      data: ['', '', '', '', '', ''],
      splitLine: {
        // 网格线
        show: false,
      },
      axisTick: {
        show: true,
        inside: false,
        length: 5,
        lineStyle: {
          // color: "#8ad474",
          width: 2,
        },
      },
      axisLabel: {
        show: true,
        interval: 0,
        color: '#fff',
        fontSize: 15,
        padding: [10, 5, 10, 10],
      },
      axisLine: {
        show: true,
        lineStyle: {
          color: '#318ef1',
          width: 2,
        },
      },
    },
    series: [
      {
        // name: '北京市',
        type: 'bar',
        data: data,
        barWidth: 10,
        itemStyle: {
          color: '#318ef1',
        },
        label: {
          //数据
          show: true,
          position: 'left',
          color: '#318ef1',
          textStyle: {
            fontWeight: 'normal',
            fontSize: '15',
            fontWeight: 700,
            textAlign: 'center',
          },
        },
      },
    ],
  };



return(
 <div className="left-b-left-histograms">
        <div className="left-b-left-histogram-daxing">
          <MapEcharts chartsOption={histo2} />
        </div>
        <div className="left-b-left-histogram-beijing">
          <MapEcharts chartsOption={histo1} />
        </div>
      </div>
)
4.两个legend,legend表示柱状图颜色

在这里插入图片描述

option = {
  color:['blue','green','yellow','orange','red'],
  legend:[{
    data:['1-2','3-4','4-5','5-6'],
  orient: 'vertical',
  right:'right',
  top:'center',
   itemGap: 30,
  },{
  data:['未检测'],
  top:'top',

   itemGap: 30,
  }],
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [120, 200, 150, 80, 70, 110, 130],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
      name:'0-1',
      barWidth:50,
       itemStyle: {
            normal: {
                // 随机显示
                //color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1)).toString(16);}
              
                // 定制显示(按顺序)
                color: function(params) { 
                  console.log('params',params)
                    var colorList = ['#C33531','#EFE42A','#64BD3D','#EE9201','#29AAE3', '#B74AE5','#0AAF9F','#E89589','#16A085','#4A235A','#C39BD3 ','#F9E79F','#BA4A00','#ECF0F1','#616A6B','#EAF2F8','#4A235A','#3498DB' ]; 
                    return colorList[params.dataIndex] 
                }
            },
        },
    },
     {
      data: [],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
      name:'1-2',
       barWidth:0
    },
     {
      data: [],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
      name:'3-4',
         barWidth:0
    },
        {
      data: [],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
      name:'4-5',
         barWidth:0
    },
     {
      data: [],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
      name:'5-6',
         barWidth:0
    },
     {
      data: [],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      },
      name:'未检测',
         barWidth:0
    },
  ]
};
5.高亮区域设置legend

在这里插入图片描述

option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  legend: {},
  series: [
    {
      name: '11',
      data: [150, 230, 224, 218, 135, 147, 260],
      type: 'line'
    },
    {
      name: '22',
      data: [],
      type: 'bar',
      markLine: {
        data: [{ xAxis: 'Wed' }],
        label: {
          normal: { show: false },
          emphasis: { show: false }
        },
        lineStyle: {
          emphasis: {
            type: 'solid',
            opacity: 0.8,
            color: 'blue',
            width: 20
          },
          normal: {
            type: 'solid',
            opacity: 0.4,
            color: 'red',
            width: 20
          }
        }
      }
    }
  ]
};
6.仪表盘 指针处展示数值

仪表盘,只有指针处展示数值,其他刻度不展示,下面数值也不能消失。
在这里插入图片描述
在这里插入图片描述

option = {
  series: [
    {
      type: 'gauge',
      progress: {
        show: true,
        width: 18
      },
      axisLine: {
        lineStyle: {
          width: 18
        }
      },
      axisTick: {
        show: false
      },
      splitNumber:100,
      splitLine: {
        length: 15,
        lineStyle: {
          width: 2,
          color: '#999'
        }
      },
      axisLabel: {
        distance: 25,
        color: '#999',
        fontSize: 20,
        formatter:function(value){
          if(value==28){
            return value
          }else{
            return ''
          }
        }
      },
      anchor: {
        show: true,
        showAbove: true,
        size: 25,
        itemStyle: {
          borderWidth: 10
        }
      },
      detail: {
        valueAnimation: true,
        fontSize: 80,
        offsetCenter: [0, '70%']
      },
      data: [
        {
          value: 28
        }
      ]
    }
  ]
};
7.柱状图根据数值每个注展示不同的颜色,legend设置为实心

在这里插入图片描述
getBgColorForHour1New方法:
根据传进去的污染物id和数值,返回一个对象,包含应该展示的颜色

{
            title: [
              {
                text: [
                  i.name,
                  `{a|${pollutionType.name}}`,
                  `{b|${pollutionType.subName}}`,
                  '达标曲线图',
                ].join(''),
                left: 20,
                textStyle: {
                  fontWeight: 180,
                  fontSize: 15,
                  rich: {
                    a: {
                      fontSize: 14,
                    },
                    b: {
                      fontSize: 8,
                      verticalAlign: 'bottom',
                    },
                  },
                },
              },
              {
                text:
                  '累计浓度:' +
                  i.cumulative_value_single +
                  '  目标浓度:' +
                  i.target_value_single +
                  '  剩余浓度:' +
                  (i.residual_control_single > 0
                    ? i.residual_control_single
                    : '无法完成'),
                left: 350,
                textStyle: {
                  fontSize: 12,
                  fontWeight: 550,
                },
              },
            ],
            tooltip: {
              trigger: 'axis',
            },
            toolbox: {
              feature: {
                saveAsImage: {},
              },
            },
            xAxis: {
              type: 'category',
              axisLine: { lineStyle: { color: fontColor } },
              data: i.time,
            },
            legend: {
              bottom: '2%',
              textStyle: { color: fontColor },
            },
            grid: {
              bottom: '24%',
              top: '14%',
            },
            yAxis: {
              type: 'value',
              axisLabel: {
                color: '#9ec7e7',
              },
              axisLine: {
                show: true,
                lineStyle: {
                  color: fontColor,
                },
              },
            },
            series: [
              {
                name: '日浓度',
                data: i.initial_value,
                type: 'bar',
                itemStyle: {
                  normal: {
                    color: function (params) {
                      return getBgColorForHour1New(params.value, data.var_id)
                        .backgroundColor;
                    },
                  },
                },
              },
              {
                name: '累计浓度',
                data: i.cumulative_value,
                type: 'line',
                symbol: 'circle',//legend设置为实心
                itemStyle: {
                  color: '#f90000',
                },
              },
              {
                name: '目标浓度',
                data: i.target_value,
                type: 'line',
                symbol: 'circle',
                itemStyle: {
                  color: '#feff00',
                },
              },
              {
                name: '剩余控制',
                data: i.residual_control,
                type: 'line',
                symbol: 'circle',
                itemStyle: {
                  color: '#fb7f00',
                },
              },
            ],
          };
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在使用Docker时,可能会遇到一些疑难杂症。其中,一些常见的问题及解决办法如下: 1. 运行docker version时报错"Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?"这个错误通常是由于Docker守护进程未启动引起的。可以通过运行以下命令来启动守护进程:`sudo systemctl start docker`(适用于基于systemd的Linux发行版)。如果您不是使用systemd,请根据您的操作系统和版本来启动Docker守护进程。 2. 使用yum安装Docker时报错"Cannot retrieve metalink for repository: epel. Please verify its path and try again."这个错误通常是由于epel源(Extra Packages for Enterprise Linux)未正确安装或配置引起的。您可以尝试以下解决办法: - 首先,确保您的系统与互联网连接正常。 - 检查您的操作系统和版本,并根据官方文档正确安装epel源。 - 如果您已经安装了epel源,但仍然遇到这个错误,请尝试更新epel源并再次运行安装命令。 这些是一些常见的Docker疑难杂症及其解决办法。当然,Docker的使用过程中可能还会遇到其他问题,您可以参考官方文档、社区论坛或搜索引擎来寻找更多解决办法。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [docker 疑难杂症](https://blog.csdn.net/weixin_33805992/article/details/92266045)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [docker常见疑难杂症](https://blog.csdn.net/weixin_45776707/article/details/103142818)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值