Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Commit

Permalink
Fix typing
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmud committed Jan 8, 2021
1 parent 77c9edc commit 4faffc4
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Registry, makeSingleton, OverwritePolicy } from '../..';
import { TransformProps } from '../types/TransformFunction';

class ChartTransformPropsRegistry extends Registry<TransformProps<never>> {
class ChartTransformPropsRegistry extends Registry<TransformProps<any>> {
constructor() {
super({ name: 'ChartTransformProps', overwritePolicy: OverwritePolicy.WARN });
}
Expand Down
4 changes: 4 additions & 0 deletions packages/superset-ui-core/src/chart/types/QueryResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ export interface DataRecordFilters {
*/
export type LegacyQueryData = PlainObject;

/**
* Ambiguous query data type. Reserved for the generic QueryFormData.
* Don't use this for a specific chart (since you know which API it uses already).
*/
export type QueryData = LegacyQueryData | ChartDataResponseResult;
7 changes: 5 additions & 2 deletions plugins/legacy-preset-chart-big-number/src/BigNumber/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import transformProps, { BigNumberChartProps, BigNumberFormData } from './transformProps';
import thumbnail from './images/thumbnail.png';

const metadata = new ChartMetadata({
Expand All @@ -28,7 +28,10 @@ const metadata = new ChartMetadata({
useLegacyApi: true,
});

export default class BigNumberChartPlugin extends ChartPlugin {
export default class BigNumberChartPlugin extends ChartPlugin<
BigNumberFormData,
BigNumberChartProps
> {
constructor() {
super({
loadChart: () => import('./BigNumber'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import {
getNumberFormatter,
NumberFormats,
ChartProps,
QueryData,
LegacyQueryData,
QueryFormData,
} from '@superset-ui/core';

const TIME_COLUMN = '__timestamp';
Expand All @@ -34,7 +35,7 @@ export interface BigNumberDatum {
[key: string]: number | null;
}

export type BigNumberFormData = {
export type BigNumberFormData = QueryFormData & {
colorPicker?: {
r: number;
g: number;
Expand All @@ -50,14 +51,14 @@ export type BigNumberFormData = {
timeGrainSqla?: TimeGranularity;
};

export type BignumberChartProps = ChartProps & {
export type BigNumberChartProps = ChartProps & {
formData: BigNumberFormData;
queriesData: (QueryData & {
queriesData: (LegacyQueryData & {
data?: BigNumberDatum[];
})[];
};

export default function transformProps(chartProps: BignumberChartProps) {
export default function transformProps(chartProps: BigNumberChartProps) {
const { width, height, queriesData, formData } = chartProps;
const {
colorPicker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
*/
import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
import controlPanel from './controlPanel';
import transformProps from '../BigNumber/transformProps';
import transformProps, {
BigNumberChartProps,
BigNumberFormData,
} from '../BigNumber/transformProps';
import thumbnail from './images/thumbnail.png';

const metadata = new ChartMetadata({
Expand All @@ -28,7 +31,10 @@ const metadata = new ChartMetadata({
useLegacyApi: true,
});

export default class BigNumberTotalChartPlugin extends ChartPlugin {
export default class BigNumberTotalChartPlugin extends ChartPlugin<
BigNumberFormData,
BigNumberChartProps
> {
constructor() {
super({
loadChart: () => import('../BigNumber/BigNumber'),
Expand Down
8 changes: 3 additions & 5 deletions plugins/plugin-chart-echarts/src/BoxPlot/buildQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ import { BoxPlotQueryFormData, BoxPlotQueryObjectWhiskerType } from './types';
const PERCENTILE_REGEX = /(\d+)\/(\d+) percentiles/;

export default function buildQuery(formData: BoxPlotQueryFormData) {
const { whiskerOptions } = formData;
const { whiskerOptions, columns: distributionColumns = [] } = formData;
return buildQueryContext(formData, baseQueryObject => {
let whiskerType: BoxPlotQueryObjectWhiskerType;
let percentiles: [number, number] | undefined;
const { columns, groupby, metrics } = baseQueryObject;
const { columns, metrics } = baseQueryObject;
const percentileMatch = PERCENTILE_REGEX.exec(whiskerOptions as string);
const distributionColumns = columns || [];

if (whiskerOptions === 'Tukey') {
whiskerType = 'tukey';
Expand All @@ -44,14 +43,13 @@ export default function buildQuery(formData: BoxPlotQueryFormData) {
{
...baseQueryObject,
is_timeseries: distributionColumns.length === 0,
groupby: (groupby || []).concat(distributionColumns),
post_processing: [
{
operation: 'boxplot',
options: {
whisker_type: whiskerType,
percentiles,
groupby,
groupby: columns,
metrics: metrics.map(getMetricLabel),
},
},
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5160,13 +5160,6 @@
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
integrity sha512-Q1y515GcOdTHgagaVFhHnIFQ38ygs/kmxdNpvpou+raI9UO3YZcHDngBSYKQklcKlvA7iuQlmIKbzvmxcOE9CQ==

"@types/echarts@^4.6.3":
version "4.6.3"
resolved "https://registry.yarnpkg.com/@types/echarts/-/echarts-4.6.3.tgz#227b33b106203ceb2ca4fa51760f406618caa89a"
integrity sha512-XsDsLtPDxSGPqcHvVEbH+z5r9lPiduNOf4aL3NjGprQ/4SliDiTS7DErimHpVdiEOoVFzwjn2usvgLOb1JqOJA==
dependencies:
"@types/zrender" "*"

"@types/enzyme@^3.10.3":
version "3.10.5"
resolved "https://registry.yarnpkg.com/@types/enzyme/-/enzyme-3.10.5.tgz#fe7eeba3550369eed20e7fb565bfb74eec44f1f0"
Expand Down Expand Up @@ -5595,11 +5588,6 @@
dependencies:
"@types/yargs-parser" "*"

"@types/zrender@*":
version "4.0.0"
resolved "https://registry.yarnpkg.com/@types/zrender/-/zrender-4.0.0.tgz#a6806f12ec4eccaaebd9b0d816f049aca6188fbd"
integrity sha512-s89GOIeKFiod2KSqHkfd2rzx+T2DVu7ihZCBEBnhFrzvQPUmzvDSBot9Fi1DfMQm9Odg+rTqoMGC38RvrwJK2w==

"@typescript-eslint/eslint-plugin@^4.1.0":
version "4.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.9.0.tgz#8fde15743413661fdc086c9f1f5d74a80b856113"
Expand Down

0 comments on commit 4faffc4

Please sign in to comment.