|
3708 | 3708 | show_text = this.options.Text, |
3709 | 3709 | text_profile = show_text && (this.options.TextKind == "E") && this.IsTProfile() && histo.fBinEntries, |
3710 | 3710 | path_fill = null, path_err = null, path_marker = null, path_line = null, |
3711 | | - endx = "", endy = "", dend = 0, my, yerr1, yerr2, bincont, binerr, mx1, mx2, midx, |
| 3711 | + do_marker = false, do_err = false, |
| 3712 | + endx = "", endy = "", dend = 0, my, yerr1, yerr2, bincont, binerr, mx1, mx2, midx, mmx1, mmx2, |
3712 | 3713 | mpath = "", text_col, text_angle, text_size; |
3713 | 3714 |
|
3714 | 3715 | if (show_errors && !show_markers && (this.histo.fMarkerStyle > 1)) |
|
3717 | 3718 | if (this.options.ErrorKind === 2) { |
3718 | 3719 | if (this.fillatt.empty()) show_markers = true; |
3719 | 3720 | else path_fill = ""; |
3720 | | - } else |
3721 | | - if (this.options.Error) path_err = ""; |
| 3721 | + } else if (this.options.Error) { |
| 3722 | + path_err = ""; |
| 3723 | + do_err = true; |
| 3724 | + } |
3722 | 3725 |
|
3723 | 3726 | if (show_line) path_line = ""; |
3724 | 3727 |
|
|
3728 | 3731 | if (this.markeratt.size > 0) { |
3729 | 3732 | // simply use relative move from point, can optimize in the future |
3730 | 3733 | path_marker = ""; |
| 3734 | + do_marker = true; |
3731 | 3735 | this.markeratt.reset_pos(); |
3732 | 3736 | } else { |
3733 | 3737 | show_markers = false; |
|
3775 | 3779 |
|
3776 | 3780 | if (draw_any_but_hist) use_minmax = true; |
3777 | 3781 |
|
3778 | | - function draw_bin(besti) { |
3779 | | - bincont = histo.getBinContent(besti+1); |
3780 | | - if (!exclude_zero || (bincont!==0)) { |
3781 | | - mx1 = Math.round(pmain.grx(xaxis.GetBinLowEdge(besti+1))); |
3782 | | - mx2 = Math.round(pmain.grx(xaxis.GetBinLowEdge(besti+2))); |
3783 | | - midx = Math.round((mx1+mx2)/2); |
3784 | | - my = Math.round(pmain.gry(bincont)); |
3785 | | - yerr1 = yerr2 = 20; |
3786 | | - if (show_errors) { |
3787 | | - binerr = histo.getBinError(besti+1); |
3788 | | - yerr1 = Math.round(my - pmain.gry(bincont + binerr)); // up |
3789 | | - yerr2 = Math.round(pmain.gry(bincont - binerr) - my); // down |
3790 | | - } |
| 3782 | + // just to get correct values for the specified bin |
| 3783 | + function extract_bin(bin) { |
| 3784 | + bincont = histo.getBinContent(bin+1); |
| 3785 | + if (exclude_zero && (bincont===0)) return false; |
| 3786 | + mx1 = Math.round(pmain.grx(xaxis.GetBinLowEdge(bin+1))); |
| 3787 | + mx2 = Math.round(pmain.grx(xaxis.GetBinLowEdge(bin+2))); |
| 3788 | + midx = Math.round((mx1+mx2)/2); |
| 3789 | + my = Math.round(pmain.gry(bincont)); |
| 3790 | + yerr1 = yerr2 = 20; |
| 3791 | + if (show_errors) { |
| 3792 | + binerr = histo.getBinError(bin+1); |
| 3793 | + yerr1 = Math.round(my - pmain.gry(bincont + binerr)); // up |
| 3794 | + yerr2 = Math.round(pmain.gry(bincont - binerr) - my); // down |
| 3795 | + } |
| 3796 | + return true; |
| 3797 | + } |
3791 | 3798 |
|
| 3799 | + function draw_errbin(bin) { |
| 3800 | + if (pthis.options.errorX > 0) { |
| 3801 | + mmx1 = Math.round(midx - (mx2-mx1)*pthis.options.errorX); |
| 3802 | + mmx2 = Math.round(midx + (mx2-mx1)*pthis.options.errorX); |
| 3803 | + path_err += "M" + (mmx1+dend) +","+ my + endx + "h" + (mmx2-mmx1-2*dend) + endx; |
| 3804 | + } |
| 3805 | + path_err += "M" + midx +"," + (my-yerr1+dend) + endy + "v" + (yerr1+yerr2-2*dend) + endy; |
| 3806 | + } |
| 3807 | + |
| 3808 | + function draw_bin(bin) { |
| 3809 | + if (extract_bin(bin)) { |
3792 | 3810 | if (show_text) { |
3793 | | - var cont = text_profile ? histo.fBinEntries[besti+1] : bincont; |
| 3811 | + var cont = text_profile ? histo.fBinEntries[bin+1] : bincont; |
3794 | 3812 |
|
3795 | 3813 | if (cont!==0) { |
3796 | 3814 | var lbl = (cont === Math.round(cont)) ? cont.toString() : JSROOT.FFormat(cont, JSROOT.gStyle.fPaintTextFormat); |
|
3810 | 3828 | if (path_fill !== null) |
3811 | 3829 | path_fill += "M" + mx1 +","+(my-yerr1) + |
3812 | 3830 | "h" + (mx2-mx1) + "v" + (yerr1+yerr2+1) + "h-" + (mx2-mx1) + "z"; |
3813 | | - if (path_marker !== null) |
| 3831 | + if ((path_marker !== null) && do_marker) |
3814 | 3832 | path_marker += pthis.markeratt.create(midx, my); |
3815 | | - if (path_err !== null) { |
3816 | | - if (pthis.options.errorX > 0) { |
3817 | | - var mmx1 = Math.round(midx - (mx2-mx1)*pthis.options.errorX), |
3818 | | - mmx2 = Math.round(midx + (mx2-mx1)*pthis.options.errorX); |
3819 | | - path_err += "M" + (mmx1+dend) +","+ my + endx + "h" + (mmx2-mmx1-2*dend) + endx; |
3820 | | - } |
3821 | | - path_err += "M" + midx +"," + (my-yerr1+dend) + endy + "v" + (yerr1+yerr2-2*dend) + endy; |
3822 | | - } |
| 3833 | + if ((path_err !== null) && do_err) |
| 3834 | + draw_errbin(bin); |
3823 | 3835 | } |
3824 | 3836 | } |
3825 | 3837 | } |
3826 | 3838 | } |
3827 | 3839 |
|
| 3840 | + // check if we should draw markers or error marks directly, skipping optimization |
| 3841 | + if (do_marker || do_err) |
| 3842 | + if (!JSROOT.gStyle.OptimizeDraw || ((right-left<50000) && (JSROOT.gStyle.OptimizeDraw==1))) { |
| 3843 | + for (i = left; i <= right; ++i) { |
| 3844 | + if (extract_bin(i)) { |
| 3845 | + if (path_marker !== null) |
| 3846 | + path_marker += pthis.markeratt.create(midx, my); |
| 3847 | + if (path_err !== null) |
| 3848 | + draw_errbin(i); |
| 3849 | + } |
| 3850 | + } |
| 3851 | + do_err = do_marker = false; |
| 3852 | + } |
| 3853 | + |
| 3854 | + |
3828 | 3855 | for (i = left; i <= right; ++i) { |
3829 | 3856 |
|
3830 | 3857 | x = xaxis.GetBinLowEdge(i+1); |
|
0 commit comments