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 ...
随机推荐
- Java 1.8 Stream流原理与用法总结
一.接口设计 从Java1.8开始提出了Stream流的概念,侧重对于源数据计算能力的封装,并且支持序列与并行两种操作方式:依旧先看核心接口的设计: BaseStream:基础接口,声明了流管理的核心 ...
- (零) React Native 项目开发拾遗
一位离职的前端同事,最近接了个 React Native 的活儿,遇到许多搞不定的问题,于是找到我帮忙"补课"(没有系统的学习 React Native,也不具备原生 Androi ...
- C++源码中司空见惯的PIMPL是什么?
前言: C++源码中司空见惯的PIMPL是什么?用原始指针.std::unique_ptr和std::shared_ptr指向Implementation,会有什么不同?优缺点是什么?读完这篇文章,相 ...
- LLM应用实战: 文档问答系统Kotaemon-1. 简介及部署实践
1.背景 本qiang~这两周关注到一个很火的开源文档问答系统Kotaemon,从8月28日至今短短两周时间,github星标迅猛增长10K,因此计划深挖一下其中的原理及奥秘. 本篇主要是Kotaem ...
- QT硬件异构计算
QT硬件异构计算 使用AI技术辅助生成 1 QT硬件异构计算概述 1.1 硬件异构计算概念 1.1.1 硬件异构计算概念 硬件异构计算概念 <QT硬件异构计算>正文 硬件异构计算概念 在进 ...
- 最好的文件管理器-dolphin
WARN:windows没有,废话少说,直接开始 what's dolphin 长得好看 dolphin使用kde的主题管理,可以通过kde的主题商店配合kvantum manager 配制出一个好看 ...
- 【赵渝强老师】MongoDB中的索引(下)
(四)索引的类型三:复合索引(Compound Index) MongoDB支持复合索引,即将多个键组合到一起创建索引.该方式称为复合索引,或者也叫组合索引,该方式能够满足多键值匹配查询使用索引的情形 ...
- GPT分区和MRB分区
GPT分区和MBR分区都是硬盘分区的方式,但它们有不同的实现方法和优缺点. MBR(Master Boot Record)分区是传统的分区方式,它将硬盘分为四个主分区或者三个主分区和一个扩展分区.在每 ...
- icache的dcache区别
iCache是指指令缓存,DCache是指数据缓存.iCache是专门用于存储指令的高速缓存,DCache是用于存储数据的高速缓存.iCache用于存储指令,在CPU执行时将指令从iCache中读取, ...
- 利用 ACME 实现SSL证书自动化配置更新
最近收到腾讯云的通知SSL证书要到期了,本想直接申请的发现现在申请的免费SSL证书有效期只有90天了,顺便了解了一下原因是包括Google在内的国际顶级科技公司一直都有在推进免费证书90天有效期的建议 ...