Can I apply custom formatting in react-pivottable for table values?

800 views Asked by At

Can I apply custom formatting in react-pivottable for table values?

For example, I have to get the sum of the count values, which is appearing with two decimal places. However, I want to customize those decimal places.

<template>
  <div id="app">
    <vue-custom-scrollbar class="scroll-area"  :settings="settings">
      <vue-pivottable height="720" width="1280"
              :data="pivotData"
              :aggregator-name="aggregatorName"
              :renderer-name="rendererName"
              :rows="rows"
              :cols="cols"
              :vals="vals"
              :row-total="true"
              :col-total="true"
              :inclusions ="inclusions"
              :sorters ="this.sortOrder()"
              :formatSettings="formatSettings"
          >
      </vue-pivottable>
    </vue-custom-scrollbar>
  </div>
</template>

<script>
import { VuePivottable} from 'vue-pivottable'
import 'vue-pivottable/dist/vue-pivottable.css'
import vueCustomScrollbar from 'vue-custom-scrollbar'
export default {
    components: {
        VuePivottable,
        vueCustomScrollbar
    },
    data: function(){
      return{       
        aggregatorName: 'Sum',
        rendererName: 'Table',
        rows: ['country', 'gender'],
        cols: ['year'],
        vals: ['count']
        }
      }
    },     
    computed: {
      pivotData: function () {
        const pivotData = [        
          {"country": "United States", "year": 2010, "gender": "male", "count": parseInt('153295220')},
          {"country": "United States", "year": 2010, "gender": "female", "count": parseInt('156588400')},
          {"country": "France", "year": 2012, "gender": "female", "count": parseInt('32612882')}
        ]
       
        return pivotData;
      }
    }
}
</script>

Here is an image of the output: Output image

1

There are 1 answers

0
cralfaro On

If you just want get ride of decimals you could use this aggregator:

aggregatorName="Integer Sum"