Skip to content

Commit

Permalink
Special TGraph 0,0 point handling
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed Nov 26, 2024
1 parent 600ed42 commit ebfb7c2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
27 changes: 18 additions & 9 deletions build/jsroot.js
Original file line number Diff line number Diff line change
Expand Up @@ -148130,6 +148130,12 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
this.ymax = Math.max(this.ymax, bin.y);
}
}

// workaround, are there better way to show marker at 0,0 on the top of the frame?
this._frame_layer = true;
if ((npoints > 0) && (this.bins[0].x === 0) && (this.bins[0].y === 0) &&
this.options.Mark && !this.options.Line && !this.options.Curve && !this.options.Fill)
this._frame_layer = 'upper_layer';
}

/** @summary Return margins for histogram ranges */
Expand All @@ -148156,7 +148162,10 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
if ((ymax < 0) && (maximum >= 0))
maximum = (1 - margin) * ymax;

if (!this._not_adjust_hrange) {
const minimum0 = minimum, maximum0 = maximum;
let histo = this.getHistogram();

if (!this._not_adjust_hrange && !histo?.fXaxis.fTimeDisplay) {
const pad_logx = this.getPadPainter()?.getPadLog('x');

if ((uxmin < 0) && (xmin >= 0))
Expand All @@ -148165,9 +148174,6 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
uxmax = pad_logx ? (1 + margin) * xmax : 0;
}

const minimum0 = minimum, maximum0 = maximum;
let histo = this.getHistogram();

if (!histo) {
histo = this._is_scatter ? createHistogram(clTH2I, 30, 30) : createHistogram(clTH1I, 100);
histo.fName = graph.fName + '_h';
Expand All @@ -148179,10 +148185,12 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
maximum = histo.fMaximum;
}

if (graph.fMinimum !== kNoZoom) minimum = ymin = graph.fMinimum;
if (graph.fMaximum !== kNoZoom) maximum = graph.fMaximum;
if (graph.fMinimum !== kNoZoom)
minimum = ymin = graph.fMinimum;
if (graph.fMaximum !== kNoZoom)
maximum = graph.fMaximum;
if ((minimum < 0) && (ymin >= 0))
minimum = (1 - margin)*ymin;
minimum = (1 - margin) * ymin;
if ((ymax < 0) && (maximum >= 0))
maximum = (1 - margin) * ymax;

Expand Down Expand Up @@ -148764,7 +148772,8 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
drawGraph() {
const pmain = this.get_main(),
graph = this.getGraph();
if (!pmain || !this.options) return;
if (!pmain || !this.options)
return;

// special mode for TMultiGraph 3d drawing
if (this.options.pos3d)
Expand All @@ -148775,7 +148784,7 @@ let TGraphPainter$1 = class TGraphPainter extends ObjectPainter {
w = pmain.getFrameWidth(),
h = pmain.getFrameHeight();

this.createG(!pmain.pad_layer);
this.createG(pmain.pad_layer ? false : this._frame_layer);

this.createGraphDrawAttributes();

Expand Down
4 changes: 2 additions & 2 deletions modules/hist2d/TGraphPainter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,9 @@ class TGraphPainter extends ObjectPainter {

// workaround, are there better way to show marker at 0,0 on the top of the frame?
this._frame_layer = true;
if ((this.xmin === 0) && (this.ymin === 0) && this.options.Mark && !this.options.Line && !this.options.Curve && !this.options.Fill)
if ((npoints > 0) && (this.bins[0].x === 0) && (this.bins[0].y === 0) &&
this.options.Mark && !this.options.Line && !this.options.Curve && !this.options.Fill)
this._frame_layer = 'upper_layer';

}

/** @summary Return margins for histogram ranges */
Expand Down

0 comments on commit ebfb7c2

Please sign in to comment.