Skip to content

Commit

Permalink
Merge pull request #2995 from kalletlak/fix-5853
Browse files Browse the repository at this point in the history
Study View: ignore case while applying filters on pie chart
  • Loading branch information
alisman authored Jan 17, 2020
2 parents 6ef31b7 + 6963c74 commit 86b72fa
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/pages/studyView/charts/pieChart/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ export default class PieChart extends React.Component<IPieChartProps, {}> implem
super(props);
}

@computed
get filters() {
const mappedValueSet = _.reduce(this.props.data, (acc, datum) => {
acc[datum.value.toLowerCase()] = datum.value;
return acc;
}, {} as { [id: string]: string });
return this.props.filters.map(filter => mappedValueSet[filter.toLowerCase()] || filter);
}

@autobind
private onUserSelection(filter: string) {
let filters = toJS(this.props.filters);
let filters = toJS(this.filters);
if (_.includes(filters, filter)) {
filters = _.filter(filters, obj => obj !== filter);
} else {
Expand Down Expand Up @@ -101,7 +110,7 @@ export default class PieChart extends React.Component<IPieChartProps, {}> implem
@computed
get fill() {
return (d: ClinicalDataCountSummary) => {
if (!_.isEmpty(this.props.filters) && !_.includes(this.props.filters, d.value)) {
if (!_.isEmpty(this.filters) && !_.includes(this.filters, d.value)) {
return DEFAULT_NA_COLOR;
}
return d.color;
Expand All @@ -111,7 +120,7 @@ export default class PieChart extends React.Component<IPieChartProps, {}> implem
@computed
get stroke() {
return (d: ClinicalDataCountSummary) => {
if (!_.isEmpty(this.props.filters) && _.includes(this.props.filters, d.value)) {
if (!_.isEmpty(this.filters) && _.includes(this.filters, d.value)) {
return "#cccccc";
}
return null;
Expand All @@ -121,7 +130,7 @@ export default class PieChart extends React.Component<IPieChartProps, {}> implem
@computed
get strokeWidth() {
return (d: ClinicalDataCountSummary) => {
if (!_.isEmpty(this.props.filters) && _.includes(this.props.filters, d.value)) {
if (!_.isEmpty(this.filters) && _.includes(this.filters, d.value)) {
return 3;
}
return 0;
Expand All @@ -131,7 +140,7 @@ export default class PieChart extends React.Component<IPieChartProps, {}> implem
@computed
get fillOpacity() {
return (d: ClinicalDataCountSummary) => {
if (!_.isEmpty(this.props.filters) && !_.includes(this.props.filters, d.value)) {
if (!_.isEmpty(this.filters) && !_.includes(this.filters, d.value)) {
return '0.5';
}
return 1;
Expand Down Expand Up @@ -255,7 +264,7 @@ export default class PieChart extends React.Component<IPieChartProps, {}> implem
labelDescription={this.props.labelDescription}
patientAttribute={this.props.patientAttribute}
showAddRemoveAllButtons={true}
filters={this.props.filters}
filters={this.filters}
highlightedRow={this.highlightedRow}
onUserSelection={this.props.onUserSelection}
/>)}
Expand Down

0 comments on commit 86b72fa

Please sign in to comment.