Klaus Eckelt
Klaus Eckelt

Reputation: 685

Add marks on click

I would like to add marks with clicks into the Vega view.

For example, in this density plot I would like to set these vertical rules with clicks:

Density plot with three vertical rules Link to Editor

Is that possible?

Upvotes: 1

Views: 258

Answers (1)

Klaus Eckelt
Klaus Eckelt

Reputation: 685

It is possible: Triggers can be used to update the data: https://vega.github.io/vega/docs/triggers

In this example, points can be added by clicking into the Vega View:

enter image description here

Link to Editor. Important are the signal addMark that listens on clicks and the trigger that is added to the input data source_0. The signal passes the data as it is stored in the dataset.

Triggers can also be used to drag marks, as in this example that builds on the first:

enter image description here

Link to editor


Applied to the example of my initial question, the final spec looks like:

enter image description here

Link to Editor

Upvotes: 1

Related Questions