Skip to content

Commit

Permalink
Add viz thumbnails to viz_type select (#1794)
Browse files Browse the repository at this point in the history
* Add viz thumbnails to viz_type select

* Replace alt with value
  • Loading branch information
vera-liu authored Dec 7, 2016
1 parent 34d0dd9 commit a95cd71
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions superset/assets/javascripts/explorev2/components/SelectField.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ export default class SelectField extends React.Component {
this.props.onChange(this.props.name, optionValue);
}
}
renderOption(opt) {
if (this.props.name === 'viz_type') {
const url = `/static/assets/images/viz_thumbnails/${opt.value}.png`;
return (
<div>
<img className="viz-thumb-option" src={url} alt={opt.value} />
<span>{opt.value}</span>
</div>
);
}
return opt.label;
}
render() {
const options = this.props.choices.map((c) => ({ value: c[0], label: c[1] }));
if (this.props.freeForm) {
Expand All @@ -55,6 +67,7 @@ export default class SelectField extends React.Component {
value: this.props.value,
autosize: false,
onChange: this.onChange.bind(this),
optionRenderer: this.renderOption.bind(this),
};
// Tab, comma or Enter will trigger a new option created for FreeFormSelect
const selectWrap = this.props.freeForm ?
Expand Down

0 comments on commit a95cd71

Please sign in to comment.