Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private onSort(channel: 'x' | 'y') {
// TODO: really take `sort` as input instead of toggling like this
const {spec, onSort} = this.props;
const channelDef = spec.encoding[channel];
if (isFieldDef(channelDef)) {
const sort = channelDef.sort === 'descending' ? undefined : 'descending';
onSort(channel, sort);
}
}function resultPlotSpecModifyFieldReducer(encoding: EncodingWithFacet, action: ResultModifyAction) {
const {channel, prop, value} = action.payload;
const channelDef = encoding[channel];
if (!channelDef) {
console.error(`${action.type} no working for channel ${channel} without field.`);
} else if (isArray(channelDef)) {
console.error(`${action.type} not supported for detail and order`);
return encoding;
} else if (!isFieldDef(channelDef)) {
console.error(`${action.type} not supported for detail and order`);
return encoding;
}
const fieldDef = encoding[channel] as FieldDef;
switch (action.type) {
case RESULT_MODIFY_FIELD_PROP:
return {
...encoding,
[channel]: modifyFieldProp(fieldDef, prop, value)
};
case RESULT_MODIFY_NESTED_FIELD_PROP: {
const {nestedProp} = action.payload;
return {
...encoding,
[channel]: modifyNestedFieldProp(fieldDef, prop, nestedProp, value)private renderSortButton(channel: 'x' | 'y') {
const {spec} = this.props;
const channelDef = spec.encoding[channel];
if (isFieldDef(channelDef) && isDiscrete(channelDef)) {
return <i title="Sort">;
}
return undefined;
}
</i>