Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(charts): big-number display broken in echarts #24492

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/

import { Behavior, ChartLabel } from '../types/Base';
import { ParseMethod } from '../../connection';

interface LookupTable {
[key: string]: boolean;
Expand Down Expand Up @@ -49,6 +50,7 @@ export interface ChartMetadataConfig {
label?: ChartLabel | null;
labelExplanation?: string | null;
queryObjectCount?: number;
parseMethod?: ParseMethod;
}

export default class ChartMetadata {
Expand Down Expand Up @@ -90,6 +92,8 @@ export default class ChartMetadata {

queryObjectCount: number;

parseMethod: ParseMethod;

constructor(config: ChartMetadataConfig) {
const {
name,
Expand All @@ -110,6 +114,7 @@ export default class ChartMetadata {
label = null,
labelExplanation = null,
queryObjectCount = 1,
parseMethod = 'json-bigint',
} = config;

this.name = name;
Expand Down Expand Up @@ -139,6 +144,7 @@ export default class ChartMetadata {
this.label = label;
this.labelExplanation = labelExplanation;
this.queryObjectCount = queryObjectCount;
this.parseMethod = parseMethod;
}

canBeAnnotationType(type: string): boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, ChartMetadata, ChartPlugin, Behavior } from '@superset-ui/core';
import { t, ChartMetadata, Behavior } from '@superset-ui/core';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import buildQuery from './buildQuery';
import example1 from './images/BigNumber.jpg';
import example2 from './images/BigNumber2.jpg';
import thumbnail from './images/thumbnail.png';
import { BigNumberTotalChartProps, BigNumberTotalFormData } from '../types';
import { EchartsChartPlugin } from '../../types';

const metadata = new ChartMetadata({
category: t('KPI'),
Expand All @@ -48,7 +49,7 @@ const metadata = new ChartMetadata({
behaviors: [Behavior.DRILL_TO_DETAIL],
});

export default class BigNumberTotalChartPlugin extends ChartPlugin<
export default class BigNumberTotalChartPlugin extends EchartsChartPlugin<
BigNumberTotalFormData,
BigNumberTotalChartProps
> {
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 { t, ChartMetadata, ChartPlugin, Behavior } from '@superset-ui/core';
import { t, ChartMetadata, Behavior } from '@superset-ui/core';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import buildQuery from './buildQuery';
Expand All @@ -26,6 +26,7 @@ import {
BigNumberWithTrendlineChartProps,
BigNumberWithTrendlineFormData,
} from '../types';
import { EchartsChartPlugin } from '../../types';

const metadata = new ChartMetadata({
category: t('KPI'),
Expand All @@ -47,7 +48,7 @@ const metadata = new ChartMetadata({
behaviors: [Behavior.DRILL_TO_DETAIL],
});

export default class BigNumberWithTrendlineChartPlugin extends ChartPlugin<
export default class BigNumberWithTrendlineChartPlugin extends EchartsChartPlugin<
BigNumberWithTrendlineFormData,
BigNumberWithTrendlineChartProps
> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
import { Behavior, t } from '@superset-ui/core';
import buildQuery from './buildQuery';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import example from './images/BoxPlot.jpg';
import thumbnail from './images/thumbnail.png';
import { BoxPlotQueryFormData, EchartsBoxPlotChartProps } from './types';
import { EchartsChartPlugin } from '../types';

export default class EchartsBoxPlotChartPlugin extends ChartPlugin<
export default class EchartsBoxPlotChartPlugin extends EchartsChartPlugin<
BoxPlotQueryFormData,
EchartsBoxPlotChartProps
> {
Expand All @@ -43,7 +44,7 @@ export default class EchartsBoxPlotChartPlugin extends ChartPlugin<
buildQuery,
controlPanel,
loadChart: () => import('./EchartsBoxPlot'),
metadata: new ChartMetadata({
metadata: {
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Expand All @@ -58,7 +59,7 @@ export default class EchartsBoxPlotChartPlugin extends ChartPlugin<
name: t('Box Plot'),
tags: [t('ECharts'), t('Range'), t('Statistical')],
thumbnail,
}),
},
transformProps,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
import { Behavior, t } from '@superset-ui/core';
import buildQuery from './buildQuery';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import example from './images/example.jpg';
import { EchartsFunnelChartProps, EchartsFunnelFormData } from './types';
import { EchartsChartPlugin } from '../types';

export default class EchartsFunnelChartPlugin extends ChartPlugin<
export default class EchartsFunnelChartPlugin extends EchartsChartPlugin<
EchartsFunnelFormData,
EchartsFunnelChartProps
> {
Expand All @@ -43,7 +44,7 @@ export default class EchartsFunnelChartPlugin extends ChartPlugin<
buildQuery,
controlPanel,
loadChart: () => import('./EchartsFunnel'),
metadata: new ChartMetadata({
metadata: {
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Expand All @@ -65,7 +66,7 @@ export default class EchartsFunnelChartPlugin extends ChartPlugin<
t('Trend'),
],
thumbnail,
}),
},
transformProps,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, ChartMetadata, ChartPlugin, Behavior } from '@superset-ui/core';
import { t, Behavior } from '@superset-ui/core';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import example1 from './images/example1.jpg';
import example2 from './images/example2.jpg';
import buildQuery from './buildQuery';
import { EchartsGaugeChartProps, EchartsGaugeFormData } from './types';
import { EchartsChartPlugin } from '../types';

export default class EchartsGaugeChartPlugin extends ChartPlugin<
export default class EchartsGaugeChartPlugin extends EchartsChartPlugin<
EchartsGaugeFormData,
EchartsGaugeChartProps
> {
Expand All @@ -34,7 +35,7 @@ export default class EchartsGaugeChartPlugin extends ChartPlugin<
buildQuery,
controlPanel,
loadChart: () => import('./EchartsGauge'),
metadata: new ChartMetadata({
metadata: {
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Expand All @@ -55,7 +56,7 @@ export default class EchartsGaugeChartPlugin extends ChartPlugin<
t('Report'),
],
thumbnail,
}),
},
transformProps,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
import { Behavior, t } from '@superset-ui/core';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import example from './images/example.jpg';
import buildQuery from './buildQuery';
import { EchartsChartPlugin } from '../types';

export default class EchartsGraphChartPlugin extends ChartPlugin {
export default class EchartsGraphChartPlugin extends EchartsChartPlugin {
constructor() {
super({
buildQuery,
controlPanel,
loadChart: () => import('./EchartsGraph'),
metadata: new ChartMetadata({
metadata: {
category: t('Flow'),
credits: ['https://echarts.apache.org'],
description: t(
Expand All @@ -53,7 +54,7 @@ export default class EchartsGraphChartPlugin extends ChartPlugin {
Behavior.DRILL_TO_DETAIL,
Behavior.DRILL_BY,
],
}),
},
transformProps,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import {
AnnotationType,
Behavior,
ChartMetadata,
ChartPlugin,
hasGenericChartAxes,
t,
} from '@superset-ui/core';
Expand All @@ -33,8 +31,9 @@ import {
EchartsMixedTimeseriesFormData,
EchartsMixedTimeseriesProps,
} from './types';
import { EchartsChartPlugin } from '../types';

export default class EchartsTimeseriesChartPlugin extends ChartPlugin<
export default class EchartsTimeseriesChartPlugin extends EchartsChartPlugin<
EchartsMixedTimeseriesFormData,
EchartsMixedTimeseriesProps
> {
Expand All @@ -53,7 +52,7 @@ export default class EchartsTimeseriesChartPlugin extends ChartPlugin<
buildQuery,
controlPanel,
loadChart: () => import('./EchartsMixedTimeseries'),
metadata: new ChartMetadata({
metadata: {
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Expand Down Expand Up @@ -88,7 +87,7 @@ export default class EchartsTimeseriesChartPlugin extends ChartPlugin<
t('Transformable'),
],
queryObjectCount: 2,
}),
},
// @ts-ignore
transformProps,
});
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 { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
import { Behavior, t } from '@superset-ui/core';
import buildQuery from './buildQuery';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
Expand All @@ -26,8 +26,9 @@ import example2 from './images/Pie2.jpg';
import example3 from './images/Pie3.jpg';
import example4 from './images/Pie4.jpg';
import { EchartsPieChartProps, EchartsPieFormData } from './types';
import { EchartsChartPlugin } from '../types';

export default class EchartsPieChartPlugin extends ChartPlugin<
export default class EchartsPieChartPlugin extends EchartsChartPlugin<
EchartsPieFormData,
EchartsPieChartProps
> {
Expand All @@ -46,7 +47,7 @@ export default class EchartsPieChartPlugin extends ChartPlugin<
buildQuery,
controlPanel,
loadChart: () => import('./EchartsPie'),
metadata: new ChartMetadata({
metadata: {
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Expand Down Expand Up @@ -76,7 +77,7 @@ export default class EchartsPieChartPlugin extends ChartPlugin<
t('ECharts'),
],
thumbnail,
}),
},
transformProps,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
import { Behavior, t } from '@superset-ui/core';
import buildQuery from './buildQuery';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import example1 from './images/example1.jpg';
import example2 from './images/example2.jpg';
import { EchartsRadarChartProps, EchartsRadarFormData } from './types';
import { EchartsChartPlugin } from '../types';

export default class EchartsRadarChartPlugin extends ChartPlugin<
export default class EchartsRadarChartPlugin extends EchartsChartPlugin<
EchartsRadarFormData,
EchartsRadarChartProps
> {
Expand All @@ -45,7 +46,7 @@ export default class EchartsRadarChartPlugin extends ChartPlugin<
buildQuery,
controlPanel,
loadChart: () => import('./EchartsRadar'),
metadata: new ChartMetadata({
metadata: {
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Expand All @@ -68,7 +69,7 @@ export default class EchartsRadarChartPlugin extends ChartPlugin<
t('ECharts'),
],
thumbnail,
}),
},
transformProps,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/
import { Behavior, ChartMetadata, ChartPlugin, t } from '@superset-ui/core';
import { Behavior, t } from '@superset-ui/core';
import transformProps from './transformProps';
import thumbnail from './images/thumbnail.png';
import controlPanel from './controlPanel';
import buildQuery from './buildQuery';
import example1 from './images/Sunburst1.png';
import example2 from './images/Sunburst2.png';
import { EchartsChartPlugin } from '../types';

export default class EchartsSunburstChartPlugin extends ChartPlugin {
export default class EchartsSunburstChartPlugin extends EchartsChartPlugin {
constructor() {
super({
buildQuery,
controlPanel,
loadChart: () => import('./EchartsSunburst'),
metadata: new ChartMetadata({
metadata: {
behaviors: [
Behavior.INTERACTIVE_CHART,
Behavior.DRILL_TO_DETAIL,
Expand All @@ -50,7 +51,7 @@ export default class EchartsSunburstChartPlugin extends ChartPlugin {
t('Proportional'),
],
thumbnail,
}),
},
transformProps,
});
}
Expand Down
Loading
Loading