// 省级美丽宜居示范村创建
// Area:地区 Finish：完成值
var myChart61 = echarts.init(document.querySelector(".echart61"))
var myChart62 = echarts.init(document.querySelector(".echart62"))
var livablev = "http://118.178.224.202:8024/api/livable-v"
$.get(livablev, function (data) {
  var d = []
  d = data.data
  let arryArea = []
  let arryFinish = []
  let arryMbiao = []
  let countFinish = 0
  let countMbiao = 0
  d.forEach(function (item) {
    arryArea.push(item.area)
    arryFinish.push(item.finish)
    arryMbiao.push(item.finish)
    countFinish += item.finish
    countMbiao  += item.target
  })

  $("#countFinish").empty().append(countFinish)
  $("#countMbiao").empty().append(countMbiao)


  var option61 = {
    tooltip: {
      trigger: "item",
      show: false,
      showContent: true,
    },
    // legend: {
    //   top: "5%",
    //   left: "center",
    //   itemStyle: {
    //     tooltip: true,
    //   },
    // },
    series: [{
      // name: "Access From",
      type: "pie",
      radius: ["70%", "90%"],
      avoidLabelOverlap: false,
      label: {
        show: true,
        // position: "center",
      },
      itemStyle: {
        color: "#3D9DF4",
      },
      emphasis: {
        label: {
          show: true,
          fontSize: "40",
          fontWeight: "bold",
        },
        itemStyle: {
          shadowBlur: 10,
          shadowOffsetX: 0,
          shadowColor: "rgba(0, 0, 0, 0.5)",
        },
      },
      labelLine: {
        show: false,
      },
      data: [
        {
          value: countMbiao,
          name: (countMbiao/countMbiao*100).toFixed(0) + "%" ,
          label: {
            position: "center",
            fontSize: 16,
          },
        },
        {
          value: countMbiao-countMbiao,
          // name: "43%",
          itemStyle: {
            color: "#EEEEEE",
          },
          label: {
            position: "center",
            fontSize: 16,
          },
        },
    ],
    }, ],
  }

  myChart61.setOption(option61)

  var option62 = {
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "shadow",
      },
      confine: true,
      formatter: "{b}" + "&nbsp;&nbsp;" + "{a0}" + ":&nbsp;" + "{c0}",
    },
    legend: {
      top: "0",
      left: 0,
selectedMode: false,
   itemWidth: 15,
   itemHeight:10,
      textStyle: {
        fontSize: 13,
        color: "#6e7178",
      },
    },

    grid: {
      left: 0,
      right: 0,
      bottom: 0,
      top: 40,
    },
    yAxis: [
      {
        type: "category",

        axisLabel: {
          align: "left",
          verticalAlign: "bottom",
          lineHeight: 34,
          margin: -0,
          fontSize: 14,
          color: "#6e7178",
        },
        // tick是刻度，tickeline刻度线，axis是轴，
        axisTick: {
          show: false,
        },
        axisTickLine: {
          show: false,
        },
        axisLine: {
          show: false,
        },

        data: arryArea,
      },
    ],
    xAxis: [
      {
        show: false,
      },
    ],

    // label: {
    //   show: true,
    //   position: "left",
    //   align: "right",
    //   offset: [380, -13],
    //   formatter: "{c}个",
    //   fontSize: 14,
    //   color: "red",
    // },
	
	label: {
	  show: true,
	  position: "left",
	  align: "right",
	  offset: [$(".echart62").width(), -13],
	  formatter: "{c}个",
	  fontSize: 14,
	  color: "#6e7178",
	},
	
	
    series: [
      {
        name: "各区县市完成值",
        type: "bar",
        barWidth: 10,
        data: arryFinish,
        itemStyle: {
          color: "#83BBFF",
          borderRadius: 5,
        },
        showBackground: {
          show: true,
        },
        backgroundStyle: {
          color: "#E6F1FF",
          borderRadius: 5,
        },
      },
    ],
  }

  myChart62.setOption(option62)
})

// var taskId2 = "229185203687473152"
// var quotaCode2 = "Q229262828229443587"
// var url2 =
//   "https://sznbs.ningbo.gov.cn:89/nbszhjkzz/tojcms/getQuotaByTaksIdOrQuotaCode.do?parentQuotaCode=" +
//   quotaCode2 +
//   "&systemName=government"

// $.post(url2, function (data) {
//   var d = unique(data.infoList)
//   // var colors = ["#31C563"]

//   var option62 = {
//     // color: colors,
//     tooltip: {
//       trigger: "axis",
//       axisPointer: {
//         type: "cross",
//       },
//     },
//     legend: {
//       top: "5%",
//       left: "center",
//       itemStyle: {
//         tooltip: true,
//       },
//       textStyle: {
//         fontSize: 16,
//         color: "#797979",
//       },
//     },
//     grid: {
//       left: "1%",
//       // right: "1%",
//       bottom: 25,
//       containLabel: true,
//     },
//     yAxis: [{
//       type: "category",
//       axisTick: {
//         alignWithLabel: true,
//       },
//       axisLabel: {
//         fontSize: 16,
//         interval: 0,
//       },

//       data: d.map(function (item) {
//         return ningbo_allareas[item["areaCode"]]
//       }),
//     },],
//     xAxis: {
//       type: "value",
//       name: "套",
//       min: 0,
//       max: 5,
//       position: "left",
//       axisLine: {
//         show: true,
//         lineStyle: {
//           // color: colors[0],
//         },
//       },
//       axisTick: {
//         show: true,
//       },
//       splitLine: {
//         show: false,
//       },
//       axisLabel: {
//         formatter: "{value} 套",
//         fontSize: 16,
//       },
//       nameTextStyle: {
//         // color: "#31C563",
//         fontSize: 16,
//       },
//     },
//     series: [{
//       name: "各区县市完成值",
//       type: "bar",
//       barWidth: "30%",
//       data: d.map(function (item) {
//         return item["currentValue"]
//       }),
//       itemStyle: {
//         normal: {
//           color: "#31C563",
//           label: {
//             show: false, //显示文本

//             textStyle: {
//               color: "#000",
//               fontSize: "14",
//             },
//           },
//         },
//       },
//     },],
//   }

//   myChart62.setOption(option62)
// })

// 农村房屋隐患排查整治
// FenM, FenZ:所有农村房屋排查录入率 FenZ1, FenM1: 鉴定为C、D级用作生产经营自建房的整治改造率 FenZ2, FenM2: 初判不安全的农村房屋鉴定率
var myChart63 = echarts.init(document.querySelector(".echart63"))
var myChart64 = echarts.init(document.querySelector(".echart64"))
var myChart65 = echarts.init(document.querySelector(".echart65"))
var new1 = "http://118.178.224.202:8024/api/new1"
$.get(new1, function (data) {
  var d = []
  d = data.data
  let arryFenM = d[0]?.fenM
  let arryFenZ = d[0]?.fenZ
  let arryFenM1 = d[0]?.fenM1
  let arryFenZ1 = d[0]?.fenZ1
  let arryFenM2 = d[0]?.fenM2
  let arryFenZ2 = d[0]?.fenZ2

  let rate1 = arryFenM == 0 ? 0 : Number((arryFenZ / arryFenM) * 100)
  let other1 = Number(100 - rate1)
  let rate_percent1 = rate1.toFixed(1) + "%"
  let other_percent1 = other1.toFixed(1) + "%"
  let ratedata1 = [
    {
      value: rate1,
      name: rate_percent1,
      label: {
        position: "center",
        fontSize: 18,
        // color: "#31C463",
      },
      // itemStyle: {
      //   color: "#31C463",
      // },
    },
    {
      value: other1,
      name: other_percent1,
      itemStyle: {
        color: "#EFEFEF",
      },
      label: {
        show: false,
      },
    },
  ]

  let rate2 = arryFenM == 0 ? 0 : Number((arryFenZ1 / arryFenM1) * 100)
  let other2 = Number(100 - rate2)
  let rate_percent2 = rate2.toFixed(1) + "%"
  let other_percent2 = other2.toFixed(1) + "%"
  let ratedata2 = [
    {
      value: rate2,
      name: rate_percent2,
      label: {
        position: "center",
        fontSize: 18,
        // color: "#31C463",
      },
      // itemStyle: {
      //   color: "#31C463",
      // },
    },
    {
      value: other2,
      name: other_percent2,
      itemStyle: {
        color: "#EFEFEF",
      },
      label: {
        show: false,
      },
    },
  ]

  let rate3 = arryFenM == 0 ? 0 : Number((arryFenZ2 / arryFenM2) * 100)
  let other3 = Number(100 - rate3)
  let rate_percent3 = rate3.toFixed(1) + "%"
  let other_percent3 = other3.toFixed(1) + "%"
  let ratedata3 = [
    {
      value: rate3,
      name: rate_percent3,
      label: {
        position: "center",
        fontSize: 18,
        // color: "#31C463",
      },
      // itemStyle: {
      //   color: "#31C463",
      // },
    },
    {
      value: other3,
      name: other_percent3,
      itemStyle: {
        color: "#EFEFEF",
      },
      label: {
        show: false,
      },
    },
  ]

  var option63 = {
    tooltip: {
      trigger: "item",
      show: false,
      showContent: true,
    },
    // legend: {
    //   top: "5%",
    //   left: "center",
    //   itemStyle: {
    //     tooltip: true,
    //   },
    // },
    series: [
      {
        // name: "Access From",
        type: "pie",
        radius: ["55%", "70%"],
        avoidLabelOverlap: false,
        label: {
          show: true,
          // position: "center",
        },
        itemStyle: {
          color: "#3D9DF4",
        },
        emphasis: {
          label: {
            show: true,
            fontSize: "40",
            fontWeight: "bold",
          },
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
        labelLine: {
          show: false,
        },
        data: ratedata1,
      },
    ],
  }
  myChart63.setOption(option63)

  var option64 = {
    tooltip: {
      trigger: "item",
      show: false,
      showContent: true,
    },
    // legend: {
    //   top: "5%",
    //   left: "center",
    //   itemStyle: {
    //     tooltip: true,
    //   },
    // },
    series: [
      {
        // name: "Access From",
        type: "pie",
        radius: ["55%", "70%"],
        avoidLabelOverlap: false,
        label: {
          show: true,
          // position: "center",
        },
        itemStyle: {
          color: "#3D9DF4",
        },
        emphasis: {
          label: {
            show: true,
            fontSize: "40",
            fontWeight: "bold",
          },
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
        labelLine: {
          show: false,
        },
        data: ratedata2,
      },
    ],
  }
  myChart64.setOption(option64)

  var option65 = {
    tooltip: {
      trigger: "item",
      show: false,
      showContent: true,
    },
    // legend: {
    //   top: "5%",
    //   left: "center",
    //   itemStyle: {
    //     tooltip: true,
    //   },
    // },
    series: [
      {
        // name: "Access From",
        type: "pie",
        radius: ["55%", "70%"],
        avoidLabelOverlap: false,
        label: {
          show: true,
          // position: "center",
        },
        itemStyle: {
          color: "#3D9DF4",
        },
        emphasis: {
          label: {
            show: true,
            fontSize: "40",
            fontWeight: "bold",
          },
          itemStyle: {
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
          },
        },
        labelLine: {
          show: false,
        },
        data: ratedata3,
      },
    ],
  }
  myChart65.setOption(option65)
})
