vue+antv實(shí)現(xiàn)雷達(dá)圖的示例代碼
一、下載依賴
npm install @antv/data-set
npm install @antv/g2
二、代碼實(shí)現(xiàn)
<template>
<div ref="container" />
</template>
<script>
import DataSet from '@antv/data-set'
import { Chart } from '@antv/g2'
export default {
// 創(chuàng)建雷達(dá)圖
mounted() {
this.constradar()
},
methods: {
constradar() {
const data = [
{ item: '工作效率', a: 70, b: 30 },
{ item: '考勤', a: 60, b: 70 },
{ item: '積極性', a: 50, b: 60 },
{ item: '幫助同事', a: 40, b: 50 },
{ item: '自主學(xué)習(xí)', a: 60, b: 70 },
{ item: '正確率', a: 70, b: 50 }
]
const { DataView } = DataSet
const dv = new DataView().source(data)
dv.transform({
type: 'fold',
fields: ['a', 'b'], // 展開字段集
key: 'user', // key字段
value: 'score' // value字段
})
const chart = new Chart({
container: this.$refs.container,
autoFit: true,
height: 500
})
chart.data(dv.rows)
chart.scale('score', {
min: 0,
max: 80
})
chart.coordinate('polar', {
radius: 0.8
})
chart.tooltip({
shared: true,
showCrosshairs: true,
crosshairs: {
line: {
style: {
lineDash: [4, 4],
stroke: '#333'
}
}
}
})
chart.axis('item', {
line: null,
tickLine: null,
grid: {
line: {
style: {
lineDash: null
}
}
}
})
chart.axis('score', {
line: null,
tickLine: null,
grid: {
line: {
type: 'line',
style: {
lineDash: null
}
}
}
})
chart.line().position('item*score').color('user').size(2)
chart
.point()
.position('item*score')
.color('user')
.shape('circle')
.size(4)
.style({
stroke: '#fff',
lineWidth: 1,
fillOpacity: 1
})
chart.area().position('item*score').color('user')
chart.render()
//修改數(shù)據(jù)
const newData = [
{ item: '工作效率', a: 20, b: 30 },
{ item: '考勤', a: 30, b: 70 },
{ item: '積極性', a: 10, b: 60 },
{ item: '幫助同事', a: 40, b: 50 },
{ item: '自主學(xué)習(xí)', a: 60, b: 70 },
{ item: '正確率', a: 20, b: 50 }
]
// 立刻更新
setTimeout(() => {
// 處理數(shù)據(jù)開始
const dv = new DataView().source(newData)
dv.transform({
type: 'fold',
fields: ['a', 'b'], // 展開字段集
key: 'user', // key字段
value: 'score' // value字段
})
// 處理結(jié)束
// 正式使用處理之后的數(shù)據(jù)進(jìn)行圖標(biāo)更新
chart.changeData(dv.rows)
}, 3000)
}
}
}
</script>
<style></style>
三、實(shí)現(xiàn)效果
數(shù)據(jù)修改前
??
數(shù)據(jù)修改后
?
到此這篇關(guān)于vue+antv實(shí)現(xiàn)雷達(dá)圖的文章就介紹到這了,更多相關(guān)vue雷達(dá)圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Vue3 computed初始化獲取設(shè)置值實(shí)現(xiàn)示例
這篇文章主要為大家介紹了Vue3 computed初始化以及獲取值設(shè)置值實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-10-10
vue?Proxy數(shù)據(jù)代理進(jìn)行校驗(yàn)部分源碼實(shí)例解析
Proxy提供了強(qiáng)大的Javascript元編程,有許多功能,包括運(yùn)算符重載,對(duì)象模擬,簡潔而靈活的API創(chuàng)建,對(duì)象變化事件,甚至Vue 3背后的內(nèi)部響應(yīng)系統(tǒng)提供動(dòng)力,這篇文章主要給大家介紹了關(guān)于vue?Proxy數(shù)據(jù)代理進(jìn)行校驗(yàn)部分源碼解析的相關(guān)資料,需要的朋友可以參考下2022-01-01
vue-cli開發(fā)時(shí),關(guān)于ajax跨域的解決方法(推薦)
下面小編就為大家分享一篇vue-cli開發(fā)時(shí),關(guān)于ajax跨域的解決方法(推薦),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-02-02
Vue中使用Openlayer實(shí)現(xiàn)加載動(dòng)畫效果
這篇文章主要介紹了Vue+Openlayer加載動(dòng)畫效果的實(shí)現(xiàn)代碼,代碼簡單易懂,對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08
vue項(xiàng)目實(shí)現(xiàn)文件下載進(jìn)度條功能
這篇文章主要介紹了vue項(xiàng)目實(shí)現(xiàn)文件下載進(jìn)度條功能,本文通過具體實(shí)現(xiàn)代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2021-09-09
客戶端(vue框架)與服務(wù)器(koa框架)通信及服務(wù)器跨域配置詳解
本篇文章主要介紹了客戶端(vue框架)與服務(wù)器(koa框架)通信及服務(wù)器跨域配置詳解,具有一定的參考價(jià)值,有興趣的可以了解一下2017-08-08

