|
954 | 954 | } |
955 | 955 | } |
956 | 956 |
|
957 | | - TGraphPainter.prototype.CreateHistogram = function(only_set_ranges) { |
| 957 | + TGraphPainter.prototype.CreateHistogram = function(histo, set_x, set_y) { |
958 | 958 | // bins should be created when calling this function |
959 | 959 |
|
960 | | - var xmin = this.xmin, xmax = this.xmax, ymin = this.ymin, ymax = this.ymax, set_x = true, set_y = true; |
| 960 | + var xmin = this.xmin, xmax = this.xmax, ymin = this.ymin, ymax = this.ymax; |
961 | 961 |
|
962 | 962 | if (xmin >= xmax) xmax = xmin+1; |
963 | 963 | if (ymin >= ymax) ymax = ymin+1; |
|
967 | 967 |
|
968 | 968 | // this is draw options with maximal axis range which could be unzoomed |
969 | 969 | this.options.HOptions = this.options.Axis + ";ymin:" + minimum + ";ymax:" + maximum; |
| 970 | + if (histo) return histo; |
970 | 971 |
|
971 | 972 | if ((uxmin<0) && (xmin>=0)) uxmin = xmin*0.9; |
972 | 973 | if ((uxmax>0) && (xmax<=0)) uxmax = 0; |
|
977 | 978 | if (graph.fMaximum != -1111) maximum = ymax = graph.fMaximum; |
978 | 979 | if ((minimum < 0) && (ymin >=0)) minimum = 0.9*ymin; |
979 | 980 |
|
980 | | - var kResetHisto = JSROOT.BIT(17); ///< fHistogram must be reset in GetHistogram |
| 981 | + histo = graph.fHistogram; |
981 | 982 |
|
982 | | - var histo = graph.fHistogram; |
| 983 | + if (!set_x && !set_y) set_x = set_y = true; |
983 | 984 |
|
984 | | - if (only_set_ranges) { |
985 | | - set_x = only_set_ranges.indexOf("x") >= 0; |
986 | | - set_y = only_set_ranges.indexOf("y") >= 0; |
987 | | - } else if (histo) { |
988 | | - // make logic like in the TGraph::GetHistogram |
989 | | - if (!graph.TestBit(kResetHisto)) return histo; |
990 | | - graph.InvertBit(kResetHisto); |
991 | | - } else { |
| 985 | + if (!histo) { |
992 | 986 | graph.fHistogram = histo = JSROOT.CreateHistogram("TH1F", 100); |
993 | 987 | histo.fName = graph.fName + "_h"; |
994 | 988 | histo.fTitle = graph.fTitle; |
|
1020 | 1014 | var histo = graph.fHistogram; |
1021 | 1015 | if (!histo) return false; |
1022 | 1016 |
|
1023 | | - var arg = ""; |
1024 | | - if (dox && (histo.fXaxis.fXmin > this.xmin) || (histo.fXaxis.fXmax < this.xmax)) arg += "x"; |
1025 | | - if (doy && (histo.fYaxis.fXmin > this.ymin) || (histo.fYaxis.fXmax < this.ymax)) arg += "y"; |
1026 | | - if (!arg) return false; |
| 1017 | + dox = dox && ((histo.fXaxis.fXmin > this.xmin) || (histo.fXaxis.fXmax < this.xmax)); |
| 1018 | + doy = doy && ((histo.fYaxis.fXmin > this.ymin) || (histo.fYaxis.fXmax < this.ymax)); |
| 1019 | + if (!dox && !doy) return false; |
1027 | 1020 |
|
1028 | | - this.CreateHistogram(arg); |
| 1021 | + this.CreateHistogram(null, dox, doy); |
1029 | 1022 | var hpainter = this.main_painter(); |
1030 | 1023 | if (hpainter) hpainter.CreateAxisFuncs(false); |
1031 | 1024 |
|
|
1863 | 1856 | fp = this.frame_painter(); |
1864 | 1857 |
|
1865 | 1858 | // if zoom was changed - do not update histogram |
1866 | | - if (!fp.zoom_changed_interactive) |
1867 | | - main.UpdateObject(obj.fHistogram || this.CreateHistogram()); |
| 1859 | + if (!fp.zoom_changed_interactive) { |
| 1860 | + var histo = this.CreateHistogram(obj.fHistogram); |
| 1861 | + main.UpdateObject(histo, this.options.HOptions); |
| 1862 | + } |
1868 | 1863 |
|
1869 | 1864 | main.GetObject().fTitle = graph.fTitle; // copy title |
1870 | 1865 | } |
|
2021 | 2016 | painter.CreateStat(); |
2022 | 2017 |
|
2023 | 2018 | if (!painter.main_painter() && painter.options.HOptions) { |
2024 | | - JSROOT.draw(divid, painter.CreateHistogram(), painter.options.HOptions, painter.PerformDrawing.bind(painter, divid)); |
| 2019 | + var histo = painter.CreateHistogram(); |
| 2020 | + JSROOT.draw(divid, histo, painter.options.HOptions, painter.PerformDrawing.bind(painter, divid)); |
2025 | 2021 | } else { |
2026 | 2022 | painter.PerformDrawing(divid); |
2027 | 2023 | } |
|
0 commit comments