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
Tutorial Series MySQL series: Basic concepts of M...
Docker Quickly Install Zookeeper I haven't us...
1. Basic Specifications (1) InnoDB storage engine...
Just pass in custom parameters HTML <div id=&q...
During the daily optimization process, I found a ...
This article shares the specific code for JavaScr...
Table of contents 1. Use the "rpm -ivh insta...
1. Complex SQL queries 1.1. Single table query (1...
1. Build the basic image of jmeter The Dockerfile...
Preface In the process of managing and maintainin...
Table of contents 1. Introduction: 2. Prototype c...
Notice! ! ! This situation can actually be avoide...
Project Background Recently, there is a project w...
Definition of Float Sets the element out of the n...
Previously, I summarized how to use CSS to achieve...