$(function () {
  // 优秀生、学困生统计
  function initClassExcellenceEcharts() {
    var legend_data = ["优秀生", "学困生"];
    var xAxis_data = ["全部班级", "九年级一班", "九年级二班"];
    var series_data1 = [10, 6, 4];
    var series_data2 = [-11, -11, -11];
    var option = {
      title: {
        text: "人",
        x: "left",
        y: "top",
        textStyle: {
          color: "#5F6E82",
          fontSize: 12,
          fontWeight: 500
        }
      },
      color: ["#5C99FF", "#F39A2C"],
      legend: {
        itemWidth: 6,
        itemHeight: 6,
        bottom: 30,
        data: legend_data
      },
      grid: {
        top: 30,
        left: 5,
        right: 0,
        bottom: 65,
        containLabel: true
      },
      xAxis: [
        {
          type: "category",
          offset: 10,
          position: "bottom",
          data: xAxis_data,
          axisLabel: {
            color: "#5F6E82" //更改坐标轴文字颜色
          },
          axisTick: {
            alignWithLabel: true
          },
          boundaryGap: true,
          triggerEvent: true,
          axisLine: {
            show: true, //是否显示轴线
            lineStyle: {
              color: "#DADADA" //刻度线的颜色
            }
          }
        }
      ],
      yAxis: [
        {
          type: "value",
          axisTick: {
            show: false //刻度
          },
          axisLine: {
            show: false, //是否显示轴线
            lineStyle: {
              color: "#DADADA" //刻度线的颜色
            }
          },
          splitLine: {
            //网格线
            lineStyle: {
              type: "dotted" //设置网格线类型 dotted：虚线   solid:实线
            },
            show: true //隐藏或显示
          },
          axisLabel: {
            color: "#5F6E82" //更改坐标轴文字颜色
          }
        }
      ],
      series: [
        {
          name: legend_data[0],
          type: "bar",
          stack: "one",
          barWidth: 32,
          // 柱状图最小高度
          barMinHeight: 0,
          barGap: 0,
          label: {
            normal: {
              show: true,
              align: "center",
              verticalAlign: "bottom",
              position: "top",
              distance: 0
            }
          },
          data: series_data1
        },
        {
          name: legend_data[1],
          type: "bar",
          stack: "one",
          barWidth: 32,
          // 柱状图最小高度
          barMinHeight: 0,
          barGap: 0,
          label: {
            normal: {
              show: true,
              align: "center",
              verticalAlign: "top",
              position: "bottom",
              distance: 0,
              formatter: function (params) {
                return Math.abs(params.value);
              }
            }
          },
          data: series_data2
        }
      ]
    };
    var myEcharts = echarts.init(document.querySelector(".section_2_excellent_all #classExcellenceEcharts"));
    myEcharts.clear();
    myEcharts.setOption(option);
  }
  var parameter = $(".section_2_html_root .section_2_excellent_all_html_root").data("page-params");
  parameter = JSON.parse(parameter);
  // console.log(".section_2_excellent_all_html_root:parameter", parameter);
  initClassExcellenceEcharts();
});