Skip to content

Commit 6c1aaae

Browse files
committed
Fix interactive update of TGraph painting on time scale
1 parent a487ca5 commit 6c1aaae

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## Changes in 5.9.x
44
1. Fix zooming in color palette
5+
2. Fix interactive update of TGraph painting on time scale
56

67

78
## Changes in 5.9.0

scripts/JSRootCore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595

9696
"use strict";
9797

98-
JSROOT.version = "5.9.0 9/10/2020";
98+
JSROOT.version = "5.9.x 9/10/2020";
9999

100100
JSROOT.source_dir = "";
101101
JSROOT.source_min = false;

scripts/JSRootPainter.more.js

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -954,10 +954,10 @@
954954
}
955955
}
956956

957-
TGraphPainter.prototype.CreateHistogram = function(only_set_ranges) {
957+
TGraphPainter.prototype.CreateHistogram = function(histo, set_x, set_y) {
958958
// bins should be created when calling this function
959959

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;
961961

962962
if (xmin >= xmax) xmax = xmin+1;
963963
if (ymin >= ymax) ymax = ymin+1;
@@ -967,6 +967,7 @@
967967

968968
// this is draw options with maximal axis range which could be unzoomed
969969
this.options.HOptions = this.options.Axis + ";ymin:" + minimum + ";ymax:" + maximum;
970+
if (histo) return histo;
970971

971972
if ((uxmin<0) && (xmin>=0)) uxmin = xmin*0.9;
972973
if ((uxmax>0) && (xmax<=0)) uxmax = 0;
@@ -977,18 +978,11 @@
977978
if (graph.fMaximum != -1111) maximum = ymax = graph.fMaximum;
978979
if ((minimum < 0) && (ymin >=0)) minimum = 0.9*ymin;
979980

980-
var kResetHisto = JSROOT.BIT(17); ///< fHistogram must be reset in GetHistogram
981+
histo = graph.fHistogram;
981982

982-
var histo = graph.fHistogram;
983+
if (!set_x && !set_y) set_x = set_y = true;
983984

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) {
992986
graph.fHistogram = histo = JSROOT.CreateHistogram("TH1F", 100);
993987
histo.fName = graph.fName + "_h";
994988
histo.fTitle = graph.fTitle;
@@ -1020,12 +1014,11 @@
10201014
var histo = graph.fHistogram;
10211015
if (!histo) return false;
10221016

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;
10271020

1028-
this.CreateHistogram(arg);
1021+
this.CreateHistogram(null, dox, doy);
10291022
var hpainter = this.main_painter();
10301023
if (hpainter) hpainter.CreateAxisFuncs(false);
10311024

@@ -1863,8 +1856,10 @@
18631856
fp = this.frame_painter();
18641857

18651858
// 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+
}
18681863

18691864
main.GetObject().fTitle = graph.fTitle; // copy title
18701865
}
@@ -2021,7 +2016,8 @@
20212016
painter.CreateStat();
20222017

20232018
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));
20252021
} else {
20262022
painter.PerformDrawing(divid);
20272023
}

0 commit comments

Comments
 (0)