Skip to content

Commit

Permalink
fix(plugin-chart-word-cloud): make wordcloud take current formdata (a…
Browse files Browse the repository at this point in the history
…pache#428)

* fix: make wordcloud take current formdata

* docs: fix storybook
  • Loading branch information
kristw authored and zhaoyongjie committed Nov 24, 2021
1 parent 2800f9b commit 219df19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import React from 'react';
import { SuperChart } from '@superset-ui/chart';
import { SuperChart, getChartTransformPropsRegistry } from '@superset-ui/chart';
import { select, withKnobs } from '@storybook/addon-knobs';
import {
WordCloudChartPlugin,
LegacyWordCloudChartPlugin,
} from '@superset-ui/plugin-chart-word-cloud';
import transformProps from '@superset-ui/plugin-chart-word-cloud/lib/plugin/transformProps';
import data from './data';

new WordCloudChartPlugin().configure({ key: 'word-cloud2' }).register();
new LegacyWordCloudChartPlugin().configure({ key: 'legacy-word-cloud2' }).register();

// Enable the new WordCloud Props to show case its full features
// if the control panel is updated to be able to pass formData in the new format.
getChartTransformPropsRegistry().registerValue('word-cloud2', transformProps);

export default {
title: 'Chart Plugins|plugin-chart-word-cloud',
decorators: [withKnobs],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export default class WordCloud extends React.PureComponent<

cloudLayout()
.size([width, height])
.words(data)
// clone the data because cloudLayout mutates input
.words(data.map(d => ({ ...d })))
.padding(5)
.rotate(ROTATION[rotation] || ROTATION.flat)
.text(d => encoder.channels.text.getValueFromDatum(d))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { t } from '@superset-ui/translation';
import { ChartMetadata, ChartPlugin } from '@superset-ui/chart';
import buildQuery from './buildQuery';
import { WordCloudFormData } from '../types';
import transformProps from './transformProps';
import transformProps from '../legacyPlugin/transformProps';
import thumbnail from '../images/thumbnail.png';

const metadata = new ChartMetadata({
Expand Down

0 comments on commit 219df19

Please sign in to comment.