Replies: 2 comments
-
Not so easy because quickdraw is a wrapper around draw. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Not a PR but I was thinking something like the following would work : https://github.com/neocarto/bertin/blob/main/src/quickdraw.js#L4 : if (Array.isArray(layers)) {
// The original color array
let cols = ["#66c2a5", "#fc8d62", "#8da0cb", "#e78ac3", "#a6d854", "#ffd92f", "#e5c494", "#b3b3b3"];
// Shuffle it so that succesive calls to quickdraw don't return them in same order
cols.sort(() => (Math.random() > 0.5) ? 1 : -1)
let myarray = layers.map((x, i) =>({
type: "layer",
geojson: x,
fill: cols[i % cols.length], // Use them in their new order, with repetition if more than cols.length layers
}));
return draw({ params: { margin: m, width: w }, layers: myarray });
} else {
... Well, this is a very low priority/low importance concern ^^ |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
When calling
quickdraw
with an array of layers (e.g. 3), sometimes several layers have the same color (e.g. 2 out of 3).Maybe when calling
quickdraw
you could compute the color to use inquickdraw
(to avoid having the same color used several times) rather than leaving this task to thesimple
function (https://github.com/neocarto/bertin/blob/main/src/layers/simple.js#L66) ?(at least when a reasonable number of layers, e.g. 8 or less, is used)
When trying to reproduce it in your @neocartocnrs/bertin-js-quickdraw-table2geo notebook I got 3 times the same color :
Beta Was this translation helpful? Give feedback.
All reactions