我可以react-pivottable
为表格值应用自定义格式吗?
例如,我必须得到count
以两位小数显示的值的总和。但是,我想自定义这些小数位。
<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>