Vega: Allow signal value for axis scale property.

Created on 29 Jan 2019  路  4Comments  路  Source: vega/vega

Please add the feature request label if you agree that this is one. Doesn't seem like I can add it myself.

The example I used when chatting with @domoritz on slack is if I would like to change from a normal linear scale to a log scale in my plot, using a signal (in particular, one that is bound to a selection by the user).

The way that you can do this now is to change the scale transform of your data depending on a signal. You can also update domains and ranges with signals. But this doesn't update the axis associated with the scale.
There are multiple levels at which this could be achieved:

  • allow the type field of the scale to be updated with a signal
  • allow the scale field of the axis to be updated with a signal

The former might be difficult to write durably given the specific configuration of scales depending on their type, as @domoritz noted in our conversation. Hopefully this is less so with the latter, but I am not sure of this. Let me know if I can be of more help to outline a way forward for this, the broader goal being configurable plots via signals, including axes, legends, etc. Thank you.

enhancement

Most helpful comment

@eharkins Instead of changing scale type, consider using Vega's power scale ("pow") with exponent that changes with bound signal input. See example at:
https://groups.google.com/forum/#!topic/vega-js/1JdIFH6o9z4

All 4 comments

Thanks for the issue. I agree that this would be helpful. Binding the scale type to a signal is unlikely any time soon, as we use the scale type information to guide significant parts of the parsing and dataflow generation process. Changing the scale field of the axis (perhaps subject to some constraints) might be more feasible. I've added the enhancement label to track this going forward.

It could be interesting to consider certain scale type changes such as going from linear to log scales. In D3 scales the transformation is internally abstracted away. Unfortunately, the external API does not expose this property.

Yes, I'm wondering if Vega might provide a different abstraction over scales (i.e., continuous) that provides the necessary info for later dataflow generation, while enabling transformation (log, sqrt, etc) as a free variable that can be controlled by a signal. However, this could result in breaking changes so we'll have to do some design work first and then decide.

@eharkins Instead of changing scale type, consider using Vega's power scale ("pow") with exponent that changes with bound signal input. See example at:
https://groups.google.com/forum/#!topic/vega-js/1JdIFH6o9z4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinmickey picture kevinmickey  路  5Comments

donghaoren picture donghaoren  路  5Comments

malhotrachetan picture malhotrachetan  路  5Comments

rubjo picture rubjo  路  4Comments

divico picture divico  路  4Comments