1、安装命令

npm  install highcharts  --save

2、在页面中按需引入

import Highcharts from 'highcharts/highstock';
import HighchartsMore from 'highcharts/highcharts-more';
import HighchartsDrilldown from 'highcharts/modules/drilldown';
import Highcharts3D from 'highcharts/highcharts-3d';
HighchartsMore(Highcharts);
HighchartsDrilldown(Highcharts);
Highcharts3D(Highcharts);

3、初始化图表

mounted() {
var that = this;
that.$el.style.height = that.$refs.chart_gauge.offsetHeight - that.torem(100) + 'px';
console.log(this.$refs.chart_gauge.offsetHeight, 'qq');
switch (that.title) {
case 'cpu':
that.text1 = 'AP平均cpu利用率';
that.text2 = 'AC平均cpu利用率';
break;
case '内存':
that.text1 = 'AP平均内存利用率';
that.text2 = 'AC平均内存利用率';
break;
}
this.options = {
chart: {
type: 'gauge',
backgroundColor: 'transparent'
// height: that.torem(500)
},
title: {
text: null
},
labels: {
items: [{
style: {
left: that.torem(180),
top: that.torem(280),
fontSize: that.torem(42),
fontWeight: 'bold',
fontFamily: '微软雅黑'
}
// html: '<span style="color:#C02316">{y}</span>'
}]
},
pane: [{
startAngle: -100,
endAngle: 100,
background: null,
center: ['25%', '65%'],
size: '80%'
}, {
startAngle: -100,
endAngle: 100,
background: null,
center: ['75%', '65%'],
size: '80%'
}],
yAxis: [{
min: 0,
max: 100,
minorTickInterval: 'auto',
minorTickWidth: that.torem(2),
minorTickLength: that.torem(20),
minorTickPosition: 'inside',
minorTickColor: '#00bfd3',
tickPixelInterval: 30,
tickWidth: that.torem(4),
tickPosition: 'inside',
tickLength: that.torem(26),
tickColor: '#48c7ff',
tickInterval: 10,
// 间隔
// tickmarkPlacement: 'on',
// labels: {
// // step: 20,
// rotation: 'auto',
// minRange: 10,
// padding: 200
// },
lineColor: 'transparent',
labels: {
style: {
color: '#48c7ff',
fontSize: that.torem(28),
html: ` < span > < /span>`
/ / step: 20
},
distance: that.offetY
},
// plotBands: [
// {
// from: 0,
// to: 6,
// color: '#C02316',
// innerRadius: '100%',
// outerRadius: '105%'
// }
// ],
pane: 0,
title: {
text: this.text1,
verticalAlign: 'bottom',
style: {
color: '#fff',
fontSize: that.torem(28)
},
y: that.torem(220)
}
}, {
min: 0,
max: 100,
minorTickInterval: 'auto',
minorTickWidth: that.torem(2),
minorTickLength: that.torem(20),
minorTickPosition: 'inside',
minorTickColor: '#00bfd3',
tickPixelInterval: 30,
tickWidth: that.torem(4),
tickPosition: 'inside',
tickLength: that.torem(26),
tickColor: '#48c7ff',
tickInterval: 10,
// 间隔
tickmarkPlacement: 'on',
lineColor: 'transparent',
labels: {
style: {
color: '#48c7ff',
fontSize: that.torem(28)
},
distance: that.offetY
},
// plotBands: [
// {
// from: 0,
// to: 6,
// color: '#C02316',
// innerRadius: '100%',
// outerRadius: '102%'
// }
// ],
pane: 1,
title: {
text: this.text2,
verticalAlign: 'bottom',
style: {
color: '#fff',
fontSize: that.torem(28)
},
y: that.torem(220)
}
}],
plotOptions: {
gauge: {
dataLabels: {
borderWidth: 0,
enabled: true,
color: '#48c7ff',
fontSize: that.torem(80),
// format: `<span style="color:({y} > 20 ? '#48c7ff' : {y} > 80 ? '#ff6748' : '#13c792');font-size:${that.torem(80)}px">{y}%</span>`,
format: ` < span > {
y
} % < /span>`
/ / formatter() {
// console.log('<span style="color:red">' + this.point.y + '%</span>')
// // '<span style="color:'+(this.point.y > 20 ? '#48c7ff' : this.point.y > 80 ? '#ff6748' : '#13c792')+'">' + this.point.y + '%</span>'
// '<span style="color:red">' + this.point.y + '%</span>'
// }
},
dial: {
radius: '80%',
// 半径:指针长度
backgroundColor: '#1b4b77',
//指针背景色
borderColor: 'black',
borderWidth: that.torem(1),
baseWidth: that.torem(10),
topWidth: that.torem(1),
baseLength: '90%',
// of radius
rearLength: '15%' //尾巴长度
},
borderWidth: 0
}
},
series: [{
data: [80],
yAxis: 0
}, {
data: [70],
yAxis: 1
}]
};
this.initChart();
},
methods: {
initChart(options) {
this.chart1 = new Highcharts.Chart(this.$refs.chart_gauge, this.options);
var title_AP_cpu = {
text: 'AP平均cpu利用率'
};
var title_AC_cpu = {
text: 'AC平均cpu利用率'
};
var title_AP_RAM = {
text: 'AP平均内存利用率'
};
var title_AC_RAM = {
text: 'AC平均内存利用率'
};
}
}

highcharts在vue中的应用的更多相关文章

  1. vue中如何不通过路由直接获取url中的参数

    前言:为什么要不通过路由直接获取url中的参数? vue中使用路由的方式设置url参数,但是这种方式必须要在路径中附带参数,而且这个参数是需要在vue的路由中提前设置好的. 相对来说,在某些情况下直接 ...

  2. vue中的重要特性

    一.vue中的自定义组件 html的代码: <!DOCTYPE html> <html lang="en"> <head> <meta c ...

  3. Vue中comoputed中的数据绑定

    Vue中的数据实现响应式绑定是在初始化的时候利用definePrototype的定义set和get过滤器,在进行组件模板编译时实现water的监听搜集依赖项,当数据发生变化时在set中通过调用dep. ...

  4. vue中使用stompjs实现mqtt消息推送通知

    最近在研究vue+webAPI进行前后端分离,在一些如前端定时循环请求后台接口判断状态等应用场景用使用mqtt进行主动的消息推送能够很大程度的减小服务端接口的压力,提高系统的效率,而且可以利用mqtt ...

  5. Vue中应用CORS实现AJAX跨域,及它在 form data 和 request payload 的小坑处理

    基本概念部分(一):理解CORS 说道Vue的跨域AJAX,我想先梳理一遍CORS跨域,"跨域资源共享"(Cross-origin resource sharing),它是一个W3 ...

  6. vue中watched属性

    watched属性,vue中的观察属性,可用来监听一个值的变化 默认有两个参数,新值,旧值 data (){ return { currentCity: "深圳" } } watc ...

  7. 七、vue中v-for有时候对页面不会重新渲染,数组变化后如何到渲染页面

      v-for不能进行双向数据绑定,页面渲染完成后,再次更改v-for遍历的数据,js里面打印的数据看到数据值已经更改,但是页面的数据就是没有渲染,这是为什么呢? vue中v-for和angularj ...

  8. 【Vue】Vue中的父子组件通讯以及使用sync同步父子组件数据

    前言: 之前写过一篇文章<在不同场景下Vue组件间的数据交流>,但现在来看,其中关于“父子组件通信”的介绍仍有诸多缺漏或者不当之处, 正好这几天学习了关于用sync修饰符做父子组件数据双向 ...

  9. vue中数据双向绑定的实现原理

    vue中最常见的属v-model这个数据双向绑定了,很好奇它是如何实现的呢?尝试着用原生的JS去实现一下. 首先大致学习了解下Object.defineProperty()这个东东吧! * Objec ...

  10. Vue中之nextTick函数源码分析

    Vue中之nextTick函数源码分析 1. 什么是Vue.nextTick()?官方文档解释如下:在下次DOM更新循环结束之后执行的延迟回调.在修改数据之后立即使用这个方法,获取更新后的DOM. 2 ...

随机推荐

  1. 【YashanDB数据库】大事务回滚导致其他操作无法执行,报错YAS-02016 no free undo blocks

    问题现象 客户将一个100G的表的数据插入到另一个表中,使用insert into select插入数据.从第一天下午2点开始执行,到第二天上午10点,一直未执行完毕. 由于需要实施下一步操作,客户k ...

  2. axios使用备忘录

    安装使用 使用npm安装: $ npm install axios 使用CDN: <script src="https://unpkg.com/axios/dist/axios.min ...

  3. Vue3——环境变量的配置

    vue3环境变量的配置 开发环境(development) 测试环境(testing) 生产环境(production) 项目根目录分别添加 开发.生产和测试环境的文件! .env.developme ...

  4. 一篇文章讲清楚synchronized关键字的作用及原理

    概述 在应用Sychronized关键字时需要把握如下注意点: 一把锁只能同时被一个线程获取,没有获得锁的线程只能等待: 每个实例都对应有自己的一把锁(this),不同实例之间互不影响:例外:锁对象是 ...

  5. PyTorch 的 Autograd

    看了一篇博客,感觉写的很棒:PyTorch 的 Autograd

  6. 三步搞定 ARM64 离线部署 Kubernetess + KubeSphere

    背景 随着我国对信息安全的愈发重视,国产化的趋势也越来越浓,包括国产操作系统.国产 CPU 等.由于 ARM 架构国产 CPU 在维持创新可信和先进性方面的潜在优势,其应用也将会越来越广泛. Kube ...

  7. 认识JVM

    类加载器 运行时数据区 执行引擎 执行引擎的任务就是将字节码指令解释/编译为对应平台上的本地机器指令 JVM架构图

  8. Web渗透07_脚本代码注入和OS命令注入( 恐怖级别 )

    1 PHP代码注入 1.1 原理成因 网站对用户的输入过滤出现问题,同时网站的脚本编写用到一些危险函数 eval(),assert().如果被攻击者发现漏洞,直接可能造成攻击者完全控制整个web甚至是 ...

  9. idea项目提交到码云

    第一步:创建一个项目 第二步:在码云上新建一个项目.[注意把使用Readme复选框取消掉] 第三步:复制gitee地址 第四步:创建本地git仓库 第五步:选择自己需要上传到码云的项目名 第六步:提交 ...

  10. LeetCode题目练习记录 _数组和链表01 _20211007

    LeetCode题目练习记录 _数组和链表01 _20211007 26. 删除有序数组中的重复项 难度简单2247 给你一个有序数组 nums ,请你原地 删除重复出现的元素,使每个元素 只出现一次 ...