highcharts在vue中的应用
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中的应用的更多相关文章
- vue中如何不通过路由直接获取url中的参数
前言:为什么要不通过路由直接获取url中的参数? vue中使用路由的方式设置url参数,但是这种方式必须要在路径中附带参数,而且这个参数是需要在vue的路由中提前设置好的. 相对来说,在某些情况下直接 ...
- vue中的重要特性
一.vue中的自定义组件 html的代码: <!DOCTYPE html> <html lang="en"> <head> <meta c ...
- Vue中comoputed中的数据绑定
Vue中的数据实现响应式绑定是在初始化的时候利用definePrototype的定义set和get过滤器,在进行组件模板编译时实现water的监听搜集依赖项,当数据发生变化时在set中通过调用dep. ...
- vue中使用stompjs实现mqtt消息推送通知
最近在研究vue+webAPI进行前后端分离,在一些如前端定时循环请求后台接口判断状态等应用场景用使用mqtt进行主动的消息推送能够很大程度的减小服务端接口的压力,提高系统的效率,而且可以利用mqtt ...
- Vue中应用CORS实现AJAX跨域,及它在 form data 和 request payload 的小坑处理
基本概念部分(一):理解CORS 说道Vue的跨域AJAX,我想先梳理一遍CORS跨域,"跨域资源共享"(Cross-origin resource sharing),它是一个W3 ...
- vue中watched属性
watched属性,vue中的观察属性,可用来监听一个值的变化 默认有两个参数,新值,旧值 data (){ return { currentCity: "深圳" } } watc ...
- 七、vue中v-for有时候对页面不会重新渲染,数组变化后如何到渲染页面
v-for不能进行双向数据绑定,页面渲染完成后,再次更改v-for遍历的数据,js里面打印的数据看到数据值已经更改,但是页面的数据就是没有渲染,这是为什么呢? vue中v-for和angularj ...
- 【Vue】Vue中的父子组件通讯以及使用sync同步父子组件数据
前言: 之前写过一篇文章<在不同场景下Vue组件间的数据交流>,但现在来看,其中关于“父子组件通信”的介绍仍有诸多缺漏或者不当之处, 正好这几天学习了关于用sync修饰符做父子组件数据双向 ...
- vue中数据双向绑定的实现原理
vue中最常见的属v-model这个数据双向绑定了,很好奇它是如何实现的呢?尝试着用原生的JS去实现一下. 首先大致学习了解下Object.defineProperty()这个东东吧! * Objec ...
- Vue中之nextTick函数源码分析
Vue中之nextTick函数源码分析 1. 什么是Vue.nextTick()?官方文档解释如下:在下次DOM更新循环结束之后执行的延迟回调.在修改数据之后立即使用这个方法,获取更新后的DOM. 2 ...
随机推荐
- Vue3 动态子页面和菜单栏同步
动态子页面 <router-view></router-view>显示子页面的内容 main.vue <template> <a-layout id=&quo ...
- A4纸尺寸
A4纸尺寸 A4纸尺寸:210×297: A3纸尺寸:297×420: A2纸尺寸:420×594: A1纸尺寸:594×841: A0纸尺寸:841×1189: 备注:长(mm)×宽(mm) 单位: ...
- Identity – Introduction & Scaffold
主要参考: Introduction to Identity on ASP.NET Core Start by command dotnet new webapp --auth Individual ...
- [Tkey] 生日礼物
题意简述 彩珠有 \(n\) 个 \(k\) 种,每个珠子都有一个坐标 \(p_{i}\),求最小的区间长度,使得这个区间包含全部的 \(k\) 种彩珠. 分析 发现我们可以维护每一种颜色的最近出现坐 ...
- Java实现随机抽奖的方法有哪些
在Java中实现随机抽奖的方法,通常我们会使用java.util.Random类来生成随机数,然后基于这些随机数来选择中奖者.以下将给出几种常见的随机抽奖实现方式,包括从数组中抽取.从列表中抽取以及基 ...
- linux内核调试痛点之函数参数抓捕记
1.linux内核调试工具crash并不能直接显示函数参数,而这个对调试又非常重要 下面是工作中一个实际的问题,我们的进程hang在如下一个内核栈中了,通过栈回溯可知是打开了一个nfs3的网盘文件或者 ...
- Failed to connect to github.com port 443: Connection refused问题解决
解决办法: 1.找到github的ip地址:查找链接 2.找到本地的hosts文件.我的hosts文件路劲为:C:\Windows\System32\drivers\etc 3.在hosts文件最后添 ...
- 本地图片上传服务器返回在线地址接口 - file - input -修改头像-带预览功能- 然后使用cropperjs 进行裁剪
说明:上传的图片是 file 类型 ,核心就是获取图片文件(file类型的) : 实现一:使用 vant2 的图片加载组件 ,选择文件后会触发afterRead方法 ,参数 file 就是文件列表fi ...
- 1.flask 源码解析:简介
目录 一.flask 源码解析:简介 1.1 flask 简介 1.2 两个依赖 1.2.1 werkzeug 1.2.2 Jinja2 1.3 如何读代码 Flask 源码分析完整教程目录:http ...
- 「模拟赛」CSP-S 模拟 11(T2 超详细)
比赛链接 A.玩水 (water) 签到.发现如果要找两条路径的话,能找到的充要条件是存在一个点的上方和左方的字母相同.(即使两条走过的点截然不同的路径也符合,这时终点会成为这个点). 即存在一个位置 ...