mirror of https://github.com/apache/superset.git
remove backend logic for wordcloud (#5753)
This commit is contained in:
parent
8af3e1f3a1
commit
9f2b502eb6
|
@ -106,7 +106,7 @@ const vizMap = {
|
|||
[VIZ_TYPES.country_map]: () =>
|
||||
loadVis(import(/* webpackChunkName: "country_map" */ './country_map.js')),
|
||||
[VIZ_TYPES.word_cloud]: () =>
|
||||
loadVis(import(/* webpackChunkName: "word_cloud" */ './word_cloud.js')),
|
||||
loadVis(import(/* webpackChunkName: "word_cloud" */ './wordcloud/WordCloud.js')),
|
||||
[VIZ_TYPES.world_map]: () =>
|
||||
loadVis(import(/* webpackChunkName: "world_map" */ './world_map.js')),
|
||||
[VIZ_TYPES.dual_line]: loadNvd3,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import d3 from 'd3';
|
||||
import PropTypes from 'prop-types';
|
||||
import cloudLayout from 'd3-cloud';
|
||||
import { getColorFromScheme } from '../modules/colors';
|
||||
import { getColorFromScheme } from '../../modules/colors';
|
||||
|
||||
const ROTATION = {
|
||||
square: () => Math.floor((Math.random() * 2)) * 90,
|
||||
|
@ -78,8 +78,23 @@ function wordCloud(element, props) {
|
|||
|
||||
wordCloud.propTypes = propTypes;
|
||||
|
||||
function transform(data, formData) {
|
||||
const {
|
||||
metric,
|
||||
series,
|
||||
} = formData;
|
||||
|
||||
const transformedData = data.map(datum => ({
|
||||
text: datum[series],
|
||||
size: datum[metric],
|
||||
}));
|
||||
|
||||
return transformedData;
|
||||
}
|
||||
|
||||
function adaptor(slice, payload) {
|
||||
const { selector, formData } = slice;
|
||||
|
||||
const {
|
||||
rotation,
|
||||
size_to: sizeTo,
|
||||
|
@ -88,8 +103,10 @@ function adaptor(slice, payload) {
|
|||
} = formData;
|
||||
const element = document.querySelector(selector);
|
||||
|
||||
const data = transform(payload.data, formData);
|
||||
|
||||
return wordCloud(element, {
|
||||
data: payload.data,
|
||||
data,
|
||||
width: slice.width(),
|
||||
height: slice.height(),
|
||||
rotation,
|
|
@ -473,7 +473,7 @@ class BaseViz(object):
|
|||
return df.to_csv(index=include_index, **config.get('CSV_EXPORT'))
|
||||
|
||||
def get_data(self, df):
|
||||
return []
|
||||
return self.get_df().to_dict(orient='records')
|
||||
|
||||
@property
|
||||
def json_data(self):
|
||||
|
@ -730,14 +730,6 @@ class WordCloudViz(BaseViz):
|
|||
d['groupby'] = [self.form_data.get('series')]
|
||||
return d
|
||||
|
||||
def get_data(self, df):
|
||||
fd = self.form_data
|
||||
# Ordering the columns
|
||||
df = df[[fd.get('series'), self.metric_labels[0]]]
|
||||
# Labeling the columns for uniform json schema
|
||||
df.columns = ['text', 'size']
|
||||
return df.to_dict(orient='records')
|
||||
|
||||
|
||||
class TreemapViz(BaseViz):
|
||||
|
||||
|
|
Loading…
Reference in New Issue