Skip to content

Commit c7fb365

Browse files
committed
Introduce createFillPattern
git-svn-id: https://subversion.gsi.de/dabc/trunk/plugins/root/js@2811 bcbf6573-9a26-0410-9ebc-ce4ab7aade96
1 parent b550ede commit c7fb365

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

scripts/JSRootPainter.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,8 @@
972972

973973
JSROOT.TObjectPainter.prototype.createFillPattern = function(attfill, pattern, color) {
974974

975-
if (pattern == null) pattern = attfill['fFillStyle'];
976-
if (color == null) color = attfill['fFillColor'];
975+
if ((pattern==null) && attfill) pattern = attfill['fFillStyle'];
976+
if ((color==null) && attfill) color = attfill['fFillColor'];
977977

978978
var fill = { color: "none" };
979979
fill.SetFill = function(selection) {
@@ -983,13 +983,20 @@
983983
}
984984
fill.func = fill.SetFill.bind(fill);
985985

986-
if ((pattern == 0) || ((pattern >= 4000) && (pattern <= 4100))) return fill;
987-
988-
fill.color = JSROOT.Painter.root_colors[color];
986+
if (typeof attfill == 'string') {
987+
fill.color = attfill;
988+
return fill;
989+
}
990+
991+
992+
if ((pattern == 0) || (color==0) || ((pattern >= 4000) && (pattern <= 4100))) return fill;
989993

990994
var svg = this.svg_canvas(true);
991995

992-
if ((pattern < 3000) || (pattern>3025) || svg.empty()) return fill;
996+
if ((pattern < 3000) || (pattern>3025) || svg.empty()) {
997+
fill.color = JSROOT.Painter.root_colors[color];
998+
return fill;
999+
}
9931000

9941001
var id = "pat_" + pattern + "_" + color;
9951002

@@ -1363,7 +1370,7 @@
13631370
h -= (tm + bm);
13641371
}
13651372
if (framecolor == null)
1366-
framecolor = this.createFillPattern(null, 1, 0);
1373+
framecolor = this.createFillPattern('white');
13671374

13681375
// this is svg:g object - container for every other items belonging to frame
13691376
var frame_g = this.svg_pad(true).select(".root_frame");
@@ -2662,7 +2669,7 @@
26622669
if (this.pad && 'fFillColor' in this.pad)
26632670
fill = this.createFillPattern(this.pad);
26642671
else
2665-
fill = this.createFillPattern(null, 1, 0);
2672+
fill = this.createFillPattern('white');
26662673

26672674
render_to.css("background-color", fill.color);
26682675

@@ -2699,9 +2706,7 @@
26992706
var h = Math.round(this.pad['fAbsHNDC'] * height);
27002707
y -= h;
27012708

2702-
var fillcolor = JSROOT.Painter.root_colors[this.pad['fFillColor']];
2703-
if (this.pad['fFillStyle'] > 4000 && this.pad['fFillStyle'] < 4100)
2704-
fillcolor = 'none';
2709+
var fill = this.createFillPattern(this.pad);
27052710

27062711
var border_width = this.pad['fLineWidth'];
27072712
var border_color = JSROOT.Painter.root_colors[this.pad['fLineColor']];
@@ -2736,7 +2741,7 @@
27362741
.attr("y", 0)
27372742
.attr("width", w)
27382743
.attr("height", h)
2739-
.attr("fill", fillcolor)
2744+
.call(fill.func)
27402745
.style("stroke-width", border_width)
27412746
.style("stroke", border_color);
27422747
}
@@ -5078,7 +5083,7 @@
50785083

50795084
var draw_bins = this.CreateDrawBins(width, height);
50805085

5081-
if (this.fill.color!='none') {
5086+
if (this.fill.color != 'none') {
50825087

50835088
// histogram filling
50845089
var area = d3.svg.area()
@@ -6095,11 +6100,9 @@
60956100
h = (pave['fY2NDC'] - pave['fY1NDC']) * Number(svg.attr("height"));
60966101
}
60976102
y -= h;
6098-
var fillcolor = JSROOT.Painter.root_colors[pave['fFillColor']];
60996103
var lcolor = JSROOT.Painter.root_colors[pave['fLineColor']];
61006104
var lwidth = pave['fBorderSize'] ? pave['fBorderSize'] : 0;
6101-
if (pave['fFillStyle'] > 4000 && pave['fFillStyle'] < 4100)
6102-
fillcolor = 'none';
6105+
var fill = this.createFillPattern(pave);
61036106

61046107
var p = this.draw_g
61056108
.attr("x", x)
@@ -6113,7 +6116,7 @@
61136116
.attr("y", 0)
61146117
.attr("width", w)
61156118
.attr("height", h)
6116-
.attr("fill", fillcolor)
6119+
.call(fill.func)
61176120
.style("stroke-width", lwidth ? 1 : 0)
61186121
.style("stroke", lcolor);
61196122

0 commit comments

Comments
 (0)