Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating pie options panel to EUI #18579

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 132 additions & 0 deletions src/core_plugins/kbn_vislib_vis_types/public/components/pie_editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';

import {
EuiFieldNumber,
EuiForm,
EuiFormRow,
EuiSelect,
EuiSwitch,
} from '@elastic/eui';

import { EditorOptionsGroup } from 'ui/vis/editors/components';

export class PieOptionsTab extends Component {

setVisParam = (paramName, paramValue) => {
const params = _.cloneDeep(this.props.scope.vis.params);
_.set(params, paramName, paramValue);
this.props.stageEditorParams(params);
};

handleUpdate = (name, prop = 'value') => {
return (evt) => {
this.setVisParam(name, evt.target[prop]);
};
};

render() {
const params = this.props.scope.vis.params;
const collections = this.props.scope.vis.type.editorConfig.collections;

return (
<EuiForm>

<EditorOptionsGroup title="Pie settings">

<EuiFormRow
id="isDonut"
>
<EuiSwitch
label="Donut"
checked={params.isDonut}
onChange={this.handleUpdate('isDonut', 'checked')}
data-test-subj="pieEditorIsDonut"
/>
</EuiFormRow>

<EuiFormRow
id="addTooltip"
>
<EuiSwitch
label="Show tooltip per slice"
checked={params.addTooltip}
onChange={this.handleUpdate('addTooltip', 'checked')}
data-test-subj="pieEditorShowTooltip"
/>
</EuiFormRow>

<EuiFormRow
id="legendPosition"
label="Legend position"
>
<EuiSelect
options={collections.legendPositions}
value={params.legendPosition}
onChange={this.handleUpdate('legendPosition')}
data-test-subj="pieEditorLegendPosition"
/>
</EuiFormRow>

</EditorOptionsGroup>

<EditorOptionsGroup title="Label settings">

<EuiFormRow
id="showLabels"
>
<EuiSwitch
label="Show labels"
checked={params.labels.show}
onChange={this.handleUpdate('labels.show', 'checked')}
data-test-subj="pieEditorShowLabels"
/>
</EuiFormRow>

<EuiFormRow
id="showLastLevel"
>
<EuiSwitch
label="Show top level only"
checked={params.labels.last_level}
disabled={!params.labels.show}
onChange={this.handleUpdate('labels.last_level', 'checked')}
data-test-subj="pieEditorShowLastLevel"
/>
</EuiFormRow>

<EuiFormRow
id="showValues"
>
<EuiSwitch
label="Show values"
checked={params.labels.values}
disabled={!params.labels.show}
onChange={this.handleUpdate('labels.values', 'checked')}
data-test-subj="pieEditorShowValues"
/>
</EuiFormRow>

<EuiFormRow
id="truncateLabels"
label="Truncation limit"
>
<EuiFieldNumber
value={params.labels.truncate}
disabled={!params.labels.show}
onChange={this.handleUpdate('labels.truncate')}
data-test-subj="pieEditorTruncateLabels"
/>
</EuiFormRow>

</EditorOptionsGroup>
</EuiForm>
);
}
}

PieOptionsTab.propTypes = {
scope: PropTypes.object.isRequired,
stageEditorParams: PropTypes.func.isRequired
};
75 changes: 0 additions & 75 deletions src/core_plugins/kbn_vislib_vis_types/public/editors/pie.html

This file was deleted.

4 changes: 2 additions & 2 deletions src/core_plugins/kbn_vislib_vis_types/public/pie.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { Schemas } from 'ui/vis/editors/default/schemas';
import { CATEGORY } from 'ui/vis/vis_category';
import pieTemplate from './editors/pie.html';
import image from './images/icon-donut.svg';
import { PieOptionsTab } from './components/pie_editor';

export default function HistogramVisType(Private) {
const VisFactory = Private(VisFactoryProvider);
Expand Down Expand Up @@ -44,7 +44,7 @@ export default function HistogramVisType(Private) {
text: 'bottom',
}],
},
optionsTemplate: pieTemplate,
optionsTemplate: PieOptionsTab,
schemas: new Schemas([
{
group: 'metrics',
Expand Down