mirror of https://github.com/apache/superset.git
chore: Adds theme object to chart properties (#19951)
This commit is contained in:
parent
5dd3ea154b
commit
e9032e95ec
|
@ -24,6 +24,7 @@ import ErrorBoundary, {
|
||||||
} from 'react-error-boundary';
|
} from 'react-error-boundary';
|
||||||
import { ParentSize } from '@vx/responsive';
|
import { ParentSize } from '@vx/responsive';
|
||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
|
import { withTheme } from '@emotion/react';
|
||||||
import { parseLength, Dimension } from '../../dimension';
|
import { parseLength, Dimension } from '../../dimension';
|
||||||
import SuperChartCore, { Props as SuperChartCoreProps } from './SuperChartCore';
|
import SuperChartCore, { Props as SuperChartCoreProps } from './SuperChartCore';
|
||||||
import DefaultFallbackComponent from './FallbackComponent';
|
import DefaultFallbackComponent from './FallbackComponent';
|
||||||
|
@ -88,7 +89,7 @@ export type Props = Omit<SuperChartCoreProps, 'chartProps'> &
|
||||||
|
|
||||||
type PropsWithDefault = Props & Readonly<typeof defaultProps>;
|
type PropsWithDefault = Props & Readonly<typeof defaultProps>;
|
||||||
|
|
||||||
export default class SuperChart extends React.PureComponent<Props, {}> {
|
class SuperChart extends React.PureComponent<Props, {}> {
|
||||||
/**
|
/**
|
||||||
* SuperChart's core
|
* SuperChart's core
|
||||||
*/
|
*/
|
||||||
|
@ -156,6 +157,7 @@ export default class SuperChart extends React.PureComponent<Props, {}> {
|
||||||
queriesData,
|
queriesData,
|
||||||
enableNoResults,
|
enableNoResults,
|
||||||
noResults,
|
noResults,
|
||||||
|
theme,
|
||||||
...rest
|
...rest
|
||||||
} = this.props as PropsWithDefault;
|
} = this.props as PropsWithDefault;
|
||||||
|
|
||||||
|
@ -164,6 +166,7 @@ export default class SuperChart extends React.PureComponent<Props, {}> {
|
||||||
queriesData,
|
queriesData,
|
||||||
height,
|
height,
|
||||||
width,
|
width,
|
||||||
|
theme,
|
||||||
});
|
});
|
||||||
|
|
||||||
let chart;
|
let chart;
|
||||||
|
@ -247,3 +250,5 @@ export default class SuperChart extends React.PureComponent<Props, {}> {
|
||||||
return this.renderChart(widthInfo.value, heightInfo.value);
|
return this.renderChart(widthInfo.value, heightInfo.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default withTheme(SuperChart);
|
||||||
|
|
|
@ -32,6 +32,7 @@ import {
|
||||||
} from '../..';
|
} from '../..';
|
||||||
import { HandlerFunction, PlainObject, SetDataMaskHook } from '../types/Base';
|
import { HandlerFunction, PlainObject, SetDataMaskHook } from '../types/Base';
|
||||||
import { QueryData, DataRecordFilters } from '..';
|
import { QueryData, DataRecordFilters } from '..';
|
||||||
|
import { SupersetTheme } from '../../style';
|
||||||
|
|
||||||
// TODO: more specific typing for these fields of ChartProps
|
// TODO: more specific typing for these fields of ChartProps
|
||||||
type AnnotationData = PlainObject;
|
type AnnotationData = PlainObject;
|
||||||
|
@ -93,6 +94,8 @@ export interface ChartPropsConfig {
|
||||||
isRefreshing?: boolean;
|
isRefreshing?: boolean;
|
||||||
/** chart ref */
|
/** chart ref */
|
||||||
inputRef?: RefObject<any>;
|
inputRef?: RefObject<any>;
|
||||||
|
/** Theme object */
|
||||||
|
theme: SupersetTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_WIDTH = 800;
|
const DEFAULT_WIDTH = 800;
|
||||||
|
@ -133,6 +136,8 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {
|
||||||
|
|
||||||
inputRef?: RefObject<any>;
|
inputRef?: RefObject<any>;
|
||||||
|
|
||||||
|
theme: SupersetTheme;
|
||||||
|
|
||||||
constructor(config: ChartPropsConfig & { formData?: FormData } = {}) {
|
constructor(config: ChartPropsConfig & { formData?: FormData } = {}) {
|
||||||
const {
|
const {
|
||||||
annotationData = {},
|
annotationData = {},
|
||||||
|
@ -149,6 +154,7 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {
|
||||||
appSection,
|
appSection,
|
||||||
isRefreshing,
|
isRefreshing,
|
||||||
inputRef,
|
inputRef,
|
||||||
|
theme,
|
||||||
} = config;
|
} = config;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.height = height;
|
this.height = height;
|
||||||
|
@ -166,6 +172,7 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {
|
||||||
this.appSection = appSection;
|
this.appSection = appSection;
|
||||||
this.isRefreshing = isRefreshing;
|
this.isRefreshing = isRefreshing;
|
||||||
this.inputRef = inputRef;
|
this.inputRef = inputRef;
|
||||||
|
this.theme = theme;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +193,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
|
||||||
input => input.appSection,
|
input => input.appSection,
|
||||||
input => input.isRefreshing,
|
input => input.isRefreshing,
|
||||||
input => input.inputRef,
|
input => input.inputRef,
|
||||||
|
input => input.theme,
|
||||||
(
|
(
|
||||||
annotationData,
|
annotationData,
|
||||||
datasource,
|
datasource,
|
||||||
|
@ -201,6 +209,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
|
||||||
appSection,
|
appSection,
|
||||||
isRefreshing,
|
isRefreshing,
|
||||||
inputRef,
|
inputRef,
|
||||||
|
theme,
|
||||||
) =>
|
) =>
|
||||||
new ChartProps({
|
new ChartProps({
|
||||||
annotationData,
|
annotationData,
|
||||||
|
@ -217,6 +226,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
|
||||||
appSection,
|
appSection,
|
||||||
isRefreshing,
|
isRefreshing,
|
||||||
inputRef,
|
inputRef,
|
||||||
|
theme,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
@ -29,9 +29,7 @@ import {
|
||||||
ThemeProvider,
|
ThemeProvider,
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
import { mount as enzymeMount } from 'enzyme';
|
import { mount as enzymeMount } from 'enzyme';
|
||||||
import RealSuperChart, {
|
import { WrapperProps } from '../../../src/chart/components/SuperChart';
|
||||||
WrapperProps,
|
|
||||||
} from '../../../src/chart/components/SuperChart';
|
|
||||||
import NoResultsComponent from '../../../src/chart/components/NoResultsComponent';
|
import NoResultsComponent from '../../../src/chart/components/NoResultsComponent';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
@ -111,9 +109,8 @@ describe('SuperChart', () => {
|
||||||
expectedErrors = 0;
|
expectedErrors = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders default FallbackComponent', () => {
|
it('renders default FallbackComponent', async () => {
|
||||||
expectedErrors = 1;
|
expectedErrors = 1;
|
||||||
jest.spyOn(RealSuperChart.defaultProps, 'FallbackComponent');
|
|
||||||
const wrapper = mount(
|
const wrapper = mount(
|
||||||
<SuperChart
|
<SuperChart
|
||||||
chartType={ChartKeys.BUGGY}
|
chartType={ChartKeys.BUGGY}
|
||||||
|
@ -122,14 +119,9 @@ describe('SuperChart', () => {
|
||||||
height="200"
|
height="200"
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
const renderedWrapper = wrapper.render();
|
await new Promise(resolve => setImmediate(resolve));
|
||||||
|
wrapper.update();
|
||||||
return promiseTimeout(() => {
|
expect(wrapper.text()).toContain('Oops! An error occured!');
|
||||||
expect(renderedWrapper.find('div.test-component')).toHaveLength(0);
|
|
||||||
expect(
|
|
||||||
RealSuperChart.defaultProps.FallbackComponent,
|
|
||||||
).toHaveBeenCalledTimes(1);
|
|
||||||
}, 100);
|
|
||||||
});
|
});
|
||||||
it('renders custom FallbackComponent', () => {
|
it('renders custom FallbackComponent', () => {
|
||||||
expectedErrors = 1;
|
expectedErrors = 1;
|
||||||
|
|
|
@ -21,7 +21,7 @@ import React from 'react';
|
||||||
import { mount, shallow } from 'enzyme';
|
import { mount, shallow } from 'enzyme';
|
||||||
import mockConsole, { RestoreConsole } from 'jest-mock-console';
|
import mockConsole, { RestoreConsole } from 'jest-mock-console';
|
||||||
|
|
||||||
import { ChartProps, promiseTimeout } from '@superset-ui/core';
|
import { ChartProps, promiseTimeout, supersetTheme } from '@superset-ui/core';
|
||||||
import SuperChartCore from '../../../src/chart/components/SuperChartCore';
|
import SuperChartCore from '../../../src/chart/components/SuperChartCore';
|
||||||
import {
|
import {
|
||||||
ChartKeys,
|
ChartKeys,
|
||||||
|
@ -123,6 +123,7 @@ describe('SuperChartCore', () => {
|
||||||
it('uses preTransformProps when specified', () => {
|
it('uses preTransformProps when specified', () => {
|
||||||
const chartPropsWithPayload = new ChartProps({
|
const chartPropsWithPayload = new ChartProps({
|
||||||
queriesData: [{ message: 'hulk' }],
|
queriesData: [{ message: 'hulk' }],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
const wrapper = shallow(
|
const wrapper = shallow(
|
||||||
<SuperChartCore
|
<SuperChartCore
|
||||||
|
|
|
@ -31,6 +31,7 @@ import {
|
||||||
getChartControlPanelRegistry,
|
getChartControlPanelRegistry,
|
||||||
QueryFormData,
|
QueryFormData,
|
||||||
DatasourceType,
|
DatasourceType,
|
||||||
|
supersetTheme,
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
|
|
||||||
describe('ChartPlugin', () => {
|
describe('ChartPlugin', () => {
|
||||||
|
@ -130,6 +131,7 @@ describe('ChartPlugin', () => {
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 400,
|
height: 400,
|
||||||
queriesData: [{}],
|
queriesData: [{}],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
it('defaults to identity function', () => {
|
it('defaults to identity function', () => {
|
||||||
const plugin = new ChartPlugin({
|
const plugin = new ChartPlugin({
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Behavior, ChartProps } from '@superset-ui/core';
|
import { Behavior, ChartProps, supersetTheme } from '@superset-ui/core';
|
||||||
|
|
||||||
const RAW_FORM_DATA = {
|
const RAW_FORM_DATA = {
|
||||||
some_field: 1,
|
some_field: 1,
|
||||||
|
@ -42,6 +42,7 @@ describe('ChartProps', () => {
|
||||||
height: 600,
|
height: 600,
|
||||||
formData: RAW_FORM_DATA,
|
formData: RAW_FORM_DATA,
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
expect(props).toBeInstanceOf(ChartProps);
|
expect(props).toBeInstanceOf(ChartProps);
|
||||||
});
|
});
|
||||||
|
@ -52,6 +53,7 @@ describe('ChartProps', () => {
|
||||||
datasource: RAW_DATASOURCE,
|
datasource: RAW_DATASOURCE,
|
||||||
formData: RAW_FORM_DATA,
|
formData: RAW_FORM_DATA,
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
expect(props.formData.someField as number).toEqual(1);
|
expect(props.formData.someField as number).toEqual(1);
|
||||||
expect(props.datasource.columnFormats).toEqual(
|
expect(props.datasource.columnFormats).toEqual(
|
||||||
|
@ -75,6 +77,7 @@ describe('ChartProps', () => {
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
behaviors: BEHAVIORS,
|
behaviors: BEHAVIORS,
|
||||||
isRefreshing: false,
|
isRefreshing: false,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
const props2 = selector({
|
const props2 = selector({
|
||||||
width: 800,
|
width: 800,
|
||||||
|
@ -84,6 +87,7 @@ describe('ChartProps', () => {
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
behaviors: BEHAVIORS,
|
behaviors: BEHAVIORS,
|
||||||
isRefreshing: false,
|
isRefreshing: false,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
expect(props1).toBe(props2);
|
expect(props1).toBe(props2);
|
||||||
});
|
});
|
||||||
|
@ -101,6 +105,7 @@ describe('ChartProps', () => {
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
behaviors: BEHAVIORS,
|
behaviors: BEHAVIORS,
|
||||||
isRefreshing: false,
|
isRefreshing: false,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
const props2 = selector({
|
const props2 = selector({
|
||||||
width: 800,
|
width: 800,
|
||||||
|
@ -110,6 +115,7 @@ describe('ChartProps', () => {
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
behaviors: BEHAVIORS,
|
behaviors: BEHAVIORS,
|
||||||
isRefreshing: true,
|
isRefreshing: true,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
expect(props1).not.toBe(props2);
|
expect(props1).not.toBe(props2);
|
||||||
});
|
});
|
||||||
|
@ -120,6 +126,7 @@ describe('ChartProps', () => {
|
||||||
datasource: RAW_DATASOURCE,
|
datasource: RAW_DATASOURCE,
|
||||||
formData: RAW_FORM_DATA,
|
formData: RAW_FORM_DATA,
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
const props2 = selector({
|
const props2 = selector({
|
||||||
width: 800,
|
width: 800,
|
||||||
|
@ -127,6 +134,7 @@ describe('ChartProps', () => {
|
||||||
datasource: RAW_DATASOURCE,
|
datasource: RAW_DATASOURCE,
|
||||||
formData: { new_field: 3 },
|
formData: { new_field: 3 },
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
const props3 = selector({
|
const props3 = selector({
|
||||||
width: 800,
|
width: 800,
|
||||||
|
@ -134,6 +142,7 @@ describe('ChartProps', () => {
|
||||||
datasource: RAW_DATASOURCE,
|
datasource: RAW_DATASOURCE,
|
||||||
formData: RAW_FORM_DATA,
|
formData: RAW_FORM_DATA,
|
||||||
queriesData: QUERIES_DATA,
|
queriesData: QUERIES_DATA,
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
expect(props1).not.toBe(props2);
|
expect(props1).not.toBe(props2);
|
||||||
expect(props1).not.toBe(props3);
|
expect(props1).not.toBe(props3);
|
||||||
|
|
|
@ -16,7 +16,11 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { DatasourceType, TimeGranularity } from '@superset-ui/core';
|
import {
|
||||||
|
DatasourceType,
|
||||||
|
supersetTheme,
|
||||||
|
TimeGranularity,
|
||||||
|
} from '@superset-ui/core';
|
||||||
import transformProps from '../../src/BigNumber/BigNumberWithTrendline/transformProps';
|
import transformProps from '../../src/BigNumber/BigNumberWithTrendline/transformProps';
|
||||||
import {
|
import {
|
||||||
BigNumberDatum,
|
BigNumberDatum,
|
||||||
|
@ -89,6 +93,7 @@ function generateProps(
|
||||||
ownState: {},
|
ownState: {},
|
||||||
filterState: {},
|
filterState: {},
|
||||||
behaviors: [],
|
behaviors: [],
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { ChartProps, SqlaFormData } from '@superset-ui/core';
|
import { ChartProps, SqlaFormData, supersetTheme } from '@superset-ui/core';
|
||||||
import { EchartsBoxPlotChartProps } from '../../src/BoxPlot/types';
|
import { EchartsBoxPlotChartProps } from '../../src/BoxPlot/types';
|
||||||
import transformProps from '../../src/BoxPlot/transformProps';
|
import transformProps from '../../src/BoxPlot/transformProps';
|
||||||
|
|
||||||
|
@ -66,6 +66,7 @@ describe('BoxPlot transformProps', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transform chart props for viz', () => {
|
it('should transform chart props for viz', () => {
|
||||||
|
|
|
@ -16,7 +16,11 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { ChartProps, getNumberFormatter } from '@superset-ui/core';
|
import {
|
||||||
|
ChartProps,
|
||||||
|
getNumberFormatter,
|
||||||
|
supersetTheme,
|
||||||
|
} from '@superset-ui/core';
|
||||||
import transformProps, {
|
import transformProps, {
|
||||||
formatFunnelLabel,
|
formatFunnelLabel,
|
||||||
} from '../../src/Funnel/transformProps';
|
} from '../../src/Funnel/transformProps';
|
||||||
|
@ -45,6 +49,7 @@ describe('Funnel transformProps', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transform chart props for viz', () => {
|
it('should transform chart props for viz', () => {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { ChartProps, SqlaFormData } from '@superset-ui/core';
|
import { ChartProps, SqlaFormData, supersetTheme } from '@superset-ui/core';
|
||||||
import transformProps from '../../src/Gauge/transformProps';
|
import transformProps from '../../src/Gauge/transformProps';
|
||||||
import { EchartsGaugeChartProps } from '../../src/Gauge/types';
|
import { EchartsGaugeChartProps } from '../../src/Gauge/types';
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ describe('Echarts Gauge transformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartProps = new ChartProps(chartPropsConfig);
|
const chartProps = new ChartProps(chartPropsConfig);
|
||||||
|
@ -123,6 +124,7 @@ describe('Echarts Gauge transformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartProps = new ChartProps(chartPropsConfig);
|
const chartProps = new ChartProps(chartPropsConfig);
|
||||||
|
@ -200,6 +202,7 @@ describe('Echarts Gauge transformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartProps = new ChartProps(chartPropsConfig);
|
const chartProps = new ChartProps(chartPropsConfig);
|
||||||
|
@ -279,6 +282,7 @@ describe('Echarts Gauge transformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartProps = new ChartProps(chartPropsConfig);
|
const chartProps = new ChartProps(chartPropsConfig);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { ChartProps } from '@superset-ui/core';
|
import { ChartProps, supersetTheme } from '@superset-ui/core';
|
||||||
import transformProps from '../../src/Graph/transformProps';
|
import transformProps from '../../src/Graph/transformProps';
|
||||||
import { DEFAULT_GRAPH_SERIES_OPTION } from '../../src/Graph/constants';
|
import { DEFAULT_GRAPH_SERIES_OPTION } from '../../src/Graph/constants';
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ describe('EchartsGraph transformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartProps = new ChartProps(chartPropsConfig);
|
const chartProps = new ChartProps(chartPropsConfig);
|
||||||
|
@ -192,6 +193,7 @@ describe('EchartsGraph transformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const chartProps = new ChartProps(chartPropsConfig);
|
const chartProps = new ChartProps(chartPropsConfig);
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
ChartProps,
|
ChartProps,
|
||||||
getNumberFormatter,
|
getNumberFormatter,
|
||||||
SqlaFormData,
|
SqlaFormData,
|
||||||
|
supersetTheme,
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
import transformProps, { formatPieLabel } from '../../src/Pie/transformProps';
|
import transformProps, { formatPieLabel } from '../../src/Pie/transformProps';
|
||||||
import { EchartsPieChartProps, EchartsPieLabelType } from '../../src/Pie/types';
|
import { EchartsPieChartProps, EchartsPieLabelType } from '../../src/Pie/types';
|
||||||
|
@ -45,6 +46,7 @@ describe('Pie transformProps', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transform chart props for viz', () => {
|
it('should transform chart props for viz', () => {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import {
|
||||||
FormulaAnnotationLayer,
|
FormulaAnnotationLayer,
|
||||||
IntervalAnnotationLayer,
|
IntervalAnnotationLayer,
|
||||||
SqlaFormData,
|
SqlaFormData,
|
||||||
|
supersetTheme,
|
||||||
TimeseriesAnnotationLayer,
|
TimeseriesAnnotationLayer,
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
import { EchartsTimeseriesChartProps } from '../../src/types';
|
import { EchartsTimeseriesChartProps } from '../../src/types';
|
||||||
|
@ -52,6 +53,7 @@ describe('EchartsTimeseries transformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should transform chart props for viz', () => {
|
it('should transform chart props for viz', () => {
|
||||||
|
@ -315,6 +317,7 @@ describe('Does transformProps transform series correctly', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData,
|
queriesData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const totalStackedValues = queriesData[0].data.reduce(
|
const totalStackedValues = queriesData[0].data.reduce(
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { ChartProps } from '@superset-ui/core';
|
import { ChartProps, supersetTheme } from '@superset-ui/core';
|
||||||
import transformProps from '../../src/Tree/transformProps';
|
import transformProps from '../../src/Tree/transformProps';
|
||||||
|
|
||||||
describe('EchartsTree transformProps', () => {
|
describe('EchartsTree transformProps', () => {
|
||||||
|
@ -34,6 +34,7 @@ describe('EchartsTree transformProps', () => {
|
||||||
formData,
|
formData,
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
it('should transform when parent present before child', () => {
|
it('should transform when parent present before child', () => {
|
||||||
const queriesData = [
|
const queriesData = [
|
||||||
|
@ -187,6 +188,7 @@ describe('EchartsTree transformProps', () => {
|
||||||
formData,
|
formData,
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
const queriesData = [
|
const queriesData = [
|
||||||
{
|
{
|
||||||
|
@ -266,6 +268,7 @@ describe('EchartsTree transformProps', () => {
|
||||||
formData,
|
formData,
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
const queriesData = [
|
const queriesData = [
|
||||||
{
|
{
|
||||||
|
@ -347,6 +350,7 @@ describe('EchartsTree transformProps', () => {
|
||||||
formData,
|
formData,
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
const queriesData = [
|
const queriesData = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { ChartProps } from '@superset-ui/core';
|
import { ChartProps, supersetTheme } from '@superset-ui/core';
|
||||||
import { EchartsTreemapChartProps } from '../../src/Treemap/types';
|
import { EchartsTreemapChartProps } from '../../src/Treemap/types';
|
||||||
import transformProps from '../../src/Treemap/transformProps';
|
import transformProps from '../../src/Treemap/transformProps';
|
||||||
|
|
||||||
|
@ -40,6 +40,7 @@ describe('Treemap transformProps', () => {
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transform chart props for viz', () => {
|
it('should transform chart props for viz', () => {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
import { ChartProps, QueryFormData } from '@superset-ui/core';
|
import { ChartProps, QueryFormData, supersetTheme } from '@superset-ui/core';
|
||||||
import { HandlebarsQueryFormData } from '../../src/types';
|
import { HandlebarsQueryFormData } from '../../src/types';
|
||||||
import transformProps from '../../src/plugin/transformProps';
|
import transformProps from '../../src/plugin/transformProps';
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@ describe('Handlebars tranformProps', () => {
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
queriesData: [{ data }],
|
queriesData: [{ data }],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should tranform chart props for viz', () => {
|
it('should tranform chart props for viz', () => {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ChartProps, QueryFormData } from '@superset-ui/core';
|
import { ChartProps, QueryFormData, supersetTheme } from '@superset-ui/core';
|
||||||
import transformProps from '../../src/plugin/transformProps';
|
import transformProps from '../../src/plugin/transformProps';
|
||||||
import { MetricsLayoutEnum } from '../../src/types';
|
import { MetricsLayoutEnum } from '../../src/types';
|
||||||
|
|
||||||
|
@ -61,6 +61,7 @@ describe('PivotTableChart transformProps', () => {
|
||||||
hooks: { setDataMask },
|
hooks: { setDataMask },
|
||||||
filterState: { selectedFilters: {} },
|
filterState: { selectedFilters: {} },
|
||||||
datasource: { verboseMap: {}, columnFormats: {} },
|
datasource: { verboseMap: {}, columnFormats: {} },
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transform chart props for viz', () => {
|
it('should transform chart props for viz', () => {
|
||||||
|
|
|
@ -21,6 +21,7 @@ import {
|
||||||
ChartProps,
|
ChartProps,
|
||||||
DatasourceType,
|
DatasourceType,
|
||||||
GenericDataType,
|
GenericDataType,
|
||||||
|
supersetTheme,
|
||||||
} from '@superset-ui/core';
|
} from '@superset-ui/core';
|
||||||
import { TableChartProps, TableChartFormData } from '../src/types';
|
import { TableChartProps, TableChartFormData } from '../src/types';
|
||||||
|
|
||||||
|
@ -63,6 +64,7 @@ const basicChartProps = {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
formData: basicFormData,
|
formData: basicFormData,
|
||||||
|
theme: supersetTheme,
|
||||||
};
|
};
|
||||||
|
|
||||||
const basicQueryResult: ChartDataResponseResult = {
|
const basicQueryResult: ChartDataResponseResult = {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ChartProps } from '@superset-ui/core';
|
import { ChartProps, supersetTheme } from '@superset-ui/core';
|
||||||
import transformProps from '../../src/legacyPlugin/transformProps';
|
import transformProps from '../../src/legacyPlugin/transformProps';
|
||||||
|
|
||||||
describe('WordCloud transformProps', () => {
|
describe('WordCloud transformProps', () => {
|
||||||
|
@ -40,6 +40,7 @@ describe('WordCloud transformProps', () => {
|
||||||
data: [{ name: 'Hulk', sum__num: 1 }],
|
data: [{ name: 'Hulk', sum__num: 1 }],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
theme: supersetTheme,
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should transform chart props for word cloud viz', () => {
|
it('should transform chart props for word cloud viz', () => {
|
||||||
|
|
Loading…
Reference in New Issue