简体   繁体   中英

With ng2-google-charts how do I format the number as a percentage?

With ng2-google-charts and angular 10 how do I format the number as a percentage?

I'm using 'GeoChart' as the chart type.

The chart interface is

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

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

A pattern fixed it

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM