echarts pie, shown separately and indication line arranged in all of the display

 const option = {
      title: {
        text: canvasStyles.name,
        x: 'center',
        y: 'center',
        textStyle: {
          color: '#fff',
          fontSize: 12
        }
      },
      tooltip: {
        show: false
        // trigger: 'item',
        // formatter: function(e) {
        //   var res = `<div>${e.data.name}:${e.data.value}</div>`;
        //   return res;
        // },
        // position: function(pos, params, dom, rect, size) {
        //   var data = params.data;
        //   var sHtml = `<div style="background:orange>555</div>`;
        //   console.log(dom);
        //   console.log(pos);
        //   console.log(params);
        //   console.log(dom);
        //   console.log(rect);
        //   console.log(size);
        //   return sHtml;
        // }
        //extraCssText: 'background:orange;transform:rotate(40deg)'
      },
      grid: {
        top: '15%'
      },
      legend: {
        orient: canvasStyles.legendOrient || 'vertical',
        //x: canvasStyles.legendX,
        y: canvasStyles.legendY,
        right: canvasStyles.right || 0,
        data: canvasStyles.legend,
        itemWidth: 15,
        itemHeight: 10,
        itemGap: 5,
        formatter: function(name) {
          return name.length > 5 ? name.substr(0, 5) + '...' : name;
        },
        textStyle: {
          color: '#fff',
          fontSize: 10
        }
      },
      color: canvasStyles.color,
      series: [
        {
          name: '房屋状态',
          type: 'pie',
          radius: ['40%', '48%'],
          center: ['50%', '50%'],
          minAngle: 12,
          avoidLabelOverlap: false,
          label: {
            normal: {
              show: false,
              formatter: '{c|{c}} ({d|{d}%})\n{hr|}\n{a|{a}}',
              lineStyle: {
                color: 'yellow',
                width: 2
              },
              rich: {
                a: {
                  padding: 4
                },
                b: {
                  fontSize: 12,
                  align: 'left',
                  padding: 82,
                  margin: 80,
                  lineHeight: 80
                },
                hr: {
                  borderColor: '#4681ec',
                  width: '100%',
                  borderWidth: 2,
                  height: 0
                },
                d: {
                  fontSize: 12,
                  align: 'left',
                  padding: 4
                },
                c: {
                  fontSize: 12,
                  align: 'left'
                }
              }
            },
            emphasis: {
              position: 'left',
              show: true,
              textStyle: {
                fontSize: '14',
                fontWeight: 'bold'
              },
              length: 1
            }
          },
          // avoidLabelOverlap: false,
          // label: {
          //   normal: {
          //     show: false,
          //     position: 'center',
          //     formatter: canvasStyles.tipNameType == '' || !canvasStyles.tipNameType ? '{b}\n{c}' : '' + canvasStyles.tipNameType + '\n{b}\n{c}'
          //   },
          //   emphasis: {
          //     show: true,
          //     textStyle: {
          //       fontSize: '14',
          //       fontWeight: 'bold'
          //     }
          //   }
          // },
          // labelLine: {
          //   normal: {
          //     show: false
          //   }
          // },
          data: canvasStyles.data
        }
      ]
    };

  

  to sum up:

 

1, normal show label of the series which is true all the time is displayed indicating lines for display only when a false

Style, rich with the ground can be customization indication line '{c | {c}} \ n {hr | |} \ n {{d}% d}': 2.formatter

3

minAngle: 12, // setting range above the minimum area
avoidLabelOverlap: false, when the time is false text can overlap, but with the show above normal for the time of false
 Can prevent the line is too long
 

Guess you like

Origin www.cnblogs.com/lsc-boke/p/11114556.html
Recommended