Skip to content

Commit 946f7bb

Browse files
committed
Correctly handle negative axis fNdivision
This is usecase when axis ticks just exactly set for visible range - no automatic adjustments. Was ignored in JSROOT.
1 parent b4f1824 commit 946f7bb

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

modules/gpad/TAxisPainter.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ const AxisPainterMethods = {
304304

305305
/** @summary Produce axis ticks */
306306
produceTicks(ndiv, ndiv2) {
307-
if (!this.noticksopt) {
307+
if (!this.noticksopt && !this.exact_ticks) {
308308
const total = ndiv * (ndiv2 || 1);
309309

310310
if (this.log)
@@ -577,14 +577,18 @@ class TAxisPainter extends ObjectPainter {
577577
else
578578
this.gr = this.func;
579579

580-
delete this.format;// remove formatting func
580+
delete this.format; // remove formatting func
581581

582582
let ndiv = 508;
583583
if (this.is_gaxis)
584584
ndiv = axis.fNdiv;
585585
else if (axis)
586-
ndiv = axis.fNdivisions ? Math.max(axis.fNdivisions, 4) : 0;
586+
ndiv = axis.fNdivisions;
587587

588+
this.exact_ticks = ndiv < 0;
589+
if (this.exact_ticks)
590+
ndiv = Math.abs(ndiv);
591+
ndiv = Math.max(ndiv, 4);
588592
this.nticks = ndiv % 100;
589593
this.nticks2 = (ndiv % 10000 - this.nticks) / 100;
590594
this.nticks3 = Math.floor(ndiv / 10000);

0 commit comments

Comments
 (0)