Skip to content

Commit

Permalink
only remap x/y to long/lat for default projection, not specified ones
Browse files Browse the repository at this point in the history
  • Loading branch information
arvind committed Jan 19, 2022
1 parent 9a10739 commit 301d7c0
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/compile/selection/interval.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {isObject, NewSignal, OnEvent, SignalValue, Stream} from 'vega';
import {array, stringValue} from 'vega-util';
import {SelectionCompiler, SelectionComponent, STORE, TUPLE, unitName} from '.';
import {LATITUDE, LONGITUDE, ScaleChannel, X, Y} from '../../channel';
import {GeoPositionChannel, LATITUDE, LONGITUDE, ScaleChannel, X, Y} from '../../channel';
import {FieldName} from '../../channeldef';
import {warn} from '../../log';
import {hasContinuousDomain} from '../../scale';
Expand Down Expand Up @@ -29,7 +29,7 @@ const interval: SelectionCompiler<'interval'> = {
parse: (model, selCmpt, selDef) => {
const type = model.hasProjection ? 'id' : 'scaled';
const cfg = duplicate(model.config.selection.interval);
const def: IntervalSelectionConfigWithField = {...cfg, ...(isObject(selDef.select) ? selDef.select : {})};
const def: IntervalSelectionConfigWithField = {...(isObject(selDef.select) ? selDef.select : {})};

selCmpt.interval = {
type,
Expand All @@ -39,11 +39,9 @@ const interval: SelectionCompiler<'interval'> = {
if (type === 'id') {
def.fields = [SELECTION_ID];

if (model.hasProjection) {
const x = def.encodings.indexOf('x');
const y = def.encodings.indexOf('y');
if (x >= 0) def.encodings[x] = LONGITUDE;
if (y >= 0) def.encodings[y] = LATITUDE;
// Remap default x/y projection
if (model.hasProjection && !def.encodings) {
def.encodings = selDef.value ? (keys(selDef.value) as GeoPositionChannel[]) : [LONGITUDE, LATITUDE];
}

selDef.select = {type: 'interval', ...def};
Expand Down

0 comments on commit 301d7c0

Please sign in to comment.