|
959 | 959 | svg_p['mainpainter'] = this; |
960 | 960 | } |
961 | 961 |
|
962 | | - JSROOT.TObjectPainter.prototype.createFillPattern = function(attfill, pattern, color) { |
| 962 | + JSROOT.TObjectPainter.prototype.createAttLine = function(attline) { |
| 963 | + |
| 964 | + var color = 0, _width = 0, style = 0; |
| 965 | + |
| 966 | + if (attline=='black') { color = 1; _width = 1; } else |
| 967 | + if (attline=='none') { _width = 0; } else |
| 968 | + if (typeof attline == 'object') { |
| 969 | + if ('fLineColor' in attline) color = attline['fLineColor']; |
| 970 | + if ('fLineWidth' in attline) _width = attline['fLineWidth']; |
| 971 | + if ('fLineStyle' in attline) style = attline['fLineStyle']; |
| 972 | + } |
| 973 | + |
| 974 | + var line = { |
| 975 | + color: JSROOT.Painter.root_colors[color], |
| 976 | + width: _width, |
| 977 | + dash: JSROOT.Painter.root_line_styles[style] |
| 978 | + }; |
| 979 | + |
| 980 | + if ((_width==0) || (color==0)) line.color = 'none'; |
| 981 | + |
| 982 | + line.SetLine = function(selection) { |
| 983 | + selection.style('stroke', this.color); |
| 984 | + if (this.color!='none') { |
| 985 | + selection.style('stroke-width', this.width); |
| 986 | + selection.style('stroke-dasharray', this.dash); |
| 987 | + } |
| 988 | + } |
| 989 | + line.func = line.SetLine.bind(line); |
| 990 | + |
| 991 | + return line; |
| 992 | + } |
| 993 | + |
| 994 | + JSROOT.TObjectPainter.prototype.createAttFill = function(attfill, pattern, color) { |
963 | 995 |
|
964 | 996 | if ((pattern==null) && attfill) pattern = attfill['fFillStyle']; |
965 | 997 | if ((color==null) && attfill) color = attfill['fFillColor']; |
|
1314 | 1346 | var tm = height * ndc.y1; |
1315 | 1347 | var bm = height * (1 - ndc.y2); |
1316 | 1348 |
|
1317 | | - var framecolor = null, bordermode = 0, bordersize = 0, linecolor = 'black', linestyle = 0, linewidth = 1; |
| 1349 | + var framecolor = this.createAttFill('white'), |
| 1350 | + lineatt = this.createAttLine('black'), |
| 1351 | + bordermode = 0, bordersize = 0; |
1318 | 1352 |
|
1319 | 1353 | if (this.tframe) { |
1320 | 1354 | bordermode = this.tframe['fBorderMode']; |
1321 | 1355 | bordersize = this.tframe['fBorderSize']; |
1322 | | - linecolor = JSROOT.Painter.root_colors[this.tframe['fLineColor']]; |
1323 | | - linestyle = this.tframe['fLineStyle']; |
1324 | | - linewidth = this.tframe['fLineWidth']; |
| 1356 | + lineatt = this.createAttLine(this.tframe); |
1325 | 1357 | if (root_pad) { |
1326 | 1358 | var xspan = width / Math.abs(root_pad['fX2'] - root_pad['fX1']); |
1327 | 1359 | var yspan = height / Math.abs(root_pad['fY2'] - root_pad['fY1']); |
|
1348 | 1380 | w -= (lm + rm); |
1349 | 1381 | h -= (tm + bm); |
1350 | 1382 | } |
1351 | | - framecolor = this.createFillPattern(this.tframe); |
| 1383 | + framecolor = this.createAttFill(this.tframe); |
1352 | 1384 | } else { |
1353 | 1385 | if (root_pad) { |
1354 | | - framecolor = this.createFillPattern(null, root_pad['fFrameFillStyle'], root_pad['fFrameFillColor']); |
| 1386 | + framecolor = this.createAttFill(null, root_pad['fFrameFillStyle'], root_pad['fFrameFillColor']); |
1355 | 1387 | } |
1356 | 1388 | w -= (lm + rm); |
1357 | 1389 | h -= (tm + bm); |
1358 | 1390 | } |
1359 | | - if (framecolor == null) |
1360 | | - framecolor = this.createFillPattern('white'); |
| 1391 | + |
1361 | 1392 |
|
1362 | 1393 | // this is svg:g object - container for every other items belonging to frame |
1363 | 1394 | var frame_g = this.svg_pad(true).select(".root_frame"); |
|
1402 | 1433 | .attr("width", w) |
1403 | 1434 | .attr("height", h) |
1404 | 1435 | .call(framecolor.func) |
1405 | | - .style("stroke", linecolor) |
1406 | | - .style("stroke-width", linewidth); |
| 1436 | + .call(lineatt.func); |
1407 | 1437 | } |
1408 | 1438 |
|
1409 | 1439 | JSROOT.TFramePainter.prototype.Redraw = function() { |
|
1555 | 1585 | var x = this.main_painter().x; |
1556 | 1586 | var y = this.main_painter().y; |
1557 | 1587 |
|
1558 | | - var linecolor = JSROOT.Painter.root_colors[this.tf1['fLineColor']]; |
1559 | | - if ((this.tf1['fLineColor'] == 0) || (this.tf1['fLineWidth'] == 0)) linecolor = "none"; |
1560 | | - |
1561 | | - var fill = this.createFillPattern(this.tf1); |
| 1588 | + var attline = this.createAttLine(this.tf1); |
| 1589 | + var fill = this.createAttFill(this.tf1); |
1562 | 1590 | if (fill.color == 'white') fill.color = 'none'; |
1563 | 1591 |
|
1564 | 1592 | var line = d3.svg.line() |
1565 | | - .x(function(d) { return Math.round(x(d.x)); }) |
1566 | | - .y(function(d) { return Math.round(y(d.y)); }) |
| 1593 | + .x(function(d) { return x(d.x).toFixed(1); }) |
| 1594 | + .y(function(d) { return y(d.y).toFixed(1); }) |
1567 | 1595 | .interpolate(this.interpolate_method); |
1568 | 1596 |
|
1569 | 1597 | var area = d3.svg.area() |
1570 | | - .x(function(d) { return Math.round(x(d.x)); }) |
| 1598 | + .x(function(d) { return x(d.x).toFixed(1); }) |
1571 | 1599 | .y1(h) |
1572 | | - .y0(function(d) { return Math.round(y(d.y)); }); |
| 1600 | + .y0(function(d) { return y(d.y).toFixed(1); }); |
1573 | 1601 |
|
1574 | | - if (linecolor != "none") |
| 1602 | + if (attline.color != "none") |
1575 | 1603 | this.draw_g.append("svg:path") |
1576 | 1604 | .attr("class", "line") |
1577 | 1605 | .attr("d",line(pthis.bins)) |
1578 | | - .style("stroke", linecolor) |
1579 | | - .style("stroke-width", pthis.tf1['fLineWidth']) |
1580 | | - .style("stroke-dasharray", JSROOT.Painter.root_line_styles[pthis.tf1['fLineStyle']]) |
1581 | | - .style("fill", "none"); |
| 1606 | + .style("fill", "none") |
| 1607 | + .call(attline.func); |
1582 | 1608 |
|
1583 | 1609 | if (fill.color != "none") |
1584 | 1610 | this.draw_g.append("svg:path") |
|
1592 | 1618 | this.draw_g.selectAll() |
1593 | 1619 | .data(this.bins).enter() |
1594 | 1620 | .append("svg:circle") |
1595 | | - .attr("cx", function(d) { return x(d.x); }) |
1596 | | - .attr("cy", function(d) { return y(d.y); }) |
| 1621 | + .attr("cx", function(d) { return x(d.x).toFixed(1); }) |
| 1622 | + .attr("cy", function(d) { return y(d.y).toFixed(1); }) |
1597 | 1623 | .attr("r", 4) |
1598 | 1624 | .style("opacity", 0) |
1599 | 1625 | .append("svg:title") |
|
1759 | 1785 |
|
1760 | 1786 | var npoints = this.graph['fNpoints']; |
1761 | 1787 | if ((this.graph._typename=="TCutG") && (npoints>3)) npoints--; |
| 1788 | + |
| 1789 | + this.lineatt = this.createAttLine(this.graph); |
1762 | 1790 |
|
1763 | 1791 | this.bins = d3.range(npoints).map( |
1764 | 1792 | function(p) { |
|
1796 | 1824 | } |
1797 | 1825 | }); |
1798 | 1826 |
|
1799 | | - this.bins_lw = this.graph['fLineWidth']; // line width |
1800 | | - |
1801 | 1827 | this.exclusionGraph = false; |
1802 | | - if (this.bins_lw <= 99) return; |
| 1828 | + if (this.lineatt.width <= 99) return; |
1803 | 1829 |
|
1804 | 1830 | // special handling of exclusion graphs |
1805 | 1831 |
|
1806 | 1832 | this.exclusionGraph = true; |
1807 | 1833 |
|
1808 | 1834 | var normx, normy; |
1809 | 1835 | var n = this.graph['fNpoints']; |
1810 | | - var glw = this.graph['fLineWidth'], |
1811 | | - xo = new Array(n + 2), |
1812 | | - yo = new Array(n + 2), |
1813 | | - xt = new Array(n + 2), |
1814 | | - yt = new Array(n + 2), |
1815 | | - xf = new Array(2 * n + 2), |
| 1836 | + var xo = new Array(n + 2), |
| 1837 | + yo = new Array(n + 2), |
| 1838 | + xt = new Array(n + 2), |
| 1839 | + yt = new Array(n + 2), |
| 1840 | + xf = new Array(2 * n + 2), |
1816 | 1841 | yf = new Array(2 * n + 2); |
1817 | 1842 | // negative value means another side of the line... |
1818 | | - if (glw > 32767) glw = 65536 - glw; |
1819 | | - this.bins_lw = glw % 100; // line width |
1820 | | - if (this.bins_lw > 0) this.optionLine = 1; |
1821 | 1843 |
|
1822 | | - var a, i, j, nf, wk = (glw / 100) * 0.005; |
1823 | | - if (this.graph['fLineWidth'] > 32767) wk *= -1; |
| 1844 | + |
| 1845 | + |
| 1846 | + var a, i, j, nf, wk = 1; |
| 1847 | + if (this.lineatt.width > 32767) { |
| 1848 | + this.lineatt.width = 65536 - this.lineatt.width; |
| 1849 | + wk = -1; |
| 1850 | + } |
| 1851 | + wk *= (this.lineatt.width / 100) * 0.005; |
| 1852 | + this.lineatt.width = this.lineatt.width % 100; // line width |
| 1853 | + if (this.lineatt.width > 0) this.optionLine = 1; |
1824 | 1854 |
|
1825 | 1855 | var w = Number(this.svg_frame(true).attr("width")), |
1826 | 1856 | h = Number(this.svg_frame(true).attr("height")); |
|
2042 | 2072 |
|
2043 | 2073 | var pthis = this; |
2044 | 2074 |
|
2045 | | - var fill = this.createFillPattern(this.graph); |
| 2075 | + var fill = this.createAttFill(this.graph); |
2046 | 2076 |
|
2047 | 2077 | function TooltipText(d) { |
2048 | 2078 |
|
|
2103 | 2133 | var close_symbol = ""; |
2104 | 2134 | if (this.graph._typename=="TCutG") close_symbol = " Z"; |
2105 | 2135 |
|
2106 | | - var line_color = "none", line_style = "none"; |
2107 | | - |
2108 | | - if (this.optionLine == 1) { |
2109 | | - line_color = JSROOT.Painter.root_colors[this.graph['fLineColor']]; |
2110 | | - line_style = JSROOT.Painter.root_line_styles[this.graph['fLineStyle']]; |
2111 | | - } |
| 2136 | + var lineatt = this.lineatt; |
| 2137 | + if (this.optionLine == 0) lineatt = this.createAttLine('none'); |
2112 | 2138 |
|
2113 | 2139 | if (this.optionFill == 1) { |
2114 | 2140 |
|
|
2119 | 2145 | this.draw_g.append("svg:path") |
2120 | 2146 | .attr("d", line(pthis.bins) + close_symbol) |
2121 | 2147 | .attr("class", "draw_line") |
2122 | | - .style("stroke", line_color) |
2123 | | - .style("stroke-width", pthis.bins_lw) |
2124 | | - .style("stroke-dasharray", line_style) |
| 2148 | + .call(lineatt.func) |
2125 | 2149 | .call(fill.func); |
2126 | 2150 |
|
2127 | 2151 | // do not add tooltip for line, when we wants to add markers |
|
2181 | 2205 | .attr("y1", 0) |
2182 | 2206 | .attr("x2", function(d) { return d.grx2; }) |
2183 | 2207 | .attr("y2", 0) |
2184 | | - .style("stroke", JSROOT.Painter.root_colors[this.graph['fLineColor']]) |
2185 | | - .style("stroke-width", this.graph['fLineWidth']); |
| 2208 | + .style("stroke", this.lineatt.color) |
| 2209 | + .style("stroke-width", this.lineatt.width); |
2186 | 2210 |
|
2187 | 2211 | nodes.filter(function(d) { return (d.exlow > 0); }) |
2188 | 2212 | .append("svg:line") |
2189 | 2213 | .attr("y1", -3) |
2190 | 2214 | .attr("x1", function(d) { return d.grx0; }) |
2191 | 2215 | .attr("y2", 3) |
2192 | 2216 | .attr("x2", function(d) { return d.grx0; }) |
2193 | | - .style("stroke", JSROOT.Painter.root_colors[this.graph['fLineColor']]) |
2194 | | - .style("stroke-width", this.graph['fLineWidth']); |
| 2217 | + .style("stroke", this.lineatt.color) |
| 2218 | + .style("stroke-width", this.lineatt.width); |
2195 | 2219 |
|
2196 | 2220 | nodes.filter(function(d) { return (d.exhigh > 0); }) |
2197 | 2221 | .append("svg:line") |
2198 | 2222 | .attr("y1", -3) |
2199 | 2223 | .attr("x1", function(d) { return d.grx2; }) |
2200 | 2224 | .attr("y2", 3) |
2201 | 2225 | .attr("x2", function(d) { return d.grx2; }) |
2202 | | - .style("stroke", JSROOT.Painter.root_colors[this.graph['fLineColor']]) |
2203 | | - .style( "stroke-width", this.graph['fLineWidth']); |
| 2226 | + .style("stroke", this.lineatt.color) |
| 2227 | + .style( "stroke-width", this.lineatt.width); |
2204 | 2228 |
|
2205 | 2229 | // Add y-error indicators |
2206 | 2230 |
|
|
2210 | 2234 | .attr("y1", function(d) { return d.gry0; }) |
2211 | 2235 | .attr("x2", 0) |
2212 | 2236 | .attr("y2", function(d) { return d.gry2; }) |
2213 | | - .style("stroke", JSROOT.Painter.root_colors[this.graph['fLineColor']]) |
2214 | | - .style("stroke-width", this.graph['fLineWidth']); |
| 2237 | + .style("stroke", this.lineatt.color) |
| 2238 | + .style("stroke-width", this.lineatt.width); |
2215 | 2239 |
|
2216 | 2240 | nodes.filter(function(d) { return (d.eylow > 0); }) |
2217 | 2241 | .append("svg:line") |
2218 | 2242 | .attr("x1", -3) |
2219 | 2243 | .attr("y1", function(d) { return d.gry0; }) |
2220 | 2244 | .attr("x2", 3) |
2221 | 2245 | .attr("y2", function(d) { return d.gry0; }) |
2222 | | - .style("stroke", JSROOT.Painter.root_colors[this.graph['fLineColor']]) |
2223 | | - .style("stroke-width", this.graph['fLineWidth']); |
| 2246 | + .style("stroke", this.lineatt.color) |
| 2247 | + .style("stroke-width", this.lineatt.width); |
2224 | 2248 |
|
2225 | 2249 | nodes.filter(function(d) { return (d.eyhigh > 0); }) |
2226 | 2250 | .append("svg:line") |
2227 | 2251 | .attr("x1", -3) |
2228 | 2252 | .attr("y1", function(d) { return d.gry2; }) |
2229 | 2253 | .attr("x2", 3) |
2230 | 2254 | .attr("y2", function(d) { return d.gry2; }) |
2231 | | - .style("stroke", JSROOT.Painter.root_colors[this.graph['fLineColor']]) |
2232 | | - .style("stroke-width", this.graph['fLineWidth']); |
| 2255 | + .style("stroke", this.lineatt.color) |
| 2256 | + .style("stroke-width", this.lineatt.width); |
2233 | 2257 | } |
2234 | 2258 |
|
2235 | 2259 | if (this.showMarker) { |
|
2315 | 2339 | var lcolor = JSROOT.Painter.root_colors[pavetext['fLineColor']]; |
2316 | 2340 | var tcolor = JSROOT.Painter.root_colors[pavetext['fTextColor']]; |
2317 | 2341 | var scolor = JSROOT.Painter.root_colors[pavetext['fShadowColor']]; |
2318 | | - var fcolor = this.createFillPattern(pavetext); |
| 2342 | + var fcolor = this.createAttFill(pavetext); |
2319 | 2343 |
|
2320 | 2344 | // align = 10*HorizontalAlign + VerticalAlign |
2321 | 2345 | // 1=left adjusted, 2=centered, 3=right adjusted |
|
2651 | 2675 | var fill = null; |
2652 | 2676 |
|
2653 | 2677 | if (this.pad && 'fFillColor' in this.pad) |
2654 | | - fill = this.createFillPattern(this.pad); |
| 2678 | + fill = this.createAttFill(this.pad); |
2655 | 2679 | else |
2656 | | - fill = this.createFillPattern('white'); |
| 2680 | + fill = this.createAttFill('white'); |
2657 | 2681 |
|
2658 | 2682 | render_to.css("background-color", fill.color); |
2659 | 2683 |
|
|
2690 | 2714 | var h = Math.round(this.pad['fAbsHNDC'] * height); |
2691 | 2715 | y -= h; |
2692 | 2716 |
|
2693 | | - var fill = this.createFillPattern(this.pad); |
| 2717 | + var fill = this.createAttFill(this.pad); |
2694 | 2718 |
|
2695 | 2719 | var border_width = this.pad['fLineWidth']; |
2696 | 2720 | var border_color = JSROOT.Painter.root_colors[this.pad['fLineColor']]; |
|
4682 | 4706 |
|
4683 | 4707 | // from here we analyze object content |
4684 | 4708 | // therefore code will be moved |
4685 | | - this.fill = this.createFillPattern(this.histo); |
| 4709 | + this.fill = this.createAttFill(this.histo); |
4686 | 4710 | if (this.fill.color == 'white') this.fill.color = 'none'; |
4687 | 4711 |
|
4688 | 4712 | this.linecolor = JSROOT.Painter.root_colors[this.histo['fLineColor']]; |
|
6093 | 6117 | y -= h; |
6094 | 6118 | var lcolor = JSROOT.Painter.root_colors[pave['fLineColor']]; |
6095 | 6119 | var lwidth = pave['fBorderSize'] ? pave['fBorderSize'] : 0; |
6096 | | - var fill = this.createFillPattern(pave); |
| 6120 | + var fill = this.createAttFill(pave); |
6097 | 6121 |
|
6098 | 6122 | var p = this.draw_g |
6099 | 6123 | .attr("x", x) |
|
6209 | 6233 | pos_y = pos_y - (hh / 2); |
6210 | 6234 | var pos_x = (tpos_x / 2) - (ww / 2); |
6211 | 6235 |
|
6212 | | - var fill = this.createFillPattern(attfill); |
| 6236 | + var fill = this.createAttFill(attfill); |
6213 | 6237 |
|
6214 | 6238 | p.append("svg:rect") |
6215 | 6239 | .attr("x", pos_x) |
|
6478 | 6502 | var height = Math.abs(pavelabel['fY2NDC'] - pavelabel['fY1NDC']) * h; |
6479 | 6503 | pos_y -= height; |
6480 | 6504 | var font_size = Math.round(height / 1.9); |
6481 | | - var fcolor = this.createFillPattern(pavelabel); |
| 6505 | + var fcolor = this.createAttFill(pavelabel); |
6482 | 6506 | var lcolor = JSROOT.Painter.root_colors[pavelabel['fLineColor']]; |
6483 | 6507 | var tcolor = JSROOT.Painter.root_colors[pavelabel['fTextColor']]; |
6484 | 6508 | var scolor = JSROOT.Painter.root_colors[pavelabel['fShadowColor']]; |
|
0 commit comments