Skip to content

Commit 69f91e2

Browse files
committed
in legend use the color in the middle of scale not from the first point
1 parent a2a66e7 commit 69f91e2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

Diff for: src/components/legend/style.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,14 @@ module.exports = function style(s, gd, legend) {
348348

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

351-
var mcc;
352-
if('mc' in d0) {
353-
mcc = Drawing.tryColorscale(marker, '')(d0.mc);
351+
var mcc = d0.mcc;
352+
if(!legend._inHover && 'mc' in d0) {
353+
// not in unified hover but
354+
// for legend use the color in the middle of scale
355+
var cOpts = extractOpts(marker);
356+
var mid = cOpts.mid;
357+
if(mid === undefined) mid = (cOpts.max + cOpts.min) / 2;
358+
mcc = Drawing.tryColorscale(marker, '')(mid);
354359
}
355360
var fillColor = mcc || d0.mc || marker.color;
356361

Diff for: test/image/baselines/pattern_with_colorscale.png

-39 Bytes
Loading

0 commit comments

Comments
 (0)