Skip to content

Commit

Permalink
feat(plugin-chart-word-cloud): allow minimum size (apache#487)
Browse files Browse the repository at this point in the history
* feat(plugin-chart-word-cloud): allow minimum size

* fix: type

* fix: test
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 26, 2021
1 parent caf9a40 commit 3364f0f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -34,7 +41,7 @@ export default function transformProps(chartProps: ChartProps): WordCloudProps {
: {
field: metricLabel,
scale: {
range: [0, sizeTo],
range: [sizeFrom, sizeTo],
zero: true,
},
type: 'quantitative',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export type LegacyWordCloudFormData = QueryFormData & {
colorScheme: string;
rotation?: RotationType;
series: string;
sizeFrom?: number;
sizeTo: number;
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('WordCloud tranformProps', () => {
fontSize: {
field: 'sum__num',
scale: {
range: [0, 70],
range: [10, 70],
zero: true,
},
type: 'quantitative',
Expand Down

0 comments on commit 3364f0f

Please sign in to comment.