all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com, pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH widget-toolkit] RRDChart: fix customizing axes in a subclass
Date: Fri, 19 Sep 2025 10:03:47 +0200	[thread overview]
Message-ID: <20250919080358.745214-1-d.csapak@proxmox.com> (raw)

the introduction of the NumericBase2 segmenter in commit
 9531c65 (rrd chart: fix y-axis segmentation when using powerOfTwo)

changed the way the axes are defined and created. The commit message
noted that we can't override the axes config anymore but that we did not
use that. It actually was used in the PMG dashboard with the 'MiniGraph'
subclass. Luckily the configs were similar enough so that it did not
matter much, so nobody seemed to notice.

On recent examination of the charts, the labels of the axes were
overlapping each other in certain conditions, and then it became
apparent that the customization there for the axis did not apply
anymore.

To fix it, move the axes definition back to the class config, and
overwrite the segmenter on each left or right 'numeric' axis if
necessary.

By overwriting it in 'config.axes' (and me.config.axes as fallback)
we're able to use:
* a default config (from the class definition, lands in `me.config`)
* a subclass override (lands also in `me.config`)
* overrides on actual creation (lands in `config`)

I examined if we can override/set this config later e.g. in the
initComponent, since a manual override + class config would be merged
there, but it seems that the chart initializes the axes already before
the initComponent.

Using 'setSegmenter' later on is also not possible really, because for
some reason this only changes the top-most point in the axis labels, but
not the intermediate ones.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/panel/RRDChart.js | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/src/panel/RRDChart.js b/src/panel/RRDChart.js
index 148015c..82615ce 100644
--- a/src/panel/RRDChart.js
+++ b/src/panel/RRDChart.js
@@ -173,6 +173,21 @@ Ext.define('Proxmox.widget.RRDChart', {
         padding: 0,
         style: 'cursor: pointer;',
     },
+    axes: [
+        {
+            type: 'numeric',
+            position: 'left',
+            grid: true,
+            renderer: 'leftAxisRenderer',
+            minimum: 0,
+        },
+        {
+            type: 'time',
+            position: 'bottom',
+            grid: true,
+            fields: ['time'],
+        },
+    ],
     listeners: {
         redraw: {
             fn: 'onAfterAnimation',
@@ -191,22 +206,17 @@ Ext.define('Proxmox.widget.RRDChart', {
         let me = this;
 
         let segmenter = config.powerOfTwo ? 'numericBase2' : 'numeric';
-        config.axes = [
-            {
-                type: 'numeric',
-                position: 'left',
-                grid: true,
-                renderer: 'leftAxisRenderer',
-                minimum: 0,
-                segmenter,
-            },
-            {
-                type: 'time',
-                position: 'bottom',
-                grid: true,
-                fields: ['time'],
-            },
-        ];
+
+        let axes = config.axes ?? me.config.axes ?? [];
+        for (const axis of axes) {
+            if (
+                axis.type === 'numeric' &&
+                (axis.position === 'left' || axis.position === 'right')
+            ) {
+                axis.segmenter = segmenter;
+            }
+        }
+
         me.callParent([config]);
     },
 
-- 
2.47.3



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


WARNING: multiple messages have this Message-ID
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com, pmg-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH widget-toolkit] RRDChart: fix customizing axes in a subclass
Date: Fri, 19 Sep 2025 10:03:47 +0200	[thread overview]
Message-ID: <20250919080358.745214-1-d.csapak@proxmox.com> (raw)

the introduction of the NumericBase2 segmenter in commit
 9531c65 (rrd chart: fix y-axis segmentation when using powerOfTwo)

changed the way the axes are defined and created. The commit message
noted that we can't override the axes config anymore but that we did not
use that. It actually was used in the PMG dashboard with the 'MiniGraph'
subclass. Luckily the configs were similar enough so that it did not
matter much, so nobody seemed to notice.

On recent examination of the charts, the labels of the axes were
overlapping each other in certain conditions, and then it became
apparent that the customization there for the axis did not apply
anymore.

To fix it, move the axes definition back to the class config, and
overwrite the segmenter on each left or right 'numeric' axis if
necessary.

By overwriting it in 'config.axes' (and me.config.axes as fallback)
we're able to use:
* a default config (from the class definition, lands in `me.config`)
* a subclass override (lands also in `me.config`)
* overrides on actual creation (lands in `config`)

I examined if we can override/set this config later e.g. in the
initComponent, since a manual override + class config would be merged
there, but it seems that the chart initializes the axes already before
the initComponent.

Using 'setSegmenter' later on is also not possible really, because for
some reason this only changes the top-most point in the axis labels, but
not the intermediate ones.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/panel/RRDChart.js | 42 ++++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/src/panel/RRDChart.js b/src/panel/RRDChart.js
index 148015c..82615ce 100644
--- a/src/panel/RRDChart.js
+++ b/src/panel/RRDChart.js
@@ -173,6 +173,21 @@ Ext.define('Proxmox.widget.RRDChart', {
         padding: 0,
         style: 'cursor: pointer;',
     },
+    axes: [
+        {
+            type: 'numeric',
+            position: 'left',
+            grid: true,
+            renderer: 'leftAxisRenderer',
+            minimum: 0,
+        },
+        {
+            type: 'time',
+            position: 'bottom',
+            grid: true,
+            fields: ['time'],
+        },
+    ],
     listeners: {
         redraw: {
             fn: 'onAfterAnimation',
@@ -191,22 +206,17 @@ Ext.define('Proxmox.widget.RRDChart', {
         let me = this;
 
         let segmenter = config.powerOfTwo ? 'numericBase2' : 'numeric';
-        config.axes = [
-            {
-                type: 'numeric',
-                position: 'left',
-                grid: true,
-                renderer: 'leftAxisRenderer',
-                minimum: 0,
-                segmenter,
-            },
-            {
-                type: 'time',
-                position: 'bottom',
-                grid: true,
-                fields: ['time'],
-            },
-        ];
+
+        let axes = config.axes ?? me.config.axes ?? [];
+        for (const axis of axes) {
+            if (
+                axis.type === 'numeric' &&
+                (axis.position === 'left' || axis.position === 'right')
+            ) {
+                axis.segmenter = segmenter;
+            }
+        }
+
         me.callParent([config]);
     },
 
-- 
2.47.3



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


             reply	other threads:[~2025-09-19  8:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-19  8:03 Dominik Csapak [this message]
2025-09-19  8:03 ` [pve-devel] " Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250919080358.745214-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal