Home > front end >  Echarts pie chart data don't show to 0, the data is not zero when displayed in the sector
Echarts pie chart data don't show to 0, the data is not zero when displayed in the sector

Time:11-20

Watched some methods from the Internet, by writing a function, iterate through all the data, the data will be 0 hidden away, I want to on this basis, make data not show 0 projects within the sector, rather than through the broken line is displayed in the sector, I wrote about the position: 'inside', but doesn't work, the complete code is as follows, ask ace to give directions,


<script type="text/javascript">
//based on dom, prepared to initialize echarts instance
Var myChart=echarts. Init (document. GetElementById (' sxpd1 '));

Var option={
Tooltip: {
The trigger: 'item',
The formatter: "{a} & lt; br/> {b}, {c} ({d} %)
"},
Title: {
Text: 'a certain site users access to source',
Subtext: 'fabrication',
X: 'center'
},
Legend: {
Received: 'vertical',
Show: false,
Left: 'left',
//this article for tips, note the name and the name in the data corresponding
Data: [' video advertising ', 'advertising', 'email marketing, direct access, "search engine", "hackers"]
},

Series: [
{
Name: 'access to source,
Type: 'pie',
The radius: '55%',

Data: [
//remember to add itemStyle property using this method, or you'll find show an error attribute
{value: 335, name: 'direct access to the' itemStyle: {
Normal: {
Label: {
Show: true,
Position: 'inside',
The formatter: '{b}, {c} \ n ({d} %)',
},
LabelLine: {
Show: true
}
}
}},
{value: 310, name: email marketing, itemStyle: {
Normal: {
Label: {
Show: true,
Position: 'inside',
The formatter: '{b}, {c} \ n ({d} %)',
},
LabelLine: {
Show: true
}
}
}},
{value: 234, name: 'union advertising, itemStyle: {
Normal: {
Label: {
Show: true,
Position: 'inside',
The formatter: '{b}, {c} \ n ({d} %)',
},
LabelLine: {
Show: true
}
}
}},
{value: 135, name: 'video ads, itemStyle: {
Normal: {
Label: {
Show: true,
Position: 'inside',
The formatter: '{b}, {c} \ n ({d} %)',
},
LabelLine: {
Show: true
}
}
}},
{value: 1548, name: 'search engines' itemStyle: {
Normal: {
Label: {
Show: true,
Position: 'inside',
The formatter: '{b}, {c} \ n ({d} %)',
},
LabelLine: {
Show: true
}
}
}},
{value: 0, name: 'hackers' itemStyle: {
Normal: {
Label: {
Show: true,
Position: 'inside',
The formatter: '{b}, {c} \ n ({d} %)',
},
LabelLine: {
Show: true
}
}
}}
]
}
]
}

Var opt=option. The series [0];
LineHide (opt);
//data is zero hidden line
The function lineHide (opt) {
JQuery. Each (opt) data, the function (I, item) {
If (item. Value=0) https://bbs.csdn.net/topics/={
Item. ItemStyle. Normal. LabelLine. Show=false;
Item. ItemStyle. Normal. Label. The show=false;
}
});
}

//use the specified configuration items and data display chart,
myChart.setOption(option);

</script>

CodePudding user response:

Why the data will be hidden is not only the hidden text lines

CodePudding user response:

Judgment only less than 10 hidden text and lines not hidden data how bosses
  • Related