mirror of
https://github.com/apache/superset.git
synced 2026-04-23 01:55:09 +00:00
feat: Utility function to render chart tooltips (#27950)
This commit is contained in:
committed by
GitHub
parent
467e612533
commit
b549977f05
@@ -21,12 +21,9 @@ import {
|
||||
getNumberFormatter,
|
||||
supersetTheme,
|
||||
} from '@superset-ui/core';
|
||||
import transformProps, {
|
||||
formatFunnelLabel,
|
||||
} from '../../src/Funnel/transformProps';
|
||||
import transformProps, { parseParams } from '../../src/Funnel/transformProps';
|
||||
import {
|
||||
EchartsFunnelChartProps,
|
||||
EchartsFunnelLabelTypeType,
|
||||
PercentCalcType,
|
||||
} from '../../src/Funnel/types';
|
||||
|
||||
@@ -89,85 +86,40 @@ describe('formatFunnelLabel', () => {
|
||||
data: { firstStepPercent: 0.5, prevStepPercent: 0.85 },
|
||||
};
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
parseParams({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.Key,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
}),
|
||||
).toEqual('My Label');
|
||||
).toEqual(['My Label', '1.23k', '12.34%']);
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
parseParams({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.Value,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
}),
|
||||
).toEqual('1.23k');
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.Percent,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
}),
|
||||
).toEqual('12.34%');
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.Percent,
|
||||
percentCalculationType: PercentCalcType.FirstStep,
|
||||
}),
|
||||
).toEqual('50.00%');
|
||||
).toEqual(['My Label', '1.23k', '50.00%']);
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
parseParams({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.Percent,
|
||||
percentCalculationType: PercentCalcType.PreviousStep,
|
||||
}),
|
||||
).toEqual('85.00%');
|
||||
).toEqual(['My Label', '1.23k', '85.00%']);
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.KeyValue,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
}),
|
||||
).toEqual('My Label: 1.23k');
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.KeyPercent,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
}),
|
||||
).toEqual('My Label: 12.34%');
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
params,
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.KeyValuePercent,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
}),
|
||||
).toEqual('My Label: 1.23k (12.34%)');
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
parseParams({
|
||||
params: { ...params, name: '<NULL>' },
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.Key,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
}),
|
||||
).toEqual('<NULL>');
|
||||
).toEqual(['<NULL>', '1.23k', '12.34%']);
|
||||
expect(
|
||||
formatFunnelLabel({
|
||||
parseParams({
|
||||
params: { ...params, name: '<NULL>' },
|
||||
numberFormatter,
|
||||
labelType: EchartsFunnelLabelTypeType.Key,
|
||||
percentCalculationType: PercentCalcType.Total,
|
||||
sanitizeName: true,
|
||||
}),
|
||||
).toEqual('<NULL>');
|
||||
).toEqual(['<NULL>', '1.23k', '12.34%']);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user