如何在电子图表/ ngx-echarts库中设置条形图顶部的值?如果存在相同的属性,请告诉我,我找不到任何属性?
我想要的结果是:

到目前为止,我能够实现的结果是:

组件:-
import {Component, Input, OnInit} from '@angular/core';
declare var echarts: any;
@Component({
selector:'app-bar-chart',
templateUrl:'./bar-chart.component.html',
styleUrls:['./bar-chart.component.css'],
})
export class BarChartComponent implements OnInit{
public barChartData;
ngOnInit() {
let dataAxis = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K','L'];
let data = [200, 180, 190, 233, 219, 203, 110, 250, 160, 130, 120, 263];
this.barChartData ={
xAxis: {
data: dataAxis,
axisLabel: {
textStyle: {
color: 'black'
}
},
axisTick: {
show:true
},
axisLine: {
show: true
},
z: 10
},
yAxis: {
axisLine: {
show: true
},
axisTick: {
show: false
},
handle: {
show: true
},
axisLabel: {
show: true,
textStyle: {
color: 'black'
}
}
},
tooltip:{
trigger: 'axis',
showTip: false,
},
series: [
{ // For shadow
name: 'Total Revenue Cost',
type: 'bar',
value: true,
itemStyle: {
normal: { color: 'black' }
},
barGap: '-100%',
barCategoryGap: '12%',
animation: false
},
{
name: 'Total Revenue Cost',
type: 'bar',
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{ offset: 0, color: '#83bff6' },
{ offset: 0.5, color: '#188df0' },
{ offset: 1, color: '#188df0' }
]
)
},
emphasis: {
name: 'Total Revenue Cost',
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{ offset: 0, color: '#2378f7' },
{ offset: 0.7, color: '#2378f7' },
{ offset: 1, color: '#83bff6' }
]
)
}
},
data: data
}
]
}
}
}模板:-
<div echarts [options]="barChartData" style="height: 199px; width: 825px; margin-left: 1%; margin-top: -65px"></div>发布于 2019-01-19 05:33:22
可以在bar系列上配置标签,请参阅documentation。
将以下内容添加到条形图系列中,将在其顶部显示条形图的值:
label: {
normal: {
show: true,
position: 'top'
}
}如果你想显示一些单独的值,你可以配置一个formatter。
https://stackoverflow.com/questions/49534931
复制相似问题