Skip to content

Commit

Permalink
more reverted changes
Browse files Browse the repository at this point in the history
  • Loading branch information
alliefeldman committed Nov 2, 2023
1 parent 99f5e65 commit d1be92d
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 109 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -364,4 +364,4 @@ Thanks for all your work!
- GitHub Actions Bot ([email protected])
- Jon Mease ([@jonmmease](https://github.com/jonmmease))
- Kanit Wongsuphasawat ([@kanitw](https://github.com/kanitw))
- Lukas Hermann ([@lsh](https://github.com/lsh))
- Lukas Hermann ([@lsh](https://github.com/lsh))
1 change: 0 additions & 1 deletion site/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ PLATFORMS
arm64-darwin-22
x86_64-darwin-19
x86_64-darwin-20
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
Expand Down
1 change: 0 additions & 1 deletion src/channeldef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
Channel,
COLOR,
COLUMN,
// CURSOR,
DESCRIPTION,
DETAIL,
ExtendedChannel,
Expand Down
2 changes: 1 addition & 1 deletion src/compile/mark/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function initMarkdef(originalMarkDef: MarkDef, encoding: Encoding<string>

return markDef;
}
// TODO: ALLIE

function cursor(markDef: MarkDef<Mark, SignalRef>, encoding: Encoding<string>, config: Config<SignalRef>) {
if (encoding.href || markDef.href || getMarkPropOrConfig('href', markDef, config)) {
return 'pointer';
Expand Down
2 changes: 1 addition & 1 deletion src/compile/selection/interval.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ const interval: SelectionCompiler<'interval'> = {

// Two brush marks ensure that fill colors and other aesthetic choices do
// not interefere with the core marks, but that the brushed region can still
// be interacted with (e.g., ging it around).
// be interacted with (e.g., dragging it around).
const {fill, fillOpacity, cursor, ...stroke} = selCmpt.mark;
const vgStroke = keys(stroke).reduce((def, k) => {
def[k] = [
Expand Down
6 changes: 0 additions & 6 deletions src/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Channel,
CHANNELS,
COLOR,
// CURSOR,
DESCRIPTION,
DETAIL,
FILL,
Expand Down Expand Up @@ -326,11 +325,6 @@ export interface Encoding<F extends Field> {
* __Note__: In aggregate plots, `order` field should be `aggregate`d to avoid creating additional aggregation grouping.
*/
order?: OrderFieldDef<F> | OrderFieldDef<F>[] | OrderValueDef | OrderOnlyDef;

/**
* TODO: Add description
*/
// cursor?: StringFieldDefWithCondition<F> | StringValueDefWithCondition<F> | StringFieldDef<F>[] | null;
}

export interface EncodingWithFacet<F extends Field> extends Encoding<F>, EncodingFacetMapping<F> {}
Expand Down
60 changes: 30 additions & 30 deletions src/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,10 @@ export interface SelectionParameter<T extends SelectionType = SelectionType> {
* __See also:__ [`init`](https://vega.github.io/vega-lite/docs/value.html) documentation.
*/
value?: T extends 'point'
? SelectionInit | SelectionInitMapping[]
: T extends 'interval'
? SelectionInitIntervalMapping
: never;
? SelectionInit | SelectionInitMapping[]
: T extends 'interval'
? SelectionInitIntervalMapping
: never;

/**
* When set, a selection is populated by input elements (also known as dynamic query widgets)
Expand All @@ -238,10 +238,10 @@ export interface SelectionParameter<T extends SelectionType = SelectionType> {
* __See also:__ [`bind`](https://vega.github.io/vega-lite/docs/bind.html) documentation.
*/
bind?: T extends 'point'
? Binding | Record<string, Binding> | LegendBinding
: T extends 'interval'
? 'scales'
: never;
? Binding | Record<string, Binding> | LegendBinding
: T extends 'interval'
? 'scales'
: never;
}

export type TopLevelSelectionParameter = SelectionParameter & {
Expand All @@ -254,29 +254,29 @@ export type TopLevelSelectionParameter = SelectionParameter & {

export type ParameterExtent =
| {
/**
* The name of a parameter.
*/
param: ParameterName;

/**
* If a selection parameter is specified, the field name to extract selected values for
* when the selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings.
*/
field?: FieldName;
}
/**
* The name of a parameter.
*/
param: ParameterName;

/**
* If a selection parameter is specified, the field name to extract selected values for
* when the selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings.
*/
field?: FieldName;
}
| {
/**
* The name of a parameter.
*/
param: ParameterName;

/**
* If a selection parameter is specified, the encoding channel to extract selected values for
* when a selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings.
*/
encoding?: SingleDefUnitChannel;
};
/**
* The name of a parameter.
*/
param: ParameterName;

/**
* If a selection parameter is specified, the encoding channel to extract selected values for
* when a selection is [projected](https://vega.github.io/vega-lite/docs/selection.html#project) over multiple fields or encodings.
*/
encoding?: SingleDefUnitChannel;
};

export type PointSelectionConfigWithoutType = Omit<PointSelectionConfig, 'type'>;

Expand Down
2 changes: 1 addition & 1 deletion src/spec/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export interface BaseViewBackground<ES extends ExprRef | SignalRef>
stroke?: Color | null | ES;

/**
* The cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used.
* The mouse cursor used over the view. Any valid [CSS cursor type](https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#Values) can be used.
*/
cursor?: Cursor;
}
Expand Down
108 changes: 41 additions & 67 deletions test-runtime/index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
<!doctype html>
<html>

<head>
<script src="/node_modules/vega/build/vega.js"></script>
<script src="/build/vega-lite.js"></script>
</head>

<body>
<div id="vis"></div>
<head>
<script src="/node_modules/vega/build/vega.js"></script>
<script src="/build/vega-lite.js"></script>
</head>
<body>
<div id="vis"></div>

<script type="text/javascript">
// global
var view = null;

function embed(vlSpec) {
if (view) {
view.finalize();
}

const vgSpec = vegaLite.compile(vlSpec).spec;
view = new vega.View(vega.parse(vgSpec)).renderer('svg').initialize('#vis').run();
Expand All @@ -31,19 +38,18 @@
);
}

target.dispatchEvent(
new PointerEvent('pointermove', { ...opts, clientX: opts.clientX + 5, clientY: opts.clientY + 5 })
);
}
function mark(id, parent) {
return document.querySelector((parent ? `g.${parent} ` : '') + `g.mark-symbol.role-mark path:nth-child(${id})`);
}

function mark(id, parent) {
return document.querySelector((parent ? `g.${parent} ` : '') + `g.mark-symbol.role-mark path:nth-child(${id})`);
}
function coords(el) {
const rect = el.getBoundingClientRect();
return [Math.ceil(rect.left + rect.width / 2), Math.ceil(rect.top + rect.height / 2)];
}

function coords(el) {
const rect = el.getBoundingClientRect();
return [Math.ceil(rect.left + rect.width / 2), Math.ceil(rect.top + rect.height / 2)];
}
function brushOrEl(el, parent, _) {
return !_ ? el : document.querySelector((parent ? `g.${parent} ` : '') + 'g.sel_brush > path');
}

function click(el, evt) {
pointerEvt('pointerdown', el, evt);
Expand All @@ -61,54 +67,22 @@
return (await view.runAsync()).data('sel_store');
}

async function brush(id0, id1, parent, targetBrush) {
const el0 = mark(id0, parent);
const el1 = mark(id1, parent);
const [mdX, mdY] = coords(el0);
const [muX, muY] = coords(el1);
pointerEvt('pointerdown', brushOrEl(el0, parent, targetBrush), { clientX: mdX, clientY: mdY });
pointerEvt('pointerup', window, { clientX: muX, clientY: muY });
return (await view.runAsync()).data('sel_store');
}

async function pt(id, parent, shiftKey) {
const el = mark(id, parent);
const [clientX, clientY] = coords(el);
click(el, { clientX, clientY, shiftKey });
return (await view.runAsync()).data('sel_store');
}

async function clear(id, parent, shiftKey) {
const bg = document.querySelector((parent ? `g.${parent} ` : '') + 'path.background');
const el = mark(id, parent);
let [clientX, clientY] = coords(el);
clientX += 10;
clientY -= 10;
click(bg, { clientX, clientY, shiftKey });
return (await view.runAsync()).data('sel_store');
}

async function zoom(id, delta, parent, targetBrush) {
const el = mark(id, parent);
const [clientX, clientY] = coords(el);
pointerEvt('wheel', brushOrEl(el, parent, targetBrush), {
clientX,
clientY,
deltaX: delta,
deltaY: delta,
deltaZ: delta
});
pointerEvt('wheel', brushOrEl(el, parent, targetBrush), {
clientX,
clientY,
deltaX: Math.sign(delta),
deltaY: Math.sign(delta),
deltaZ: Math.sign(delta)
});
return (await view.runAsync()).data('sel_store');
}
</script>
</body>
async function pt(id, parent, shiftKey) {
const el = mark(id, parent);
const [clientX, clientY] = coords(el);
click(el, {clientX, clientY, shiftKey});
return (await view.runAsync()).data('sel_store');
}

async function clear(id, parent, shiftKey) {
const bg = document.querySelector((parent ? `g.${parent} ` : '') + 'path.background');
const el = mark(id, parent);
let [clientX, clientY] = coords(el);
clientX += 10;
clientY -= 10;
click(bg, {clientX, clientY, shiftKey});
return (await view.runAsync()).data('sel_store');
}

async function zoom(id, delta, parent, targetBrush) {
const el = mark(id, parent);
Expand Down

0 comments on commit d1be92d

Please sign in to comment.