Skip to content

Commit 6a7115a

Browse files
committed
Rebuild graph histogram like TGraph::GetHistogram does
1 parent eb11bc0 commit 6a7115a

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

scripts/JSRootCore.js

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

9797
"use strict";
9898

99-
JSROOT.version = "dev 2/07/2018";
99+
JSROOT.version = "dev 4/07/2018";
100100

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

scripts/JSRootPainter.more.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -953,16 +953,28 @@
953953
if (graph.fMaximum != -1111) maximum = ymax = graph.fMaximum;
954954
if ((minimum < 0) && (ymin >=0)) minimum = 0.9*ymin;
955955

956-
var histo = JSROOT.CreateHistogram("TH1I", 100);
957-
histo.fName = graph.fName + "_h";
958-
histo.fTitle = graph.fTitle;
956+
var kResetHisto = JSROOT.BIT(17); ///< fHistogram must be reset in GetHistogram
957+
958+
var histo = graph.fHistogram;
959+
960+
if (histo) {
961+
// make logic like in the TGraph::GetHistogram
962+
if (!graph.TestBit(kResetHisto)) return histo;
963+
graph.InvertBit(kResetHisto);
964+
} else {
965+
graph.fHistogram = histo = JSROOT.CreateHistogram("TH1I", 100);
966+
histo.fName = graph.fName + "_h";
967+
histo.fTitle = graph.fTitle;
968+
histo.fBits = histo.fBits | JSROOT.TH1StatusBits.kNoStats;
969+
}
970+
959971
histo.fXaxis.fXmin = uxmin;
960972
histo.fXaxis.fXmax = uxmax;
961973
histo.fYaxis.fXmin = minimum;
962974
histo.fYaxis.fXmax = maximum;
963975
histo.fMinimum = minimum;
964976
histo.fMaximum = maximum;
965-
histo.fBits = histo.fBits | JSROOT.TH1StatusBits.kNoStats;
977+
966978
return histo;
967979
}
968980

@@ -1918,9 +1930,7 @@
19181930
painter.CreateStat();
19191931

19201932
if (!painter.main_painter() && painter.options.Axis) {
1921-
if (!graph.fHistogram)
1922-
graph.fHistogram = painter.CreateHistogram();
1923-
JSROOT.draw(divid, graph.fHistogram, painter.options.Axis, painter.PerformDrawing.bind(painter, divid));
1933+
JSROOT.draw(divid, painter.CreateHistogram(), painter.options.Axis, painter.PerformDrawing.bind(painter, divid));
19241934
} else {
19251935
painter.PerformDrawing(divid);
19261936
}

0 commit comments

Comments
 (0)