This article mainly introduces the pie chart data part of Vue using echart to display percentages, and shares it with everyone. The details are as follows: Rendering Implementation source code option = { title : { text: 'Source of user access to a certain site', subtext: 'Purely fictitious', x:'center' }, tooltip : { trigger: 'item', formatter: "{a} <br/>{b} : {c} ({d}%)" }, legend: { orient: 'vertical', // Layout mode, the default is horizontal layout, optional: 'horizontal' ¦ 'vertical' // Horizontal placement, default is on the left, options are: 'center' | 'left' | 'right' | {number} (x coordinate, unit px) x: 'left', // Vertical placement, default is the top of the whole image, options are: 'top' | 'bottom' | 'center' | {number} (y coordinate, unit px) y: 'bottom', // Rewrite the legend display style formatter: function(name) { // Get the legend display content let data = option.series[0].data; let total = 0; let tarValue = 0; for (let i = 0, l = data.length; i < l; i++) { total += data[i].value; if (data[i].name == name) { tarValue = data[i].value; } } let p = (tarValue / total * 100).toFixed(2); return name + ' ' + ' ' + p + '%'; }, data: ['Direct access', 'Email marketing', 'Affiliate advertising', 'Video advertising', 'Search engine'] }, series: [ { name: 'Access source', type: 'pie', radius : '55%', center: ['50%', '60%'], data:[ {value:335, name:'Direct access'}, {value:310, name:'Email Marketing'}, {value:234, name:'Alliance Advertising'}, {value:135, name:'Video Ad'}, {value:1548, name:'search engine'} ], itemStyle: { emphasis: shadowBlur: 10, shadowOffsetX: 0, shadowColor: 'rgba(0, 0, 0, 0.5)' } } } ] }; This is the end of this article about how to use Vue to implement echart pie chart legend to display percentages. For more information about Vue pie chart display percentages, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: A brief understanding of MySQL storage field type query efficiency
>>: Detailed explanation of Docker data backup and recovery process
1. VMware download and install Link: https://www....
question: Recently, garbled data appeared when de...
1. View openjdk rpm -qa|grep jdk 2. Delete openjd...
Cause of the problem: At first, the default yum s...
Table of contents View all storage engines InnoDB...
Effect (source code at the end): accomplish: 1. D...
Table of contents Preface Child components pass d...
<br />Semanticization cannot be explained in...
Table of contents background CommonsChunkPlugin s...
Background: Linux server file upload and download...
First: <abbr> or <acronym> These two s...
Overview This article will introduce the MVC arch...
background Use idea with docker to realize the wh...
location / { index index.jsp; proxy_next_upstream...
When I was working on a project recently, I found...