Reactjs 我可以在数据透视表中为表值应用自定义格式吗?
我可以在Reactjs 我可以在数据透视表中为表值应用自定义格式吗?,reactjs,vue.js,pivottable.js,Reactjs,Vue.js,Pivottable.js,我可以在react pivottable中为表值应用自定义格式吗 例如,我必须得到count值的总和,它以两位小数出现。但是,我想自定义这些小数位 <template> <div id="app"> <vue-custom-scrollbar class="scroll-area" :settings="settings"> <vue-pivottable height
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>
从“vue数据透视表”导入{VuePivottable}
导入“vue数据透视表/dist/vue数据透视表.css”
从“vue自定义滚动条”导入vueCustomScrollbar
导出默认值{
组成部分:{
VuePivottable,
vueCustomScrollbar
},
数据:函数(){
返回{
aggregatorName:'Sum',
RenderName:'表',
行:[“国家”、“性别”],
科尔斯:[“年”],
VAL:[“计数”]
}
}
},
计算:{
数据透视:函数(){
常量数据透视=[
{“国家”:“美国”,“年份”:2010,“性别”:“男性”,“计数”:parseInt('153295220'),
{“国家”:“美国”,“年份”:2010,“性别”:“女性”,“计数”:parseInt('156588400'),
{“国家”:“法国”,“年份”:2012,“性别”:“女性”,“计数”:parseInt('32612882')}
]
返回数据透视图;
}
}
}
以下是输出的图像:
如果您只想使用小数,可以使用此聚合器:
aggregatorName="Integer Sum"