首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在条形图顶部设置值- echarts

在条形图顶部设置值- echarts
EN

Stack Overflow用户
提问于 2018-03-28 20:44:56
回答 1查看 1.9K关注 0票数 2

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

我想要的结果是:

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

组件:-

代码语言:javascript
复制
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
    }
  ]
}
}
}

模板:-

代码语言:javascript
复制
<div echarts [options]="barChartData" style="height: 199px; width: 825px; margin-left: 1%; margin-top: -65px"></div>
EN

回答 1

Stack Overflow用户

发布于 2019-01-19 05:33:22

可以在bar系列上配置标签,请参阅documentation

将以下内容添加到条形图系列中,将在其顶部显示条形图的值:

代码语言:javascript
复制
label: {
    normal: {
        show: true,
        position: 'top'
      }
  }

如果你想显示一些单独的值,你可以配置一个formatter

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49534931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档