vue加载highcharts柱状图

89 篇文章 1 订阅
84 篇文章 1 订阅
<div id="chart" class="chart"></div>
data() {
    return {
        chart: null,
    } 
},
mounted() {
    this.buildChart()
}
buildLineChart(id) {
      this.contentList.chart = Highcharts.chart(id, {
        chart: {
          type: "column", //柱状图
          backgroundColor: "rgba(2, 16, 67, 0)",  //图表底色
          style: {
            color: "#fff"
          }
        },
        title: {
          text: "当前海域24小时气温变化趋势",  //标题
          style: { //标题样式
            color: '#F0F7FF',
            fontSize: 14
          },
        },
        xAxis: { //x轴
          categories:["晴", "雨", "雪", "雾"],
          labels: { //X轴字体颜色
            style: {
              color: "#F0F7FF",
              fontSize: "14px",
              fontWeight: "400"
            }
          },
          // 设置X轴基线颜色
          lineColor:'rgba(240,247,255,0.6)',
          // categories: []
        },
        yAxis: { Ytitle: {
            text: "℃",
            align: 'high',
            offset: -25,
            rotation: 0,
            y: -18,
            style: {
              width:"20px",
              color: "rgba(240,252,255,0.4)",
              fontSize: "14px",
              fontWeight: "400"
            },
          },
          labels: {
            style: {
              color: "#F0F7FF",
              fontSize: "14px",
              fontWeight: "400",
              
            },
            // align:'left',
            x:13, //改变y轴位置
            y:5
          },
          lineColor:'red',
          // 设置网格线虚线等样式
          gridLineDashStyle: "dash",
          gridLineWidth: 1,
          gridLineColor: "rgba(240,252,255,0.6)"
        },
        // 提示框
        tooltip: {
          // formatter:function() {
          //   return this.y;
          
          // },
          formatter: function() {
            var tooltip = ''
            tooltip += '<div style="width: 54px;height: 15px;line-height: 15px;background: rgba(0, 187, 255, 0.1);color: #FFFFFF;text-align: center;position: relative">'
            tooltip += '<span>' 
            tooltip += this.y
            tooltip += '</span>'
            tooltip += '<img src="/left.png" style="position: absolute;left: 0px;top: 0px;" />'
            tooltip += '<img src="/right.png" style="position: absolute;right: 0px;top: 0px;" />'
            tooltip += '</div>'
            return tooltip
          },
          useHTML: true,
          backgroundColor: null,
          borderWidth: 0,
          // borderWidth:33,
          // borderHeight:44,
          // borderRadius: 0,
          // paddingLeft:30,
          // backgroundColor:'rgb(0,187,255,0.2)',
          // borderColor: 'rgb(0,187,255,0.2)',
          shadow:false,
          style: {
            color:'#FFFFFF',
            fontSize: '14PX',
          },
          // 鼠标停留后的垂直白线
          crosshairs:[{
            width:3,
            color:'rgba(255,255,255,0.2)',
          }],
        },
        // 图例
        legend: {
          enabled: false,
        },
        plotOptions: {
          column: {
            borderWidth: 0,
            pointWidth: 40,
          },
          areaspline: {},
          // 设置区域的透明度 fillOpacity: num 最大为1
          series: {
            fillOpacity: 0.3,
            // pointPlacement: 'on',   设置x轴左对齐
          },
         
        },
        series: [
          {
            data:[20,7,0,4],
            color: "rgba(0,187,255,0.3)",
            fillColor: {
              linearGradient: {
                x1: 0,
                y1: 0,
                x2: 0,
                y2: 1
              },
              stops: [
                [0, "rgba(0, 187, 255, 0.6)"],
                [1, "rgba(0, 187, 255, 0)"]
              ]
            },
            label: {
              connectorAllowed: false
            },
            marker: {
              enabled:false,
              radius: 3,
              // symbol:'circle',
              // symbol:'url(https://ts1.cn.mm.bing.net/th/id/R-C.3ee8e0c3ef5deebc97978557b8e26a7b?rik=ZuOtsvk0gOu4kQ&riu=http%3a%2f%2fwww.psahz.com%2fuploads%2fallimg%2f130214%2f20301SS1-0-lp.jpg&ehk=GXnA%2fWbnSvpDVS6FPnzds7hY5Wt1WWAbE20CJ2CKY%2fM%3d&risl=&pid=ImgRaw&r=0)',
              lineColor:"#00BBFF",
              fillColor:'#00BBFF',
              
            },
            
          }
        ],
        credits: {
          enabled: false
        }
      })
    },
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值