Skip to content

Commit

Permalink
Improve Z axis handling in scatter plot
Browse files Browse the repository at this point in the history
Correctly copy members before drawing
  • Loading branch information
linev committed Jun 17, 2024
1 parent e7ed34b commit 8f3ec1e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
6 changes: 4 additions & 2 deletions modules/hist/TPavePainter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -838,14 +838,15 @@ class TPavePainter extends ObjectPainter {
is_th3 = isFunc(main.getDimension) && (main.getDimension() === 3),
log = pad?.fLogv ?? (is_th3 ? false : pad?.fLogz),
draw_palette = main._color_palette,
zaxis = main.getObject()?.fZaxis,
zaxis = isFunc(main.getZaxis) ? main.getZaxis() : main.getObject()?.fZaxis,
sizek = pad?.fTickz ? 0.35 : 0.7;

let zmin = 0, zmax = 100, gzmin, gzmax, axis_transform = '', axis_second = 0;

this._palette_vertical = (palette.fX2NDC - palette.fX1NDC) < (palette.fY2NDC - palette.fY1NDC);

axis.fTickSize = 0.6 * s_width / width; // adjust axis ticks size

if ((typeof zaxis?.fLabelOffset !== 'undefined') && !is_th3) {
axis.fTitle = zaxis.fTitle;
axis.fTitleSize = zaxis.fTitleSize;
Expand All @@ -857,7 +858,8 @@ class TPavePainter extends ObjectPainter {
axis.fLabelColor = zaxis.fLabelColor;
axis.fLabelFont = zaxis.fLabelFont;
axis.fLabelOffset = zaxis.fLabelOffset;
this.z_handle.setHistPainter(main, 'z');
if (!isFunc(main.getZaxis))
this.z_handle.setHistPainter(main, 'z');
this.z_handle.source_axis = zaxis;
}

Expand Down
17 changes: 6 additions & 11 deletions modules/hist2d/TScatterPainter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,6 @@ class TScatterPainter extends TGraphPainter {
gr.fFunctions.AddFirst(pal, '');
}

const zaxis = this.getHistogram()?.fZaxis;
if (pal && zaxis) {
Object.assign(pal.fAxis, {
fTitle: zaxis.fTitle, fTitleSize: zaxis.fTitleSize,
fTitleOffset: zaxis.fTitleOffset, fTitleColor: zaxis.fTitleColor,
fLineColor: zaxis.fAxisColor, fTextSize: zaxis.fLabelSize,
fTextColor: zaxis.fLabelColor, fTextFont: zaxis.fLabelFont,
fLabelOffset: zaxis.fLabelOffset
});
}

return pal;
}

Expand All @@ -69,6 +58,12 @@ class TScatterPainter extends TGraphPainter {
super._updateMembers(scatter.fGraph, obj.fGraph);
}

/** @summary Return Z axis used for palette drawing
* @private */
getZaxis() {
return this.getHistogram()?.fZaxis;
}

/** @summary Actual drawing of TScatter */
async drawGraph() {
const fpainter = this.get_main(),
Expand Down

0 comments on commit 8f3ec1e

Please sign in to comment.