Skip to content

Commit 781ea66

Browse files
committed
Fix ticks position for axes with labels
1 parent 6f3234d commit 781ea66

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
4. Let draw TGeo object inside TCanvas
88
5. Let superimpose TPolyLine3D and TPolyMarker3D with TGeo drawing
99
6. Fix plain #sum and #int parsing in TLatex
10+
7. Fix ticks position for axes with labels
1011

1112

1213
## Changes in 6.3.3

scripts/JSRoot.core.js

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

105105
/** @summary JSROOT version date
106106
* @desc Release date in format day/month/year like "19/11/2021" */
107-
JSROOT.version_date = "11/02/2022";
107+
JSROOT.version_date = "14/02/2022";
108108

109109
/** @summary JSROOT version id and date
110110
* @desc Produced by concatenation of {@link JSROOT.version_id} and {@link JSROOT.version_date}

scripts/JSRoot.gpad.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,24 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
225225

226226
if (optionNoopt && this.nticks && (this.kind == "normal")) this.noticksopt = true;
227227

228-
let handle = { nminor: 0, nmiddle: 0, nmajor: 0, func: this.func };
228+
let handle = { nminor: 0, nmiddle: 0, nmajor: 0, func: this.func }, ticks;
229229

230-
handle.minor = handle.middle = handle.major = this.produceTicks(this.nticks);
230+
if ((this.kind == 'labels') && !this.regular_labels) {
231+
ticks = [];
232+
handle.lbl_pos = [];
233+
let axis = this.getObject();
234+
for (let n = 0; n < axis.fNbins; ++n) {
235+
let x = axis.fXmin + n / axis.fNbins * (axis.fXmax - axis.fXmin);
236+
if ((x >= this.scale_min) && (x < this.scale_max)) {
237+
handle.lbl_pos.push(x);
238+
if (x > this.scale_min) ticks.push(x);
239+
}
240+
}
241+
} else {
242+
ticks = this.produceTicks(this.nticks);
243+
}
244+
245+
handle.minor = handle.middle = handle.major = ticks;
231246

232247
if (only_major_as_array) {
233248
let res = handle.major, delta = (this.scale_max - this.scale_min)*1e-5;
@@ -236,14 +251,6 @@ JSROOT.define(['d3', 'painter'], (d3, jsrp) => {
236251
return res;
237252
}
238253

239-
if ((this.kind == 'labels') && !this.regular_labels) {
240-
handle.lbl_pos = [];
241-
let axis = this.getObject();
242-
for (let n = 0; n < axis.fNbins; ++n) {
243-
let x = axis.fXmin + n / axis.fNbins * (axis.fXmax - axis.fXmin);
244-
if ((x >= this.scale_min) && (x < this.scale_max)) handle.lbl_pos.push(x);
245-
}
246-
}
247254

248255
if ((this.nticks2 > 1) && (!this.log || (this.logbase === 10))) {
249256
handle.minor = handle.middle = this.produceTicks(handle.major.length, this.nticks2);

0 commit comments

Comments
 (0)