feat(plugin-chart-word-cloud): allow minimum size (#487)

* feat(plugin-chart-word-cloud): allow minimum size

* fix: type

* fix: test
This commit is contained in:
Krist Wongsuphasawat 2020-05-13 13:18:36 -07:00 committed by Yongjie Zhao
parent caf9a4000e
commit 3364f0f6da
3 changed files with 11 additions and 3 deletions

View File

@ -16,7 +16,14 @@ function getMetricLabel(metric: LegacyWordCloudFormData['metric']): string | und
export default function transformProps(chartProps: ChartProps): WordCloudProps {
const { width, height, formData, queryData } = chartProps;
const { colorScheme, metric, rotation, series, sizeTo } = formData as LegacyWordCloudFormData;
const {
colorScheme,
metric,
rotation,
series,
sizeFrom = 0,
sizeTo,
} = formData as LegacyWordCloudFormData;
const metricLabel = getMetricLabel(metric);
@ -34,7 +41,7 @@ export default function transformProps(chartProps: ChartProps): WordCloudProps {
: {
field: metricLabel,
scale: {
range: [0, sizeTo],
range: [sizeFrom, sizeTo],
zero: true,
},
type: 'quantitative',

View File

@ -5,5 +5,6 @@ export type LegacyWordCloudFormData = QueryFormData & {
colorScheme: string;
rotation?: RotationType;
series: string;
sizeFrom?: number;
sizeTo: number;
};

View File

@ -37,7 +37,7 @@ describe('WordCloud tranformProps', () => {
fontSize: {
field: 'sum__num',
scale: {
range: [0, 70],
range: [10, 70],
zero: true,
},
type: 'quantitative',