Reputation: 5
I have two arrays of data: [35, 15, 30] and [green, red, blue] assigned to single variables "freqs" and "colors". One for the values in the pie chart and one for the names. The two variables are being passed into the page.
This situation is no problem with echarts bar and line charts because both x and y axes have a "data" component, but for pie charts I can't find any examples of how to display the names.
Most pie chart examples look something like:
series: [
{
name: 'Color Frequencies',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: [
{value: 335, name: '直接访问'},
{value: 310, name: '邮件营销'},
{value: 234, name: '联盟广告'},
{value: 135, name: '视频广告'},
{value: 1548, name: '搜索引擎'}
],
}
]
If I try:
series: [
{
name: 'Color Frequencies',
type: 'pie',
radius: '55%',
center: ['50%', '60%'],
data: freqs
}
]
the data displays fine, but without any category labels. I have tried data: [freqs, colors]
, or some variant, it doesn't seem to work.
Upvotes: 0
Views: 1226
Reputation:
The Pie need data likes:
...
data: [
{value:35, name:'green'},
{value:15, name:'red'},
{value:30, name:'blue'},
],
...
Upvotes: 0