I have a dataset that shows the borehole yield for fractured aquifers in South Africa. Using the "yield_ls" column, my CARTO VL legend looks like this (notice how the 4th item should be the first).
const aquiferViz = new carto.Viz(`
color: ramp($yield_ls, teal)
strokeColor: rgba(0,0,0,0.3)
strokeWidth: 1
`);
I noticed that each legend item is assigned an ID column in the database ("sayld_id") starting from 6 to 10. Therefore if this database is ordered by the sayld_id ASC, then the yield_ls features go into a logical order. I tested this using the following SQL command in my CARTO dataset:
SELECT *
FROM fractured
ORDER BY sayld_id ASC
I then tried to do this when adding my the layer to a CARTO VL map using:
const fracturedSource = new carto.source.SQL(`
SELECT *
FROM fractured
ORDER BY sayld_id ASC
`);
But the legend remains the same as before. Is there a better way to correctly arrange the legend, or possibly move an item up or down in the legend order?