首页 > 解决方案 > 使用 ng2-google-charts 如何将数字格式化为百分比?

问题描述

使用 ng2-google-charts 和 angular 10 如何将数字格式化为百分比?

我使用“GeoChart”作为图表类型。

图表界面是

public geoChart: GoogleChartInterface = {
chartType: 'GeoChart',
dataTable: [
  ['Country', 'Issuance (2019)'],
  ['GB', 20]
],
formatters: [

  {
    columns: [1],
    type: 'NumberFormat',
    options: {
     suffix: '%'
    }
  }
],

标签: angularng2-google-chart

解决方案


一个模式固定它

public geoChart: GoogleChartInterface = {
chartType: 'GeoChart',
dataTable: [
  ['Country', 'Issuance (2019)'],
  ['GB', 20]
],
formatters: [
  {
    columns: [1],
    type: 'NumberFormat',
    options: {
      pattern: '#0',
     suffix: '%'
    }
  }
],

推荐阅读