Skip to content

Commit

Permalink
refactor: Creates the VizType enum (#31193)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-s-molina authored Nov 29, 2024
1 parent dbcb473 commit 93ba8e1
Show file tree
Hide file tree
Showing 138 changed files with 766 additions and 555 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { boxplotOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
time_grain_sqla: 'P1Y',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { contributionOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { flattenOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { histogramOperator } from '@superset-ui/chart-controls';
import { SqlaFormData } from '@superset-ui/core';
import { SqlaFormData, VizType } from '@superset-ui/core';
import { omit } from 'lodash';

const formData: SqlaFormData = {
Expand All @@ -26,7 +26,7 @@ const formData: SqlaFormData = {
cumulative: true,
normalize: true,
groupby: ['country', 'region'],
viz_type: 'histogram',
viz_type: VizType.LegacyHistogram,
datasource: 'foo',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { pivotOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
show_empty_columns: true,
};
const queryObject: QueryObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { DTTM_ALIAS, QueryObject, SqlaFormData } from '@superset-ui/core';
import {
DTTM_ALIAS,
QueryObject,
SqlaFormData,
VizType,
} from '@superset-ui/core';
import { prophetOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +32,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
time_grain_sqla: 'P1Y',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { rankOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -26,7 +26,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
truncate_metric: true,
};
const queryObject: QueryObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ComparisonType, QueryObject, SqlaFormData } from '@superset-ui/core';
import {
ComparisonType,
QueryObject,
SqlaFormData,
VizType,
} from '@superset-ui/core';
import { renameOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -26,7 +31,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
truncate_metric: true,
};
const queryObject: QueryObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { resampleOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { rollingWindowOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { sortOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import { timeCompareOperator } from '@superset-ui/chart-controls';

const formData: SqlaFormData = {
Expand All @@ -27,7 +27,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const queryObject: QueryObject = {
metrics: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryObject, SqlaFormData } from '@superset-ui/core';
import { QueryObject, SqlaFormData, VizType } from '@superset-ui/core';
import {
timeCompareOperator,
timeComparePivotOperator,
Expand All @@ -30,7 +30,7 @@ const formData: SqlaFormData = {
time_range: '2015 : 2016',
granularity: 'month',
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
show_empty_columns: true,
};
const queryObject: QueryObject = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryFormData, QueryFormMetric } from '@superset-ui/core';
import { QueryFormData, QueryFormMetric, VizType } from '@superset-ui/core';
import { extractExtraMetrics } from '@superset-ui/chart-controls';

const baseFormData: QueryFormData = {
datasource: 'dummy',
viz_type: 'table',
viz_type: VizType.Table,
metrics: ['a', 'b'],
columns: ['foo', 'bar'],
limit: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
* under the License.
*/
import { isDerivedSeries } from '@superset-ui/chart-controls';
import { SqlaFormData, ComparisonType } from '@superset-ui/core';
import { SqlaFormData, ComparisonType, VizType } from '@superset-ui/core';

const formData: SqlaFormData = {
datasource: 'foo',
viz_type: 'table',
viz_type: VizType.Table,
};
const series = {
id: 'metric__1 month ago',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { VizType } from '@superset-ui/core';
import { displayTimeRelatedControls } from '../../src';

const mockData = {
Expand All @@ -35,7 +36,7 @@ const mockData = {
exportState: {},
form_data: {
datasource: '22__table',
viz_type: 'table',
viz_type: VizType.Table,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { QueryFormData } from '@superset-ui/core';
import { QueryFormData, VizType } from '@superset-ui/core';
import { getStandardizedControls } from '../../src';

const formData: QueryFormData = {
datasource: '30__table',
viz_type: 'table',
viz_type: VizType.Table,
standardizedFormData: {
controls: {
metrics: ['count(*)', 'sum(sales)'],
Expand All @@ -34,7 +34,7 @@ const formData: QueryFormData = {
test('without standardizedFormData', () => {
getStandardizedControls().setStandardizedControls({
datasource: '30__table',
viz_type: 'table',
viz_type: VizType.Table,
});
expect(getStandardizedControls().controls).toEqual({
metrics: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export { default as ChartDataProvider } from './components/ChartDataProvider';
export * from './types/Base';
export * from './types/TransformFunction';
export * from './types/QueryResponse';
export * from './types/VizType';

export { default as __hack_reexport_chart_Base } from './types/Base';
export { default as __hack_reexport_chart_TransformFunction } from './types/TransformFunction';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
export enum VizType {
Area = 'echarts_area',
Bar = 'echarts_timeseries_bar',
BigNumber = 'big_number',
BigNumberTotal = 'big_number_total',
BigNumberPeriodOverPeriod = 'pop_kpi',
BoxPlot = 'box_plot',
Bubble = 'bubble_v2',
Bullet = 'bullet',
Calendar = 'cal_heatmap',
Chord = 'chord',
Compare = 'compare',
CountryMap = 'country_map',
DistBar = 'dist_bar',
EventFlow = 'event_flow',
Funnel = 'funnel',
Gauge = 'gauge_chart',
Graph = 'graph_chart',
Handlebars = 'handlebars',
Heatmap = 'heatmap_v2',
Histogram = 'histogram_v2',
Horizon = 'horizon',
LegacyArea = 'area',
LegacyBar = 'bar',
LegacyBubble = 'bubble',
LegacyHeatmap = 'heatmap',
LegacyHistogram = 'histogram',
LegacyLine = 'line',
LegacySankey = 'sankey',
Line = 'echarts_timeseries_line',
MapBox = 'mapbox',
MixedTimeseries = 'mixed_timeseries',
PairedTTest = 'paired_ttest',
ParallelCoordinates = 'para',
Partition = 'partition',
Pie = 'pie',
PivotTable = 'pivot_table_v2',
Radar = 'radar',
Rose = 'rose',
Sankey = 'sankey_v2',
Scatter = 'echarts_timeseries_scatter',
SmoothLine = 'echarts_timeseries_smooth',
Step = 'echarts_timeseries_step',
Sunburst = 'sunburst_v2',
Table = 'table',
TimePivot = 'time_pivot',
TimeTable = 'time_table',
Timeseries = 'echarts_timeseries',
Tree = 'tree_chart',
Treemap = 'treemap_v2',
Waterfall = 'waterfall',
WordCloud = 'word_cloud',
WorldMap = 'world_map',
}
Loading

0 comments on commit 93ba8e1

Please sign in to comment.