Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit }
import { GraphConfig } from '@zeppelin/sdk';
import { TableData, Visualization } from '@zeppelin/visualization';

import { AGGREGATION_TYPES, AggregationType } from '../util/aggregation-type';

@Component({
selector: 'zeppelin-visualization-pivot-setting',
templateUrl: './pivot-setting.component.html',
Expand All @@ -28,7 +30,7 @@ export class VisualizationPivotSettingComponent implements OnInit {

config!: GraphConfig;
columns: Array<{ name: string; index: number; aggr: string }> = [];
aggregates = ['sum', 'count', 'avg', 'min', 'max'];
aggregates: readonly AggregationType[] = AGGREGATION_TYPES;

// eslint-disable-next-line
drop(event: CdkDragDrop<any[]>) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Single source of truth for the aggregation-type set shared by the table
// visualization and the pivot setting UI. The order is canonical and drives the
// pivot aggregation dropdown display order.
export const AGGREGATION_TYPES = ['sum', 'count', 'avg', 'min', 'max'] as const;

export type AggregationType = (typeof AGGREGATION_TYPES)[number];
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ import { utils, writeFile, WorkSheet } from 'xlsx';

import { TableData, Visualization, VISUALIZATION } from '@zeppelin/visualization';

import { AGGREGATION_TYPES, AggregationType } from '../common/util/aggregation-type';

type ColType = 'string' | 'date' | 'number';
type AggregationType = 'count' | 'sum' | 'min' | 'max' | 'avg';

class FilterOption {
sort: 'desc' | 'asc' | '' = '';
Expand Down Expand Up @@ -59,7 +60,7 @@ export class TableVisualizationComponent implements OnInit {
columns: string[] = [];
colOptions = new Map<string, FilterOption>();
types: ColType[] = ['string', 'number', 'date'];
aggregations: AggregationType[] = ['count', 'sum', 'min', 'max', 'avg'];
aggregations: readonly AggregationType[] = AGGREGATION_TYPES;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@ViewChild(NzTableComponent, { static: false }) nzTable!: NzTableComponent<any>;

Expand Down
Loading