]> git.proxmox.com Git - proxmox-widget-toolkit.git/commit - src/panel/RRDChart.js
rrd chart: fix y-axis segmentation when using powerOfTwo
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 16 Apr 2021 19:53:45 +0000 (21:53 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Sat, 17 Apr 2021 17:20:53 +0000 (19:20 +0200)
commit9531c6594ec1d50565152660914f362999baabfb
tree33b8fa499b3c9ba141bd4d3619db6d3f07b1ba5f
parent4337ad5b7457939ced4aceee64ffc3b6c1505ee3
rrd chart: fix y-axis segmentation when using powerOfTwo

The chart axis get initialized really, so changing the segmenter in
initComponent is not possible anymore, we can only alter the chart
base config in the constructor.

Luckily, the actual segmentation happens later, so we can pass a
flag to the y-axis and hook into the segmenter directly by creating
a new one derived from 'Ext.chart.axis.segmenter.Numeric'.

There we override the preferStep and exactStep methods to decide if
we want to calculate with base 10 or base 2.

So add a constructor to RRDChart and set the axis with the respective
segmenter, depending on the powerOfTwo config, up there initially.

Note: that makes overwriting the axes from a caller impossible, but
we do not use that anywhere, and we can control the more important
parts of the axes, like label or units already otherwise, so seems
not really required, and if, its not to hard to solve (either by
always using our new segmenter by default and handle the different
bases there directly, or by adding an explicit do not touch axes
config flag, or the like).

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/panel/RRDChart.js