|
134 | 134 |
|
135 | 135 | /** Function that generates all root colors */ |
136 | 136 | JSROOT.Painter.root_colors = function() { |
137 | | - var colorMap = new Array('rgb(255, 255, 255)', 'rgb(0, 0, 0)', |
138 | | - 'rgb(255, 0, 0)', 'rgb(0, 255, 0)', 'rgb(0, 0, 255)', |
139 | | - 'rgb(255, 255, 0)', 'rgb(255, 0, 255)', 'rgb(0, 255, 255)', |
| 137 | + var colorMap = new Array('white', 'black', 'red', 'green', 'blue', |
| 138 | + 'rgb(255,255,0)', 'rgb(255,0,255)', 'rgb(0,255,255)', |
140 | 139 | 'rgb(89, 211, 84)', 'rgb(89, 84, 216)', 'rgb(254, 254, 254)', |
141 | | - 'rgb(191, 181, 173)', 'rgb(76, 76, 76)', 'rgb(102, 102, 102)', |
142 | | - 'rgb(127, 127, 127)', 'rgb(153, 153, 153)', 'rgb(178, 178, 178)', |
143 | | - 'rgb(204, 204, 204)', 'rgb(229, 229, 229)', 'rgb(242, 242, 242)', |
144 | | - 'rgb(204, 198, 170)', 'rgb(204, 198, 170)', 'rgb(193, 191, 168)', |
145 | | - 'rgb(186, 181, 163)', 'rgb(178, 165, 150)', 'rgb(183, 163, 155)', |
146 | | - 'rgb(173, 153, 140)', 'rgb(155, 142, 130)', 'rgb(135, 102, 86)', |
147 | | - 'rgb(175, 206, 198)', 'rgb(132, 193, 163)', 'rgb(137, 168, 160)', |
148 | | - 'rgb(130, 158, 140)', 'rgb(173, 188, 198)', 'rgb(122, 142, 153)', |
149 | | - 'rgb(117, 137, 145)', 'rgb(104, 130, 150)', 'rgb(109, 122, 132)', |
150 | | - 'rgb(124, 153, 209)', 'rgb(127, 127, 155)', 'rgb(170, 165, 191)', |
151 | | - 'rgb(211, 206, 135)', 'rgb(221, 186, 135)', 'rgb(188, 158, 130)', |
152 | | - 'rgb(198, 153, 124)', 'rgb(191, 130, 119)', 'rgb(206, 94, 96)', |
153 | | - 'rgb(170, 142, 147)', 'rgb(165, 119, 122)', 'rgb(147, 104, 112)', |
154 | | - 'rgb(211, 89, 84)'); |
| 140 | + 'rgb(191,181, 173)', 'rgb(76, 76, 76)', 'rgb(102, 102, 102)', |
| 141 | + 'rgb(127,127, 127)', 'rgb(153, 153, 153)', 'rgb(178, 178, 178)', |
| 142 | + 'rgb(204,204, 204)', 'rgb(229, 229, 229)', 'rgb(242, 242, 242)', |
| 143 | + 'rgb(204,198, 170)', 'rgb(204, 198, 170)', 'rgb(193, 191, 168)', |
| 144 | + 'rgb(186,181, 163)', 'rgb(178, 165, 150)', 'rgb(183, 163, 155)', |
| 145 | + 'rgb(173,153, 140)', 'rgb(155, 142, 130)', 'rgb(135, 102, 86)', |
| 146 | + 'rgb(175,206, 198)', 'rgb(132, 193, 163)', 'rgb(137, 168, 160)', |
| 147 | + 'rgb(130,158, 140)', 'rgb(173, 188, 198)', 'rgb(122, 142, 153)', |
| 148 | + 'rgb(117,137, 145)', 'rgb(104, 130, 150)', 'rgb(109, 122, 132)', |
| 149 | + 'rgb(124,153, 209)', 'rgb(127, 127, 155)', 'rgb(170, 165, 191)', |
| 150 | + 'rgb(211,206, 135)', 'rgb(221, 186, 135)', 'rgb(188, 158, 130)', |
| 151 | + 'rgb(198,153, 124)', 'rgb(191, 130, 119)', 'rgb(206, 94, 96)', |
| 152 | + 'rgb(170,142, 147)', 'rgb(165, 119, 122)', 'rgb(147, 104, 112)', |
| 153 | + 'rgb(211,89, 84)'); |
155 | 154 |
|
156 | 155 | var circleColors = [ 632, 416, 600, 400, 616, 432 ]; |
157 | 156 |
|
158 | 157 | var rectangleColors = [ 800, 820, 840, 860, 880, 900 ]; |
159 | 158 |
|
160 | 159 | var set1 = [ 255, 204, 204, 255, 153, 153, 204, 153, 153, 255, 102, 102, |
161 | 160 | 204, 102, 102, 153, 102, 102, 255, 51, 51, 204, 51, 51, 153, 51, |
162 | | - 51, 102, 51, 51, 255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, 51, 0, |
163 | | - 0 ]; |
| 161 | + 51, 102, 51, 51, 255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, 51, 0, 0 ]; |
164 | 162 | var set2 = [ 204, 255, 204, 153, 255, 153, 153, 204, 153, 102, 255, 102, |
165 | 163 | 102, 204, 102, 102, 153, 102, 51, 255, 51, 51, 204, 51, 51, 153, |
166 | | - 51, 51, 102, 51, 0, 255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, 51, |
167 | | - 0 ]; |
| 164 | + 51, 51, 102, 51, 0, 255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, 51, 0 ]; |
168 | 165 | var set3 = [ 204, 204, 255, 153, 153, 255, 153, 153, 204, 102, 102, 255, |
169 | 166 | 102, 102, 204, 102, 102, 153, 51, 51, 255, 51, 51, 204, 51, 51, |
170 | | - 153, 51, 51, 102, 0, 0, 255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, |
171 | | - 51 ]; |
| 167 | + 153, 51, 51, 102, 0, 0, 255, 0, 0, 204, 0, 0, 153, 0, 0, 102, 0, 0, 51 ]; |
172 | 168 | var set4 = [ 255, 255, 204, 255, 255, 153, 204, 204, 153, 255, 255, 102, |
173 | 169 | 204, 204, 102, 153, 153, 102, 255, 255, 51, 204, 204, 51, 153, 153, |
174 | | - 51, 102, 102, 51, 255, 255, 0, 204, 204, 0, 153, 153, 0, 102, 102, |
175 | | - 0, 51, 51, 0 ]; |
| 170 | + 51, 102, 102, 51, 255, 255, 0, 204, 204, 0, 153, 153, 0, 102, 102, 0, 51, 51, 0 ]; |
176 | 171 | var set5 = [ 255, 204, 255, 255, 153, 255, 204, 153, 204, 255, 102, 255, |
177 | 172 | 204, 102, 204, 153, 102, 153, 255, 51, 255, 204, 51, 204, 153, 51, |
178 | | - 153, 102, 51, 102, 255, 0, 255, 204, 0, 204, 153, 0, 153, 102, 0, |
179 | | - 102, 51, 0, 51 ]; |
| 173 | + 153, 102, 51, 102, 255, 0, 255, 204, 0, 204, 153, 0, 153, 102, 0, 102, 51, 0, 51 ]; |
180 | 174 | var set6 = [ 204, 255, 255, 153, 255, 255, 153, 204, 204, 102, 255, 255, |
181 | | - 102, 204, 204, 102, 153, 153, 51, 255, 255, 51, 204, 204, 51, 153, |
182 | | - 153, 51, 102, 102, 0, 255, 255, 0, 204, 204, 0, 153, 153, 0, 102, |
183 | | - 102, 0, 51, 51 ]; |
| 175 | + 102, 204, 204, 102, 153, 153, 51, 255, 255, 51, 204, 204, 51, 153, |
| 176 | + 153, 51, 102, 102, 0, 255, 255, 0, 204, 204, 0, 153, 153, 0, 102, 102, 0, 51, 51 ]; |
184 | 177 |
|
185 | 178 | var circleSets = new Array(set1, set2, set3, set4, set5, set6); |
186 | 179 |
|
|
217 | 210 |
|
218 | 211 | var rectSets = new Array(set7, set8, set9, set10, set11, set12); |
219 | 212 |
|
220 | | - /* |
221 | | - * Define circle colors |
222 | | - */ |
223 | 213 | for (var i = 0; i < 6; i++) { |
224 | 214 | for (var j = 0; j < 15; j++) { |
225 | 215 | var colorn = circleColors[i] + j - 10; |
226 | | - colorMap[colorn] = 'rgb(' + circleSets[i][3 * j] + ', ' |
227 | | - + circleSets[i][3 * j + 1] + ', ' + circleSets[i][3 * j + 2] + ')'; |
| 216 | + colorMap[colorn] = 'rgb(' + circleSets[i][3 * j] + ',' + circleSets[i][3 * j + 1] + ',' + circleSets[i][3 * j + 2] + ')'; |
228 | 217 | colorn = rectangleColors[i] + j - 9; |
229 | | - colorMap[colorn] = 'rgb(' + rectSets[i][3 * j] + ', ' |
230 | | - + rectSets[i][3 * j + 1] + ', ' + rectSets[i][3 * j + 2] + ')'; |
| 218 | + colorMap[colorn] = 'rgb(' + rectSets[i][3 * j] + ',' + rectSets[i][3 * j + 1] + ',' + rectSets[i][3 * j + 2] + ')'; |
231 | 219 | } |
232 | 220 | } |
233 | 221 | return colorMap; |
|
243 | 231 | var num = col.fNumber; |
244 | 232 | if ((num<0) || (num>4096)) continue; |
245 | 233 |
|
246 | | - var rgb = "rgb(" + (col.fRed*255).toFixed(0) + ", " + (col.fGreen*255).toFixed(0) + ", " + (col.fBlue*255).toFixed(0) + ")"; |
| 234 | + var rgb = "rgb(" + (col.fRed*255).toFixed(0) + "," + (col.fGreen*255).toFixed(0) + "," + (col.fBlue*255).toFixed(0) + ")"; |
| 235 | + |
| 236 | + if (rgb == 'rgb(255,255,255)') rgb = 'white'; |
247 | 237 |
|
248 | 238 | while (num>JSROOT.Painter.root_colors.length) |
249 | 239 | JSROOT.Painter.root_colors.push(rgb); |
250 | 240 |
|
251 | 241 | if (JSROOT.Painter.root_colors[num] != rgb) { |
252 | | - // console.log("Replace color "+ num + " " + rgb); |
253 | 242 | JSROOT.Painter.root_colors[num] = rgb; |
254 | 243 | } |
255 | 244 | } |
|
988 | 977 | return fill; |
989 | 978 | } |
990 | 979 |
|
991 | | - |
992 | | - if ((pattern == 0) || (color==0) || ((pattern >= 4000) && (pattern <= 4100))) return fill; |
| 980 | + if ((pattern < 1001) || ((pattern >= 4000) && (pattern <= 4100))) return fill; |
| 981 | + |
| 982 | + fill.color = JSROOT.Painter.root_colors[color]; |
993 | 983 |
|
994 | 984 | var svg = this.svg_canvas(true); |
995 | 985 |
|
996 | | - if ((pattern < 3000) || (pattern>3025) || svg.empty()) { |
997 | | - fill.color = JSROOT.Painter.root_colors[color]; |
998 | | - return fill; |
999 | | - } |
| 986 | + if ((pattern < 3000) || (pattern>3025) || svg.empty()) return fill; |
1000 | 987 |
|
1001 | 988 | var id = "pat_" + pattern + "_" + color; |
1002 | 989 |
|
|
1382 | 1369 |
|
1383 | 1370 | top_rect = frame_g.append("svg:rect"); |
1384 | 1371 |
|
1385 | | - // append for the moment two layers - for drawing and axis |
| 1372 | + // append for the moment three layers - for drawing and axis |
| 1373 | + frame_g.append('svg:g').attr('class','grid_layer'); |
1386 | 1374 | frame_g.append('svg:g').attr('class','main_layer'); |
1387 | 1375 | frame_g.append('svg:g').attr('class','axis_layer'); |
1388 | 1376 | } else { |
|
1571 | 1559 | if ((this.tf1['fLineColor'] == 0) || (this.tf1['fLineWidth'] == 0)) linecolor = "none"; |
1572 | 1560 |
|
1573 | 1561 | var fill = this.createFillPattern(this.tf1); |
| 1562 | + if (fill.color == 'white') fill.color = 'none'; |
1574 | 1563 |
|
1575 | 1564 | var line = d3.svg.line() |
1576 | 1565 | .x(function(d) { return Math.round(x(d.x)); }) |
|
1606 | 1595 | .attr("cx", function(d) { return x(d.x); }) |
1607 | 1596 | .attr("cy", function(d) { return y(d.y); }) |
1608 | 1597 | .attr("r", 4) |
1609 | | - .attr("opacity", 0) |
| 1598 | + .style("opacity", 0) |
1610 | 1599 | .append("svg:title") |
1611 | 1600 | .text( function(d) { return "x = " + d.x.toPrecision(4) + " \ny = " + d.y.toPrecision(4); }); |
1612 | 1601 | } |
|
1816 | 1805 |
|
1817 | 1806 | this.exclusionGraph = true; |
1818 | 1807 |
|
1819 | | - var ec, ff = 1; |
1820 | | - |
1821 | 1808 | var normx, normy; |
1822 | 1809 | var n = this.graph['fNpoints']; |
1823 | 1810 | var glw = this.graph['fLineWidth'], |
|
1831 | 1818 | if (glw > 32767) glw = 65536 - glw; |
1832 | 1819 | this.bins_lw = glw % 100; // line width |
1833 | 1820 | if (this.bins_lw > 0) this.optionLine = 1; |
1834 | | - ec = JSROOT.Painter.root_colors[this.graph['fFillColor']]; |
1835 | | - ec = ec.replace('rgb', 'rgba'); |
1836 | | - ec = ec.replace(')', ', 0.20)'); |
1837 | 1821 |
|
1838 | 1822 | var a, i, j, nf, wk = (glw / 100) * 0.005; |
1839 | 1823 | if (this.graph['fLineWidth'] > 32767) wk *= -1; |
|
2032 | 2016 |
|
2033 | 2017 | this.excl = d3.range(nf).map(function(p) { return { x : xf[p], y : yf[p] }; }); |
2034 | 2018 |
|
2035 | | - this.excl_ec = ec; |
2036 | | - this.excl_ff = ff; |
| 2019 | + this.excl_ff = 1; |
2037 | 2020 |
|
2038 | 2021 | /* some clean-up */ |
2039 | 2022 | xo.splice(0, xo.length); |
|
2085 | 2068 |
|
2086 | 2069 | if (this.seriesType == 'bar') { |
2087 | 2070 | var fillcolor = JSROOT.Painter.root_colors[this.graph['fFillColor']]; |
2088 | | - if (typeof (fillcolor) == 'undefined') fillcolor = "rgb(204, 204, 204)"; |
| 2071 | + if (typeof (fillcolor) == 'undefined') fillcolor = "rgb(204,204,204)"; |
2089 | 2072 | /* filled bar graph */ |
2090 | 2073 | var xdom = this.main_painter().x.domain(); |
2091 | 2074 | var xfactor = xdom[1] - xdom[0]; |
|
2111 | 2094 | .attr("d", line(pthis.excl)) |
2112 | 2095 | .style("stroke", "none") |
2113 | 2096 | .style("stroke-width", pthis.excl_ff) |
2114 | | - .call(fill.func); |
| 2097 | + .call(fill.func) |
| 2098 | + .style('opacity', 0.75); |
2115 | 2099 | } |
2116 | 2100 |
|
2117 | 2101 | if (this.seriesType == 'line') { |
|
2148 | 2132 | .attr("cx", function(d) { return Math.round(x(d.x)); }) |
2149 | 2133 | .attr("cy", function(d) { return Math.round(y(d.y)); }) |
2150 | 2134 | .attr("r", 3) |
2151 | | - .attr("opacity", 0) |
| 2135 | + .style("opacity", 0) |
2152 | 2136 | .append("svg:title") |
2153 | 2137 | .text(TooltipText); |
2154 | 2138 | } |
|
3672 | 3656 | JSROOT.THistPainter.prototype.DrawGrids = function() { |
3673 | 3657 | // grid can only be drawn by first painter |
3674 | 3658 | if (!this.is_main_painter()) return; |
| 3659 | + |
| 3660 | + var layer = this.svg_frame(true).select(".grid_layer"); |
3675 | 3661 |
|
3676 | | - this.svg_frame(true).selectAll(".gridLine").remove(); |
| 3662 | + layer.selectAll(".xgrid").remove(); |
| 3663 | + layer.selectAll(".ygrid").remove(); |
3677 | 3664 | /* add a grid on x axis, if the option is set */ |
3678 | 3665 |
|
3679 | 3666 | // add a grid on x axis, if the option is set |
3680 | 3667 | if (this.options.Gridx) { |
3681 | 3668 |
|
3682 | 3669 | var h = Number(this.svg_frame(true).attr("height")); |
| 3670 | + |
| 3671 | + var xticks = this.x.ticks(this.x_nticks); |
3683 | 3672 |
|
3684 | | - this.svg_frame(true).selectAll("gridLine") |
3685 | | - .data(this.x.ticks(this.x_nticks)).enter() |
| 3673 | + layer.selectAll(".xgrid") |
| 3674 | + .data(xticks).enter() |
3686 | 3675 | .append("svg:line") |
3687 | | - .attr("class", "gridLine") |
| 3676 | + .attr("class", "xgrid") |
3688 | 3677 | .attr("x1", this.x) |
3689 | 3678 | .attr("y1", h) |
3690 | 3679 | .attr("x2", this.x) |
3691 | 3680 | .attr("y2",0) |
3692 | 3681 | .style("stroke", "black") |
3693 | | - .style("stroke-width", this.histo['fLineWidth']) |
| 3682 | + .style("stroke-width", 1) |
3694 | 3683 | .style("stroke-dasharray", JSROOT.Painter.root_line_styles[11]); |
3695 | 3684 | } |
3696 | 3685 |
|
3697 | 3686 | // add a grid on y axis, if the option is set |
3698 | 3687 | if (this.options.Gridy) { |
3699 | | - |
3700 | 3688 | var w = Number(this.svg_frame(true).attr("width")); |
3701 | 3689 |
|
3702 | | - this.svg_frame(true).selectAll("gridLine") |
3703 | | - .data(this.y.ticks(this.y_nticks)).enter() |
| 3690 | + var yticks = this.y.ticks(this.y_nticks); |
| 3691 | + |
| 3692 | + layer.selectAll('.ygrid') |
| 3693 | + .data(yticks).enter() |
3704 | 3694 | .append("svg:line") |
3705 | | - .attr("class", "gridLine") |
| 3695 | + .attr("class", "ygrid") |
3706 | 3696 | .attr("x1", 0) |
3707 | 3697 | .attr("y1", this.y) |
3708 | 3698 | .attr("x2", w) |
3709 | 3699 | .attr("y2", this.y) |
3710 | 3700 | .style("stroke", "black") |
3711 | | - .style("stroke-width", this.histo['fLineWidth']) |
| 3701 | + .style("stroke-width", 1) |
3712 | 3702 | .style("stroke-dasharray", JSROOT.Painter.root_line_styles[11]); |
3713 | 3703 | } |
3714 | 3704 | } |
|
4693 | 4683 | // from here we analyze object content |
4694 | 4684 | // therefore code will be moved |
4695 | 4685 | this.fill = this.createFillPattern(this.histo); |
| 4686 | + if (this.fill.color == 'white') this.fill.color = 'none'; |
4696 | 4687 |
|
4697 | 4688 | this.linecolor = JSROOT.Painter.root_colors[this.histo['fLineColor']]; |
4698 | 4689 | if (this.histo['fLineColor'] == 0) this.linecolor = '#4572A7'; |
|
5124 | 5115 | .attr("y1", function(d) { return Math.max(0, d.y); }) |
5125 | 5116 | .attr("x2", function(d) { return d.x + d.width / 2; }) |
5126 | 5117 | .attr("y2", function(d) { return height; }) |
5127 | | - .attr("opacity", 0) |
| 5118 | + .style("opacity", 0) |
5128 | 5119 | .style("stroke", "#4572A7") |
5129 | 5120 | .style("stroke-width", function(d) { return d.width; }) |
5130 | 5121 | .on('mouseover', function() { |
|
5172 | 5163 | // create painter and add it to canvas |
5173 | 5164 | var painter = new JSROOT.TH1Painter(histo); |
5174 | 5165 | painter.SetDivId(divid, 1); |
5175 | | - |
| 5166 | + |
5176 | 5167 | // here we deciding how histogram will look like and how will be shown |
5177 | 5168 | painter.options = painter.DecodeOptions(opt); |
5178 | 5169 |
|
|
0 commit comments