-
@@ -107,23 +102,35 @@ const moveFilterBoxToTop = (e) => {
const handleFilterTextClear = () => {
filterText.value = ''
}
-const matchesFilter = (x) => x.toLowerCase().trim().includes(filterText.value.toLowerCase().trim())
+const matchesFilter = (x) =>
+ x.toLowerCase().trim().includes(filterText.value.toLowerCase().trim())
const addValuesToFilter = (values) => {
- const filterValues = values.reduce((r, v) => {
- r[v] = true
- return r
- }, Object.assign({}, unselectedValues.value))
- emit('update:unselectedFilterValues', { key: props.filterBoxKey, value: filterValues })
+ const filterValues = values.reduce(
+ (r, v) => {
+ r[v] = true
+ return r
+ },
+ Object.assign({}, unselectedValues.value)
+ )
+ emit('update:unselectedFilterValues', {
+ key: props.filterBoxKey,
+ value: filterValues
+ })
}
const removeValuesFromFilter = (values) => {
- console.log(values)
- const filterValues = values.reduce((r, v) => {
- if (r[v]) {
- delete r[v]
- }
- return r
- }, Object.assign({}, unselectedValues.value))
- emit('update:unselectedFilterValues', { key: props.filterBoxKey, value: filterValues })
+ const filterValues = values.reduce(
+ (r, v) => {
+ if (r[v]) {
+ delete r[v]
+ }
+ return r
+ },
+ Object.assign({}, unselectedValues.value)
+ )
+ emit('update:unselectedFilterValues', {
+ key: props.filterBoxKey,
+ value: filterValues
+ })
}
const toggleValue = (value) => {
if (value in unselectedValues.value) {
@@ -134,13 +141,19 @@ const toggleValue = (value) => {
}
const selectOnly = (e, value) => {
e.stopPropagation()
- setValuesInFilter(props.filterBoxKey, filterBoxValuesList.filter(y => y !== value))
+ setValuesInFilter(
+ props.filterBoxKey,
+ filterBoxValuesList.filter((y) => y !== value)
+ )
}
const setValuesInFilter = (filterBoxKey, values) => {
const filterValues = values.reduce((r, v) => {
r[v] = true
return r
}, {})
- emit('update:unselectedFilterValues', { key: filterBoxKey, value: filterValues })
+ emit('update:unselectedFilterValues', {
+ key: filterBoxKey,
+ value: filterValues
+ })
}
diff --git a/src/components/pivottable-ui/VPivottableUi.vue b/src/components/pivottable-ui/VPivottableUi.vue
index 3b9dd0d..99da431 100644
--- a/src/components/pivottable-ui/VPivottableUi.vue
+++ b/src/components/pivottable-ui/VPivottableUi.vue
@@ -28,7 +28,10 @@
@update:draggedAttribute="onDraggedAttribute"
>
-
+
@@ -69,7 +72,10 @@
@update:draggedAttribute="onDraggedAttribute"
>
-
+
@@ -94,11 +100,17 @@
@update:draggedAttribute="onDraggedAttribute"
>
-
+
-
+
|
@@ -189,21 +201,21 @@ const rendererItems = computed(() =>
const aggregatorItems = computed(() => state.aggregators)
const rowAttrs = computed(() => {
return state.rows.filter(
- e =>
+ (e) =>
!state.hiddenAttributes.includes(e) &&
!state.hiddenFromDragDrop.includes(e)
)
})
const colAttrs = computed(() => {
return state.cols.filter(
- e =>
+ (e) =>
!state.hiddenAttributes.includes(e) &&
!state.hiddenFromDragDrop.includes(e)
)
})
const attributeNames = computed(() => {
return Object.keys(allFilters.value).filter(
- e =>
+ (e) =>
!state.hiddenAttributes.includes(e) &&
!state.hiddenFromAggregators.includes(e)
)
@@ -211,7 +223,7 @@ const attributeNames = computed(() => {
const unusedAttrs = computed(() => {
return attributeNames.value
.filter(
- e =>
+ (e) =>
!state.rows.includes(e) &&
!state.cols.includes(e) &&
!state.hiddenAttributes.includes(e) &&
diff --git a/src/components/pivottable/VPivottable.vue b/src/components/pivottable/VPivottable.vue
index f6e1357..68379e2 100644
--- a/src/components/pivottable/VPivottable.vue
+++ b/src/components/pivottable/VPivottable.vue
@@ -16,6 +16,7 @@ const props = defineProps({
default: () => TableRenderer
}
})
-const rendererComponent = computed(() => props.rendererItems[props.rendererName] || TableRenderer.Table)
-
+const rendererComponent = computed(
+ () => props.rendererItems[props.rendererName] || TableRenderer.Table
+)
diff --git a/src/components/pivottable/VPivottableBody.vue b/src/components/pivottable/VPivottableBody.vue
index e5d93bb..20245b2 100644
--- a/src/components/pivottable/VPivottableBody.vue
+++ b/src/components/pivottable/VPivottableBody.vue
@@ -46,12 +46,6 @@ defineProps({
}
})
-const {
- pivotData,
- rowKeys,
- colKeys,
- rowAttrs,
- colAttrs
-} = useProvidePivotData()
-
+const { pivotData, rowKeys, colKeys, rowAttrs, colAttrs } =
+ useProvidePivotData()
diff --git a/src/components/pivottable/VPivottableBodyRows.vue b/src/components/pivottable/VPivottableBodyRows.vue
index 2304174..c84fd9f 100644
--- a/src/components/pivottable/VPivottableBodyRows.vue
+++ b/src/components/pivottable/VPivottableBodyRows.vue
@@ -1,6 +1,12 @@
-
-
+
+
- {{ getAggregator(rowKey, colKey).format(getAggregator(rowKey, colKey).value()) }}
+ {{
+ getAggregator(rowKey, colKey).format(
+ getAggregator(rowKey, colKey).value()
+ )
+ }}
|
{{ getAggregator(rowKey, []).format(getAggregator(rowKey, []).value()) }}
|
@@ -31,7 +49,6 @@
diff --git a/src/components/pivottable/VPivottableBodyRowsTotalRow.vue b/src/components/pivottable/VPivottableBodyRowsTotalRow.vue
index 62ea8ec..7aceba0 100644
--- a/src/components/pivottable/VPivottableBodyRowsTotalRow.vue
+++ b/src/components/pivottable/VPivottableBodyRowsTotalRow.vue
@@ -11,14 +11,16 @@
:key="`total${i}`"
class="pvtTotal"
:style="getColTotalStyle(colKey)"
- @click="handleCellClick(getAggregator([], colKey).value(), [], colKey)"
+ @click="
+ handleCellClick(getAggregator([], colKey).value(), [], colKey)($event)
+ "
>
{{ getAggregator([], colKey).format(getAggregator([], colKey).value()) }}
{{ getAggregator([], []).format(grandTotalValue) }}
|
@@ -70,21 +72,21 @@ const handleCellClick = (value, rowValues, colValues) => {
if (props.tableOptions?.clickCallback) {
const filters = {}
- // Add column filters
colAttrs.value.forEach((attr, i) => {
if (colValues[i] !== undefined && colValues[i] !== null) {
filters[attr] = colValues[i]
}
})
- // Add row filters
rowAttrs.value.forEach((attr, i) => {
if (rowValues[i] !== undefined && rowValues[i] !== null) {
filters[attr] = rowValues[i]
}
})
- props.tableOptions.clickCallback(event, value, filters, pivotData.value)
+ return (event) =>
+ props.tableOptions.clickCallback(event, value, filters, pivotData.value)
}
+ return () => ({})
}
diff --git a/src/components/pivottable/VPivottableHeader.vue b/src/components/pivottable/VPivottableHeader.vue
index 5360757..e605d42 100644
--- a/src/components/pivottable/VPivottableHeader.vue
+++ b/src/components/pivottable/VPivottableHeader.vue
@@ -1,8 +1,15 @@
-
- |
+
+ |
{{ c }} |
diff --git a/src/components/pivottable/VPivottableHeaderColumns.vue b/src/components/pivottable/VPivottableHeaderColumns.vue
index 124aa1a..cde5525 100644
--- a/src/components/pivottable/VPivottableHeaderColumns.vue
+++ b/src/components/pivottable/VPivottableHeaderColumns.vue
@@ -1,5 +1,8 @@
-
+
h(TableRenderer, {
...defaultProps,
...props
@@ -14,7 +14,7 @@ export default {
}),
'Table Heatmap': defineComponent({
name: 'vue-table-heatmap',
- setup (props) {
+ setup(props) {
return () => h(TableRenderer, {
...defaultProps,
...props,
@@ -24,7 +24,7 @@ export default {
}),
'Table Col Heatmap': defineComponent({
name: 'vue-table-col-heatmap',
- setup (props) {
+ setup(props) {
return () => h(TableRenderer, {
...defaultProps,
...props,
@@ -34,7 +34,7 @@ export default {
}),
'Table Row Heatmap': defineComponent({
name: 'vue-table-row-heatmap',
- setup (props) {
+ setup(props) {
return () => h(TableRenderer, {
...defaultProps,
...props,
diff --git a/src/composables/useAggregators.js b/src/composables/useAggregators.js
deleted file mode 100644
index 8f3e4bc..0000000
--- a/src/composables/useAggregators.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// 집계 함수들을 Vue3 반응형으로 래핑
-import { ref, computed } from 'vue'
-import { aggregators, aggregatorTemplates } from '../helper/utilities.js'
-
-export function useAggregators (options) {
- // 집계 함수 선택 및 관리
-
- return {
- // 집계 함수와 관련 메서드
- }
-}
diff --git a/src/composables/useMaterializeInput.js b/src/composables/useMaterializeInput.js
index 114bab9..3f723f3 100644
--- a/src/composables/useMaterializeInput.js
+++ b/src/composables/useMaterializeInput.js
@@ -1,12 +1,12 @@
import { ref, watch } from 'vue'
import { PivotData } from '@/helper/utilities.js'
-export function useMaterializeInput (dataSource, options) {
+export function useMaterializeInput(dataSource, options) {
const rawData = ref(null)
const allFilters = ref({})
const materializedInput = ref([])
- function processData (data) {
+ function processData(data) {
if (!data || rawData.value === data) return
rawData.value = data
@@ -53,9 +53,12 @@ export function useMaterializeInput (dataSource, options) {
watch(() => dataSource.value, processData, { immediate: true })
- watch(() => options.derivedAttributes.value, () => {
- processData(dataSource.value)
- })
+ watch(
+ () => options.derivedAttributes.value,
+ () => {
+ processData(dataSource.value)
+ }
+ )
return {
rawData,
diff --git a/src/composables/usePivotUiState.js b/src/composables/usePivotUiState.js
index be0ba02..f48c80c 100644
--- a/src/composables/usePivotUiState.js
+++ b/src/composables/usePivotUiState.js
@@ -1,6 +1,6 @@
import { reactive } from 'vue'
-export function usePivotUiState () {
+export function usePivotUiState() {
const pivotUiState = reactive({
unusedOrder: [],
zIndices: {},
diff --git a/src/composables/usePropsState.js b/src/composables/usePropsState.js
index 78151d9..16a1381 100644
--- a/src/composables/usePropsState.js
+++ b/src/composables/usePropsState.js
@@ -1,6 +1,6 @@
import { reactive } from 'vue'
-export function usePropsState (initialProps) {
+export function usePropsState(initialProps) {
const state = reactive({
...initialProps
})
@@ -11,7 +11,7 @@ export function usePropsState (initialProps) {
}
}
- const updateMultiple = updates => {
+ const updateMultiple = (updates) => {
Object.entries(updates).forEach(([key, value]) => {
if (key in state) {
state[key] = value
@@ -25,7 +25,7 @@ export function usePropsState (initialProps) {
})
}
- const onUpdateRendererName = rendererName => {
+ const onUpdateRendererName = (rendererName) => {
updateState('rendererName', rendererName)
if (rendererName === 'Table Heatmap') {
updateState('heatmapMode', 'full')
@@ -38,16 +38,16 @@ export function usePropsState (initialProps) {
}
}
- const onUpdateAggregatorName = aggregatorName => {
+ const onUpdateAggregatorName = (aggregatorName) => {
updateState('aggregatorName', aggregatorName)
}
- const onUpdateRowOrder = rowOrder => {
+ const onUpdateRowOrder = (rowOrder) => {
updateState('rowOrder', rowOrder)
}
- const onUpdateColOrder = colOrder => {
+ const onUpdateColOrder = (colOrder) => {
updateState('colOrder', colOrder)
}
- const onUpdateVals = vals => {
+ const onUpdateVals = (vals) => {
updateState('vals', vals)
}
const onDraggedAttribute = ({ key, value }) => {
diff --git a/src/composables/useProvideFilterbox.js b/src/composables/useProvideFilterbox.js
index 7262f47..98401dc 100644
--- a/src/composables/useProvideFilterbox.js
+++ b/src/composables/useProvideFilterbox.js
@@ -2,7 +2,7 @@ import { inject, provide } from 'vue'
import { getSort } from '../helper/utilities'
const filterBoxKey = Symbol('filterBox')
-export function provideFilterBox (props) {
+export function provideFilterBox(props) {
const localeStrings = props.languagePack[props.locale].localeStrings
const sorter = (x) => getSort(props.sorters, x)
const menuLimit = props.menuLimit
@@ -14,6 +14,6 @@ export function provideFilterBox (props) {
})
}
-export function useProvideFilterBox () {
+export function useProvideFilterBox() {
return inject(filterBoxKey)
}
diff --git a/src/composables/useProvidePivotData.js b/src/composables/useProvidePivotData.js
index b4085f1..1484d22 100644
--- a/src/composables/useProvidePivotData.js
+++ b/src/composables/useProvidePivotData.js
@@ -3,7 +3,7 @@ import { PivotData } from '@/helper'
const PIVOT_DATA_KEY = Symbol('pivotData')
-export function providePivotData (props) {
+export function providePivotData(props) {
const error = ref(null)
const pivotData = computed(() => {
@@ -21,10 +21,11 @@ export function providePivotData (props) {
const colAttrs = computed(() => pivotData.value?.props.cols || [])
const rowAttrs = computed(() => pivotData.value?.props.rows || [])
const colorScaleGenerator = props.tableColorScaleGenerator
- const getAggregator = (rowKey, colKey) => pivotData.value?.getAggregator(rowKey, colKey) || {
- value: () => null,
- format: () => ''
- }
+ const getAggregator = (rowKey, colKey) =>
+ pivotData.value?.getAggregator(rowKey, colKey) || {
+ value: () => null,
+ format: () => ''
+ }
const grandTotalAggregator = computed(() => {
return pivotData.value
@@ -35,53 +36,49 @@ export function providePivotData (props) {
}
})
- const allValues = computed(() => {
- const values = []
- rowKeys.value.forEach(r =>
- colKeys.value.forEach(c =>
- values.push(getAggregator(r, c).value())
- )
- )
- return values
+ const allColorScales = computed(() => {
+ const values = rowKeys.value.reduce((acc, r) => {
+ return acc.concat(colKeys.value.map((c) => getAggregator(r, c).value()))
+ }, [])
+ return colorScaleGenerator(values)
})
+ const rowColorScales = computed(() =>
+ rowKeys.value.reduce((scales, r) => {
+ scales[r] = colorScaleGenerator(
+ colKeys.value.map((x) => getAggregator(r, x).value())
+ )
+ return scales
+ }, {})
+ )
+ const colColorScales = computed(() =>
+ colKeys.value.reduce((scales, c) => {
+ scales[c] = colorScaleGenerator(
+ rowKeys.value.map((x) => getAggregator(x, c).value())
+ )
+ return scales
+ }, {})
+ )
- // Colors for heatmap
const valueCellColors = (rowKey, colKey, value) => {
if (props.heatmapMode === 'full') {
- const colorScale = colorScaleGenerator(allValues.value)
- return colorScale(value)
+ return allColorScales.value(value)
} else if (props.heatmapMode === 'row') {
- const rowColorScales = rowKeys.value.reduce((scales, r) => {
- scales[r] = colorScaleGenerator(colKeys.value.map(x =>
- getAggregator(r, x).value()
- ))
- return scales
- }, {})
- return rowColorScales[rowKey](value)
+ return rowColorScales.value[rowKey](value)
} else if (props.heatmapMode === 'col') {
- const colColorScales = colKeys.value.reduce((scales, c) => {
- scales[c] = colorScaleGenerator(rowKeys.value.map(x =>
- getAggregator(x, c).value()
- ))
- return scales
- }, {})
- return colColorScales[colKey](value)
+ return colColorScales.value[colKey](value)
}
return {}
}
+ const rowTotalValues = colKeys.value.map((x) => getAggregator([], x).value())
const rowTotalColors = (value) => {
if (!props.heatmapMode) return {}
- const rowTotalValues = colKeys.value.map(x =>
- getAggregator([], x).value()
- )
+
return colorScaleGenerator(rowTotalValues)(value)
}
-
+ const colTotalValues = rowKeys.value.map((x) => getAggregator(x, []).value())
const colTotalColors = (value) => {
if (!props.heatmapMode) return {}
- const colTotalValues = rowKeys.value.map(x =>
- getAggregator(x, []).value()
- )
+
return colorScaleGenerator(colTotalValues)(value)
}
@@ -134,6 +131,6 @@ export function providePivotData (props) {
return pivotDataContext
}
-export function useProvidePivotData () {
+export function useProvidePivotData() {
return inject(PIVOT_DATA_KEY)
}
diff --git a/src/composables/useSorting.js b/src/composables/useSorting.js
deleted file mode 100644
index a6bc0d2..0000000
--- a/src/composables/useSorting.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// 정렬 관련 유틸리티를 Vue3 반응형으로 래핑
-import { ref, computed } from 'vue'
-import { naturalSort, getSort, sortAs } from '../helper/utilities.js'
-
-export function useSorting (options) {
- // 정렬 방향, 정렬 필드 등 관리
-
- return {
- // 노출할 상태와 메서드
- }
-}
diff --git a/src/composables/useTableRenderers.js b/src/composables/useTableRenderers.js
deleted file mode 100644
index e0eb881..0000000
--- a/src/composables/useTableRenderers.js
+++ /dev/null
@@ -1,19 +0,0 @@
-// composables/useTableRenderer.js
-import { ref, computed } from 'vue'
-import { redColorScaleGenerator } from '../helper/utilities.js'
-
-export function useTableRenderer (options) {
- // 기존 redColorScaleGenerator 및 관련 함수 래핑
-
- // 히트맵 로직
- const getColorScaleGenerator = (values) => {
- return options.tableColorScaleGenerator || redColorScaleGenerator(values)
- }
-
- // 기타 렌더러 관련 함수
-
- return {
- getColorScaleGenerator
- // 기타 필요한 함수 및 상태
- }
-}
diff --git a/src/composables/useValueFormatting.js b/src/composables/useValueFormatting.js
deleted file mode 100644
index 7d110cf..0000000
--- a/src/composables/useValueFormatting.js
+++ /dev/null
@@ -1,11 +0,0 @@
-// 값 포맷팅 기능을 Vue3 반응형으로 래핑
-import { ref, computed } from 'vue'
-import { numberFormat } from '../helper/utilities.js'
-
-export function useValueFormatting (options) {
- // 포맷팅 옵션 관리
-
- return {
- // 포맷팅 함수와 옵션
- }
-}
diff --git a/src/helper/defaultProps.js b/src/helper/defaultProps.js
index e5786c7..ef23453 100644
--- a/src/helper/defaultProps.js
+++ b/src/helper/defaultProps.js
@@ -77,16 +77,18 @@ export default {
rowOrder: {
type: String,
default: 'key_a_to_z',
- validator: (value) => ['key_a_to_z', 'value_a_to_z', 'value_z_to_a'].indexOf(value) !== -1
+ validator: (value) =>
+ ['key_a_to_z', 'value_a_to_z', 'value_z_to_a'].indexOf(value) !== -1
},
colOrder: {
type: String,
default: 'key_a_to_z',
- validator: value => ['key_a_to_z', 'value_a_to_z', 'value_z_to_a'].indexOf(value) !== -1
+ validator: (value) =>
+ ['key_a_to_z', 'value_a_to_z', 'value_z_to_a'].indexOf(value) !== -1
},
tableMaxWidth: {
type: Number,
default: 0,
- validator: value => value >= 0
+ validator: (value) => value >= 0
}
}
diff --git a/src/helper/redColorScaleGenerator.js b/src/helper/redColorScaleGenerator.js
index 4f62db2..3cfb87a 100644
--- a/src/helper/redColorScaleGenerator.js
+++ b/src/helper/redColorScaleGenerator.js
@@ -1,8 +1,8 @@
-export function redColorScaleGenerator (values) {
+export function redColorScaleGenerator(values) {
const min = Math.min.apply(Math, values)
const max = Math.max.apply(Math, values)
- return x => {
- const nonRed = 255 - Math.round(255 * (x - min) / (max - min))
+ return (x) => {
+ const nonRed = 255 - Math.round((255 * (x - min)) / (max - min))
return { backgroundColor: `rgb(255,${nonRed},${nonRed})` }
}
}
diff --git a/src/helper/utilities.js b/src/helper/utilities.js
index 4314b6a..261bcbd 100644
--- a/src/helper/utilities.js
+++ b/src/helper/utilities.js
@@ -100,7 +100,7 @@ const naturalSort = (as, bs) => {
if (a1 !== b1) {
if (rd.test(a1) && rd.test(b1)) {
const numDiff = a1.replace(rz, '.0') - b1.replace(rz, '.0')
- return (numDiff !== 0) ? numDiff : a1.length - b1.length
+ return numDiff !== 0 ? numDiff : a1.length - b1.length
}
return a1 > b1 ? 1 : -1
}
@@ -161,15 +161,15 @@ const usFmtPct = numberFormat({
})
const aggregatorTemplates = {
- count (formatter = usFmtInt) {
+ count(formatter = usFmtInt) {
return () =>
function () {
return {
count: 0,
- push () {
+ push() {
this.count++
},
- value () {
+ value() {
return this.count
},
format: formatter
@@ -177,17 +177,17 @@ const aggregatorTemplates = {
}
},
- uniques (fn, formatter = usFmtInt) {
+ uniques(fn, formatter = usFmtInt) {
return function ([attr]) {
return function () {
return {
uniq: [],
- push (record) {
+ push(record) {
if (!Array.from(this.uniq).includes(record[attr])) {
this.uniq.push(record[attr])
}
},
- value () {
+ value() {
return fn(this.uniq)
},
format: formatter,
@@ -197,17 +197,17 @@ const aggregatorTemplates = {
}
},
- sum (formatter = usFmt) {
+ sum(formatter = usFmt) {
return function ([attr]) {
return function () {
return {
sum: 0,
- push (record) {
+ push(record) {
if (!isNaN(parseFloat(record[attr]))) {
this.sum += parseFloat(record[attr])
}
},
- value () {
+ value() {
return this.sum
},
format: formatter,
@@ -217,7 +217,7 @@ const aggregatorTemplates = {
}
},
- extremes (mode, formatter = usFmt) {
+ extremes(mode, formatter = usFmt) {
return function ([attr]) {
return function (data) {
return {
@@ -226,7 +226,7 @@ const aggregatorTemplates = {
typeof data !== 'undefined' ? data.sorters : null,
attr
),
- push (record) {
+ push(record) {
let x = record[attr]
if (['min', 'max'].includes(mode)) {
x = parseFloat(x)
@@ -235,20 +235,22 @@ const aggregatorTemplates = {
}
}
if (
- mode === 'first' && this.sorter(x, this.val !== null ? this.val : x) <= 0
+ mode === 'first' &&
+ this.sorter(x, this.val !== null ? this.val : x) <= 0
) {
this.val = x
}
if (
- mode === 'last' && this.sorter(x, this.val !== null ? this.val : x) >= 0
+ mode === 'last' &&
+ this.sorter(x, this.val !== null ? this.val : x) >= 0
) {
this.val = x
}
},
- value () {
+ value() {
return this.val
},
- format (x) {
+ format(x) {
if (isNaN(x)) {
return x
}
@@ -260,18 +262,18 @@ const aggregatorTemplates = {
}
},
- quantile (q, formatter = usFmt) {
+ quantile(q, formatter = usFmt) {
return function ([attr]) {
return function () {
return {
vals: [],
- push (record) {
+ push(record) {
const x = parseFloat(record[attr])
if (!isNaN(x)) {
this.vals.push(x)
}
},
- value () {
+ value() {
if (this.vals.length === 0) {
return null
}
@@ -286,14 +288,14 @@ const aggregatorTemplates = {
}
},
- runningStat (mode = 'mean', ddof = 1, formatter = usFmt) {
+ runningStat(mode = 'mean', ddof = 1, formatter = usFmt) {
return function ([attr]) {
return function () {
return {
n: 0.0,
m: 0.0,
s: 0.0,
- push (record) {
+ push(record) {
const x = parseFloat(record[attr])
if (isNaN(x)) {
return
@@ -306,7 +308,7 @@ const aggregatorTemplates = {
this.s = this.s + (x - this.m) * (x - mNew)
this.m = mNew
},
- value () {
+ value() {
if (mode === 'mean') {
if (this.n === 0) {
return 0 / 0
@@ -332,13 +334,13 @@ const aggregatorTemplates = {
}
},
- sumOverSum (formatter = usFmt) {
+ sumOverSum(formatter = usFmt) {
return function ([num, denom]) {
return function () {
return {
sumNum: 0,
sumDenom: 0,
- push (record) {
+ push(record) {
if (!isNaN(parseFloat(record[num]))) {
this.sumNum += parseFloat(record[num])
}
@@ -346,29 +348,35 @@ const aggregatorTemplates = {
this.sumDenom += parseFloat(record[denom])
}
},
- value () {
+ value() {
return this.sumNum / this.sumDenom
},
format: formatter,
- numInputs: typeof num !== 'undefined' && typeof denom !== 'undefined' ? 0 : 2
+ numInputs:
+ typeof num !== 'undefined' && typeof denom !== 'undefined' ? 0 : 2
}
}
}
},
- fractionOf (wrapped, type = 'total', formatter = usFmtPct) {
+ fractionOf(wrapped, type = 'total', formatter = usFmtPct) {
return (...x) =>
function (data, rowKey, colKey) {
return {
- selector: { total: [[], []], row: [rowKey, []], col: [[], colKey] }[type],
+ selector: { total: [[], []], row: [rowKey, []], col: [[], colKey] }[
+ type
+ ],
inner: wrapped(...Array.from(x || []))(data, rowKey, colKey),
- push (record) {
+ push(record) {
this.inner.push(record)
},
format: formatter,
- value () {
+ value() {
return (
- this.inner.value() / data.getAggregator(...Array.from(this.selector || [])).inner.value()
+ this.inner.value() /
+ data
+ .getAggregator(...Array.from(this.selector || []))
+ .inner.value()
)
},
numInputs: wrapped(...Array.from(x || []))().numInputs
@@ -377,32 +385,40 @@ const aggregatorTemplates = {
}
}
-aggregatorTemplates.countUnique = f => aggregatorTemplates.uniques(x => x.length, f)
-aggregatorTemplates.listUnique = s => aggregatorTemplates.uniques(x => x.join(s), x => x)
-aggregatorTemplates.max = f => aggregatorTemplates.extremes('max', f)
-aggregatorTemplates.min = f => aggregatorTemplates.extremes('min', f)
-aggregatorTemplates.first = f => aggregatorTemplates.extremes('first', f)
-aggregatorTemplates.last = f => aggregatorTemplates.extremes('last', f)
-aggregatorTemplates.median = f => aggregatorTemplates.quantile(0.5, f)
-aggregatorTemplates.average = f => aggregatorTemplates.runningStat('mean', 1, f)
-aggregatorTemplates.var = (ddof, f) => aggregatorTemplates.runningStat('var', ddof, f)
-aggregatorTemplates.stdev = (ddof, f) => aggregatorTemplates.runningStat('stdev', ddof, f)
+aggregatorTemplates.countUnique = (f) =>
+ aggregatorTemplates.uniques((x) => x.length, f)
+aggregatorTemplates.listUnique = (s) =>
+ aggregatorTemplates.uniques(
+ (x) => x.join(s),
+ (x) => x
+ )
+aggregatorTemplates.max = (f) => aggregatorTemplates.extremes('max', f)
+aggregatorTemplates.min = (f) => aggregatorTemplates.extremes('min', f)
+aggregatorTemplates.first = (f) => aggregatorTemplates.extremes('first', f)
+aggregatorTemplates.last = (f) => aggregatorTemplates.extremes('last', f)
+aggregatorTemplates.median = (f) => aggregatorTemplates.quantile(0.5, f)
+aggregatorTemplates.average = (f) =>
+ aggregatorTemplates.runningStat('mean', 1, f)
+aggregatorTemplates.var = (ddof, f) =>
+ aggregatorTemplates.runningStat('var', ddof, f)
+aggregatorTemplates.stdev = (ddof, f) =>
+ aggregatorTemplates.runningStat('stdev', ddof, f)
// default aggregators & renderers use US naming and number formatting
-const aggregators = (tpl => ({
- Count: tpl.count(usFmtInt),
+const aggregators = ((tpl) => ({
+ 'Count': tpl.count(usFmtInt),
'Count Unique Values': tpl.countUnique(usFmtInt),
'List Unique Values': tpl.listUnique(', '),
- Sum: tpl.sum(usFmt),
+ 'Sum': tpl.sum(usFmt),
'Integer Sum': tpl.sum(usFmtInt),
- Average: tpl.average(usFmt),
- Median: tpl.median(usFmt),
+ 'Average': tpl.average(usFmt),
+ 'Median': tpl.median(usFmt),
'Sample Variance': tpl.var(1, usFmt),
'Sample Standard Deviation': tpl.stdev(1, usFmt),
- Minimum: tpl.min(usFmt),
- Maximum: tpl.max(usFmt),
- First: tpl.first(usFmt),
- Last: tpl.last(usFmt),
+ 'Minimum': tpl.min(usFmt),
+ 'Maximum': tpl.max(usFmt),
+ 'First': tpl.first(usFmt),
+ 'Last': tpl.last(usFmt),
'Sum over Sum': tpl.sumOverSum(usFmt),
'Sum as Fraction of Total': tpl.fractionOf(tpl.sum(), 'total', usFmtPct),
'Sum as Fraction of Rows': tpl.fractionOf(tpl.sum(), 'row', usFmtPct),
@@ -414,27 +430,47 @@ const aggregators = (tpl => ({
// fr aggregators
-const frAggregators = (tpl => ({
- Compte: tpl.count(usFmtInt),
+const frAggregators = ((tpl) => ({
+ 'Compte': tpl.count(usFmtInt),
'Compter les valeurs uniques': tpl.countUnique(usFmtInt),
'Liste des valeurs uniques': tpl.listUnique(', '),
- Somme: tpl.sum(usFmt),
+ 'Somme': tpl.sum(usFmt),
'Somme de nombres entiers': tpl.sum(usFmtInt),
- Moyenne: tpl.average(usFmt),
- Médiane: tpl.median(usFmt),
+ 'Moyenne': tpl.average(usFmt),
+ 'Médiane': tpl.median(usFmt),
"Variance de l'échantillon": tpl.var(1, usFmt),
"Écart-type de l'échantillon": tpl.stdev(1, usFmt),
- Minimum: tpl.min(usFmt),
- Maximum: tpl.max(usFmt),
- Premier: tpl.first(usFmt),
- Dernier: tpl.last(usFmt),
+ 'Minimum': tpl.min(usFmt),
+ 'Maximum': tpl.max(usFmt),
+ 'Premier': tpl.first(usFmt),
+ 'Dernier': tpl.last(usFmt),
'Somme Total': tpl.sumOverSum(usFmt),
'Somme en fraction du total': tpl.fractionOf(tpl.sum(), 'total', usFmtPct),
- 'Somme en tant que fraction de lignes': tpl.fractionOf(tpl.sum(), 'row', usFmtPct),
- 'Somme en tant que fraction de colonnes': tpl.fractionOf(tpl.sum(), 'col', usFmtPct),
- 'Comptage en tant que fraction du total': tpl.fractionOf(tpl.count(), 'total', usFmtPct),
- 'Comptage en tant que fraction de lignes': tpl.fractionOf(tpl.count(), 'row', usFmtPct),
- 'Comptage en tant que fraction de colonnes': tpl.fractionOf(tpl.count(), 'col', usFmtPct)
+ 'Somme en tant que fraction de lignes': tpl.fractionOf(
+ tpl.sum(),
+ 'row',
+ usFmtPct
+ ),
+ 'Somme en tant que fraction de colonnes': tpl.fractionOf(
+ tpl.sum(),
+ 'col',
+ usFmtPct
+ ),
+ 'Comptage en tant que fraction du total': tpl.fractionOf(
+ tpl.count(),
+ 'total',
+ usFmtPct
+ ),
+ 'Comptage en tant que fraction de lignes': tpl.fractionOf(
+ tpl.count(),
+ 'row',
+ usFmtPct
+ ),
+ 'Comptage en tant que fraction de colonnes': tpl.fractionOf(
+ tpl.count(),
+ 'col',
+ usFmtPct
+ )
}))(aggregatorTemplates)
const locales = {
@@ -460,7 +496,8 @@ const locales = {
localeStrings: {
renderError: 'Une erreur est survenue en dessinant le tableau croisé.',
computeError: 'Une erreur est survenue en calculant le tableau croisé.',
- uiRenderError: "Une erreur est survenue en dessinant l'interface du tableau croisé dynamique.",
+ uiRenderError:
+ "Une erreur est survenue en dessinant l'interface du tableau croisé dynamique.",
selectAll: 'Sélectionner tout',
selectNone: 'Ne rien sélectionner',
tooMany: '(trop de valeurs à afficher)',
@@ -491,13 +528,13 @@ const mthNamesEn = [
'Dec'
]
const dayNamesEn = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
-const zeroPad = number => `0${number}`.substr(-2, 2)
+const zeroPad = (number) => `0${number}`.substr(-2, 2)
const derivers = {
- bin (col, binWidth) {
- return record => record[col] - record[col] % binWidth
+ bin(col, binWidth) {
+ return (record) => record[col] - (record[col] % binWidth)
},
- dateFormat (
+ dateFormat(
col,
formatString,
utcOutput = false,
@@ -543,7 +580,7 @@ Data Model class
*/
class PivotData {
- constructor (inputProps = {}) {
+ constructor(inputProps = {}) {
this.props = Object.assign({}, PivotData.defaultProps, inputProps)
this.aggregator = this.props.aggregators[this.props.aggregatorName](
this.props.vals
@@ -560,7 +597,7 @@ class PivotData {
PivotData.forEachRecord(
this.props.data,
this.props.derivedAttributes,
- record => {
+ (record) => {
if (this.filter(record)) {
this.filteredData.push(record)
this.processRecord(record)
@@ -569,11 +606,12 @@ class PivotData {
)
}
- filter (record) {
+ filter(record) {
const allSelector = '*'
for (const k in this.props.valueFilter) {
if (k !== allSelector) {
- const valueFilterItem = this.props.valueFilter && this.props.valueFilter[k]
+ const valueFilterItem =
+ this.props.valueFilter && this.props.valueFilter[k]
if (record[k] in valueFilterItem) {
const existingKey = valueFilterItem[record[k]]
if (existingKey === true) {
@@ -587,11 +625,11 @@ class PivotData {
return true
}
- forEachMatchingRecord (criteria, callback) {
+ forEachMatchingRecord(criteria, callback) {
return PivotData.forEachRecord(
this.props.data,
this.props.derivedAttributes,
- record => {
+ (record) => {
if (!this.filter(record)) {
return
}
@@ -606,7 +644,7 @@ class PivotData {
)
}
- arrSort (attrs) {
+ arrSort(attrs) {
let a
const sortersArr = (() => {
const result = []
@@ -627,7 +665,7 @@ class PivotData {
}
}
- sortKeys () {
+ sortKeys() {
if (!this.sorted) {
this.sorted = true
const v = (r, c) => this.getAggregator(r, c).value()
@@ -654,21 +692,21 @@ class PivotData {
}
}
- getFilteredData () {
+ getFilteredData() {
return this.filteredData
}
- getColKeys () {
+ getColKeys() {
this.sortKeys()
return this.colKeys
}
- getRowKeys () {
+ getRowKeys() {
this.sortKeys()
return this.rowKeys
}
- processRecord (record) {
+ processRecord(record) {
// this code is called in a tight loop
const colKey = []
const rowKey = []
@@ -714,7 +752,7 @@ class PivotData {
}
}
- getAggregator (rowKey, colKey) {
+ getAggregator(rowKey, colKey) {
let agg
const flatRowKey = rowKey.join(String.fromCharCode(0))
const flatColKey = colKey.join(String.fromCharCode(0))
@@ -729,10 +767,10 @@ class PivotData {
}
return (
agg || {
- value () {
+ value() {
return null
},
- format () {
+ format() {
return ''
}
}
diff --git a/src/index.js b/src/index.js
index 3ab941b..18c4d3a 100644
--- a/src/index.js
+++ b/src/index.js
@@ -39,7 +39,4 @@ const install = (app) => {
export default install
export * from './components/index'
-export {
- PivotUtilities,
- Renderer
-}
+export { PivotUtilities, Renderer }
diff --git a/src/tips.js b/src/tips.js
index 95f1d5b..d890f9c 100644
--- a/src/tips.js
+++ b/src/tips.js
@@ -1,5 +1,13 @@
export default [
- ['Total Bill', 'Tip', 'Payer Gender', 'Payer Smoker', 'Day of Week', 'Meal', 'Party Size'],
+ [
+ 'Total Bill',
+ 'Tip',
+ 'Payer Gender',
+ 'Payer Smoker',
+ 'Day of Week',
+ 'Meal',
+ 'Party Size'
+ ],
[16.99, 1.01, 'Female', 'Non-Smoker', 'Sunday', 'Dinner', 2],
[10.34, 1.66, 'Male', 'Non-Smoker', 'Sunday', 'Dinner', 3],
[21.01, 3.5, 'Male', 'Non-Smoker', 'Sunday', 'Dinner', 3],
diff --git a/vite.config.js b/vite.config.js
index 9965a0b..8551625 100644
--- a/vite.config.js
+++ b/vite.config.js
@@ -8,15 +8,6 @@ export default defineConfig({
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
- extensions: [
- '.mjs',
- '.js',
- '.json',
- '.jsx',
- '.ts',
- '.tsx',
- '.vue',
- '.mts'
- ]
+ extensions: ['.mjs', '.js', '.json', '.jsx', '.ts', '.tsx', '.vue', '.mts']
}
})
|