1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
Description: Make flot to control legend backgrounds using SVG fill
Author: Marcos <markskayff@gmail.com>
Origin: upstream, https://patch-diff.githubusercontent.com/raw/flot/flot/pull/1709
Bug-Debian: https://bugs.debian.org/980294
Forwarded: not-needed
Last-Update: 2021-01-17
--- a/source/jquery.flot.legend.js
+++ b/source/jquery.flot.legend.js
@@ -11,7 +11,9 @@
container: null, // container (as jQuery object) to put legend in, null means default on top of graph
position: 'ne', // position of default legend container within plot
margin: 5, // distance from grid edge to default legend container within plot
- sorted: null // default to no legend sorting
+ sorted: null, // default to no legend sorting
+ backgroundColor: null,
+ backgroundOpacity: 0 // No background shows by default
}
};
@@ -154,6 +156,20 @@
options.legend.container.style.width = width + 'px';
options.legend.container.style.height = height + 'em';
}
+
+ // ----------------------------------------------------------------------------------------
+ // Control backgroundColor
+ // ----------------------------------------------------------------------------------------
+ if(options.legend.backgroundColor){
+ $('.legendLayer rect.background').css({
+ 'fill': options.legend.backgroundColor, // New SVG 2.0 spec, uses fill
+ 'background': options.legend.backgroundColor, // Back compau with SVG 1.1
+ });
+ }
+ // ----------------------------------------------------------------------------------------
+ // Control background-opacity
+ // ----------------------------------------------------------------------------------------
+ $('.legendLayer rect.background').css('opacity', options.legend.backgroundOpacity? options.legend.backgroundOpacity : 1);
}
// Generate html for a shape
|