Skip to content

Commit

Permalink
in legend use the color in the middle of scale not from the first point
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Jun 17, 2021
1 parent a2a66e7 commit 69f91e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/legend/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,14 @@ module.exports = function style(s, gd, legend) {

p.style('stroke-width', w + 'px');

var mcc;
if('mc' in d0) {
mcc = Drawing.tryColorscale(marker, '')(d0.mc);
var mcc = d0.mcc;
if(!legend._inHover && 'mc' in d0) {
// not in unified hover but
// for legend use the color in the middle of scale
var cOpts = extractOpts(marker);
var mid = cOpts.mid;
if(mid === undefined) mid = (cOpts.max + cOpts.min) / 2;
mcc = Drawing.tryColorscale(marker, '')(mid);
}
var fillColor = mcc || d0.mc || marker.color;

Expand Down
Binary file modified test/image/baselines/pattern_with_colorscale.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 69f91e2

Please sign in to comment.