1. Download Dependency
2. Code Implementation<template> <div ref="container" /> </template> <script> import DataSet from '@antv/data-set' import { Chart } from '@antv/g2' export default { // Create a radar chart mounted() { this.constradar() }, methods: { constradar() { const data = [ { item: 'Work efficiency', a: 70, b: 30 }, { item: 'Attendance', a: 60, b: 70 }, { item: 'Positiveness', a: 50, b: 60 }, { item: 'Helping a colleague', a: 40, b: 50 }, { item: 'Self-directed learning', a: 60, b: 70 }, { item: 'Accuracy', a: 70, b: 50 } ] const { DataView } = DataSet const dv = new DataView().source(data) dv.transform({ type: 'fold', fields: ['a', 'b'], // Expand field set key: 'user', // key field value: 'score' // value field }) 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() //Modify data const newData = [ { item: 'Work efficiency', a: 20, b: 30 }, { item: 'Attendance', a: 30, b: 70 }, { item: 'Positiveness', a: 10, b: 60 }, { item: 'Helping a colleague', a: 40, b: 50 }, { item: 'Self-directed learning', a: 60, b: 70 }, { item: 'Accuracy', a: 20, b: 50 } ] // Update immediately setTimeout(() => { // Start processing data const dv = new DataView().source(newData) dv.transform({ type: 'fold', fields: ['a', 'b'], // Expand field set key: 'user', // key field value: 'score' // value field }) // Processing is finished // Use the processed data to update the icon chart.changeData(dv.rows) }, 3000) } } } </script> <style></style> 3. Achievement EffectBefore data modification After data modification This is the end of this article about vue+antv implementing radar chart. For more related vue radar chart content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Summary of Button's four Click response methods
>>: Example code for implementing a text marquee with CSS3
Illustrated CentOS 7.3 installation steps for you...
Table of contents Background 1. What is dns-prefe...
1. Create a project with vue ui 2. Select basic c...
1. JS asynchronous execution principle We know th...
Background: Make a little progress every day, acc...
Utilize the browser's non- overflow:auto elem...
This article shares the specific code of native j...
Key Points The CSS resize property allows you to ...
mysql dirty pages Due to the WAL mechanism, when ...
Notes on installing MySQL database, share with ev...
1. Check whether the existing nginx supports ipv6...
Table of contents 1. Introduction 2. Environmenta...
Important note: Before studying this article, you...
1. The difference between Http and Https HTTP: It...
Record the problems you solve for others. Problem...