In our project we are using vega-scale to generate heatmaps for numeric data. We managed to use a sequential scheme like viridis
with scale = vega.scale('sequential').interploate(vega.scheme('viridis'));
. I can't seem to figure out from the documentation how to differentiate between for example a linear and log scale. Also the previously mentioned vega-scale repository is archived now. The README.md file explains that everything has been moved to vega/vega for further development but i can't seem to find any documentation on how to use the scale api. Could someone point me to the documentation for it?
Asked
Active
Viewed 29 times
0

fxwiegand
- 1
- 2
1 Answers
0
Here you go - I think it has been moved here.
https://vega.github.io/vega/docs/api/extensibility/#scales
I'm really not familiar with the API but is this what you want?
var seq = vega.scale('sequential');
// sequential scale, using the plasma color palette
var scale1 = seq().interpolator(vega.scheme('viridis')).domain([0,10]);
document.getElementsByTagName("h1")[0].style.color = scale1(0);
document.getElementsByTagName("h1")[1].style.color = scale1(2);
document.getElementsByTagName("h1")[2].style.color = scale1(4);
document.getElementsByTagName("h1")[3].style.color = scale1(6);
document.getElementsByTagName("h1")[3].style.color = scale1(8);
document.getElementsByTagName("h1")[4].style.color = scale1(10);

Davide Bacci
- 16,647
- 3
- 10
- 36
-
Thank you! Could you maybe provide an example on how to use the scale API to create a log scale with the virirdis scheme? – fxwiegand Feb 06 '23 at 09:47
-
I haven't used the API so can't help. If you have a codepen with minimal example, then I'm happy to give it a go. – Davide Bacci Feb 06 '23 at 10:06
-
Yes just made one: https://codepen.io/fxwiegand/pen/ZEMYzKR It would be great if you could show me how to actually use an sequential scheme like viridis for the scale. – fxwiegand Feb 15 '23 at 11:06
-
I'll add an answer. – Davide Bacci Feb 15 '23 at 12:22