欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Highchart实现条状图bar 2

程序员文章站 2022-06-09 23:30:09
...

特点:文字与条状并列排,颜色渐变
Highchart实现条状图bar 2

chart_UnitMatters: function(docm) {
      // let myColors = ["#06a786", "#0480c6", "#0375e8"];
      let myColors = [{
        radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
        stops: [[0, 'rgb(81, 254, 208)'], [1, 'rgb(81, 196, 253)']]
      }];
      Highcharts.chart(docm, {
        chart: {
          type: 'bar',
          backgroundColor: null,
          spacing: [30, 10, 10, 20]
        },
        colors: myColors,
        title: {
          text: ''
        },
        tooltip: {
          pointFormat: '{series.name}: <b>{point.y}</b><br/>'
        },
        xAxis: {
          reversed: true,
          gridLineWidth: 0,
          lineWidth: 0,
          categories: this.UnitMatters.listX,
          labels: {
            style: {
              color: "#fff",
              fontSize: 14
            },
            align: 'left',
            x: 0,
            y: -18,
            autoRotation: false
          }
        },
        yAxis: [{
          title: {
            text: ''
          },
          lineWidth: 0,
          gridLineWidth: 0,
          labels: {
            style: {
              color: "#fff",
              fontSize: 14
            }
          },
          visible: false,
          max: 700000
        }],
        plotOptions: {
          bar: {
            showInLegend: false,
            dataLabels: {
              allowOverlap: true,
              enabled: true,
              // distance: -70,
              style: {
                textOutline: "0px 0px contrast",
                color: "#01e6ec",
                fontSize: 12
              },
              format: '{y}'
            }
          },
          series: {
            colorByPoint: true,
            borderWidth: 0,
            pointWidth: 12
            // borderRadius: 4
          }
        },
        series: [{
          name: '单位事项数',
          colorByPoint: true,
          data: this.UnitMatters.listY
        }]
      });
    },
相关标签: Highcharts