|
3646 | 3646 | xaxis = histo.fXaxis, |
3647 | 3647 | pthis = this, |
3648 | 3648 | res = "", lastbin = false, |
3649 | | - startx, currx, curry, x, grx, y, gry, curry_min, curry_max, prevy, prevx, i, besti, |
| 3649 | + startx, currx, curry, x, grx, y, gry, curry_min, curry_max, prevy, prevx, i, bestimin, bestimax, |
3650 | 3650 | exclude_zero = !this.options.Zero, |
3651 | 3651 | show_errors = this.options.Error, |
3652 | 3652 | show_markers = this.options.Mark, |
|
3721 | 3721 |
|
3722 | 3722 | if (draw_any_but_hist) use_minmax = true; |
3723 | 3723 |
|
| 3724 | + function draw_bin(besti) { |
| 3725 | + bincont = histo.getBinContent(besti+1); |
| 3726 | + if (!exclude_zero || (bincont!==0)) { |
| 3727 | + mx1 = Math.round(pmain.grx(xaxis.GetBinLowEdge(besti+1))); |
| 3728 | + mx2 = Math.round(pmain.grx(xaxis.GetBinLowEdge(besti+2))); |
| 3729 | + midx = Math.round((mx1+mx2)/2); |
| 3730 | + my = Math.round(pmain.gry(bincont)); |
| 3731 | + yerr1 = yerr2 = 20; |
| 3732 | + if (show_errors) { |
| 3733 | + binerr = histo.getBinError(besti+1); |
| 3734 | + yerr1 = Math.round(my - pmain.gry(bincont + binerr)); // up |
| 3735 | + yerr2 = Math.round(pmain.gry(bincont - binerr) - my); // down |
| 3736 | + } |
| 3737 | + |
| 3738 | + if (show_text) { |
| 3739 | + var cont = text_profile ? histo.fBinEntries[besti+1] : bincont; |
| 3740 | + |
| 3741 | + if (cont!==0) { |
| 3742 | + var lbl = (cont === Math.round(cont)) ? cont.toString() : JSROOT.FFormat(cont, JSROOT.gStyle.fPaintTextFormat); |
| 3743 | + |
| 3744 | + if (text_angle) |
| 3745 | + pthis.DrawText({ align: 12, x: midx, y: Math.round(my - 2 - text_size/5), width: 0, height: 0, rotate: text_angle, text: lbl, color: text_col, latex: 0 }); |
| 3746 | + else |
| 3747 | + pthis.DrawText({ align: 22, x: Math.round(mx1 + (mx2-mx1)*0.1), y: Math.round(my-2-text_size), width: Math.round((mx2-mx1)*0.8), height: text_size, text: lbl, color: text_col, latex: 0 }); |
| 3748 | + } |
| 3749 | + } |
| 3750 | + |
| 3751 | + if (show_line && (path_line !== null)) |
| 3752 | + path_line += ((path_line.length===0) ? "M" : "L") + midx + "," + my; |
| 3753 | + |
| 3754 | + if (draw_markers) { |
| 3755 | + if ((my >= -yerr1) && (my <= height + yerr2)) { |
| 3756 | + if (path_fill !== null) |
| 3757 | + path_fill += "M" + mx1 +","+(my-yerr1) + |
| 3758 | + "h" + (mx2-mx1) + "v" + (yerr1+yerr2+1) + "h-" + (mx2-mx1) + "z"; |
| 3759 | + if (path_marker !== null) |
| 3760 | + path_marker += pthis.markeratt.create(midx, my); |
| 3761 | + if (path_err !== null) { |
| 3762 | + if (pthis.options.errorX > 0) { |
| 3763 | + var mmx1 = Math.round(midx - (mx2-mx1)*pthis.options.errorX), |
| 3764 | + mmx2 = Math.round(midx + (mx2-mx1)*pthis.options.errorX); |
| 3765 | + path_err += "M" + (mmx1+dend) +","+ my + endx + "h" + (mmx2-mmx1-2*dend) + endx; |
| 3766 | + } |
| 3767 | + path_err += "M" + midx +"," + (my-yerr1+dend) + endy + "v" + (yerr1+yerr2-2*dend) + endy; |
| 3768 | + } |
| 3769 | + } |
| 3770 | + } |
| 3771 | + } |
| 3772 | + } |
| 3773 | + |
3724 | 3774 | for (i = left; i <= right; ++i) { |
3725 | 3775 |
|
3726 | 3776 | x = xaxis.GetBinLowEdge(i+1); |
|
3739 | 3789 | } |
3740 | 3790 |
|
3741 | 3791 | if (res.length === 0) { |
3742 | | - besti = i; |
| 3792 | + bestimin = bestimax = i; |
3743 | 3793 | prevx = startx = currx = grx; |
3744 | 3794 | prevy = curry_min = curry_max = curry = gry; |
3745 | 3795 | res = "M"+currx+","+curry; |
3746 | 3796 | } else if (use_minmax) { |
3747 | 3797 | if ((grx === currx) && !lastbin) { |
3748 | | - if (gry < curry_min) besti = i; |
| 3798 | + if (gry < curry_min) bestimax = i; else |
| 3799 | + if (gry > curry_max) bestimin = i; |
| 3800 | + |
3749 | 3801 | curry_min = Math.min(curry_min, gry); |
3750 | 3802 | curry_max = Math.max(curry_max, gry); |
3751 | 3803 | curry = gry; |
3752 | 3804 | } else { |
3753 | 3805 |
|
3754 | 3806 | if (draw_any_but_hist) { |
3755 | | - bincont = histo.getBinContent(besti+1); |
3756 | | - if (!exclude_zero || (bincont!==0)) { |
3757 | | - mx1 = Math.round(pmain.grx(xaxis.GetBinLowEdge(besti+1))); |
3758 | | - mx2 = Math.round(pmain.grx(xaxis.GetBinLowEdge(besti+2))); |
3759 | | - midx = Math.round((mx1+mx2)/2); |
3760 | | - my = Math.round(pmain.gry(bincont)); |
3761 | | - yerr1 = yerr2 = 20; |
3762 | | - if (show_errors) { |
3763 | | - binerr = histo.getBinError(besti+1); |
3764 | | - yerr1 = Math.round(my - pmain.gry(bincont + binerr)); // up |
3765 | | - yerr2 = Math.round(pmain.gry(bincont - binerr) - my); // down |
3766 | | - } |
3767 | | - |
3768 | | - if (show_text) { |
3769 | | - var cont = text_profile ? histo.fBinEntries[besti+1] : bincont; |
3770 | | - |
3771 | | - if (cont!==0) { |
3772 | | - var lbl = (cont === Math.round(cont)) ? cont.toString() : JSROOT.FFormat(cont, JSROOT.gStyle.fPaintTextFormat); |
3773 | | - |
3774 | | - if (text_angle) |
3775 | | - this.DrawText({ align: 12, x: midx, y: Math.round(my - 2 - text_size/5), width: 0, height: 0, rotate: text_angle, text: lbl, color: text_col, latex: 0 }); |
3776 | | - else |
3777 | | - this.DrawText({ align: 22, x: Math.round(mx1 + (mx2-mx1)*0.1), y: Math.round(my-2-text_size), width: Math.round((mx2-mx1)*0.8), height: text_size, text: lbl, color: text_col, latex: 0 }); |
3778 | | - } |
3779 | | - } |
3780 | | - |
3781 | | - if (show_line && (path_line !== null)) |
3782 | | - path_line += ((path_line.length===0) ? "M" : "L") + midx + "," + my; |
3783 | | - |
3784 | | - if (draw_markers) { |
3785 | | - if ((my >= -yerr1) && (my <= height + yerr2)) { |
3786 | | - if (path_fill !== null) |
3787 | | - path_fill += "M" + mx1 +","+(my-yerr1) + |
3788 | | - "h" + (mx2-mx1) + "v" + (yerr1+yerr2+1) + "h-" + (mx2-mx1) + "z"; |
3789 | | - if (path_marker !== null) |
3790 | | - path_marker += this.markeratt.create(midx, my); |
3791 | | - if (path_err !== null) { |
3792 | | - if (this.options.errorX > 0) { |
3793 | | - var mmx1 = Math.round(midx - (mx2-mx1)*this.options.errorX), |
3794 | | - mmx2 = Math.round(midx + (mx2-mx1)*this.options.errorX); |
3795 | | - path_err += "M" + (mmx1+dend) +","+ my + endx + "h" + (mmx2-mmx1-2*dend) + endx; |
3796 | | - } |
3797 | | - path_err += "M" + midx +"," + (my-yerr1+dend) + endy + "v" + (yerr1+yerr2-2*dend) + endy; |
3798 | | - } |
3799 | | - } |
3800 | | - } |
| 3807 | + if (bestimin === bestimax) { draw_bin(bestimin); } else |
| 3808 | + if (bestimin < bestimax) { draw_bin(bestimin); draw_bin(bestimax); } else { |
| 3809 | + draw_bin(bestimax); draw_bin(bestimin); |
3801 | 3810 | } |
3802 | 3811 | } |
3803 | 3812 |
|
|
3828 | 3837 | if (lastbin && (prevx !== grx)) |
3829 | 3838 | res += "h"+(grx-prevx); |
3830 | 3839 |
|
3831 | | - besti = i; |
| 3840 | + bestimin = bestimax = i; |
3832 | 3841 | curry_min = curry_max = curry = gry; |
3833 | 3842 | currx = grx; |
3834 | 3843 | } |
|
0 commit comments