all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/4] ui: add panel/UsageChart
Date: Tue, 10 Nov 2020 10:18:06 +0100	[thread overview]
Message-ID: <20201110091808.4476-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20201110091808.4476-1-d.csapak@proxmox.com>

heavily inspired by pveRunningChart, without the dynamically adding
of data and specific for the usage of datastores

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/Makefile            |   1 +
 www/panel/UsageChart.js | 115 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 116 insertions(+)
 create mode 100644 www/panel/UsageChart.js

diff --git a/www/Makefile b/www/Makefile
index bfea32fa..f64d2bba 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -44,6 +44,7 @@ JSSRC=							\
 	panel/XtermJsConsole.js				\
 	panel/AccessControl.js				\
 	panel/StorageAndDisks.js			\
+	panel/UsageChart.js				\
 	ZFSList.js					\
 	DirectoryList.js				\
 	LoginView.js					\
diff --git a/www/panel/UsageChart.js b/www/panel/UsageChart.js
new file mode 100644
index 00000000..87f1200d
--- /dev/null
+++ b/www/panel/UsageChart.js
@@ -0,0 +1,115 @@
+Ext.define('PBS.widget.UsageChart', {
+    extend: 'Ext.container.Container',
+    alias: 'widget.pbsUsageChart',
+
+    layout: {
+	type: 'hbox',
+	align: 'center',
+    },
+
+    items: [
+	{
+	    width: 80,
+	    xtype: 'box',
+	    itemId: 'title',
+	    data: {
+		title: '',
+	    },
+	    tpl: '<h3>{title}:</h3>',
+	},
+	{
+	    flex: 1,
+	    xtype: 'cartesian',
+	    height: '100%',
+	    itemId: 'chart',
+	    border: false,
+	    axes: [
+		{
+		    type: 'numeric',
+		    position: 'right',
+		    hidden: true,
+		    minimum: 0,
+		},
+		{
+		    type: 'time',
+		    position: 'bottom',
+		    hidden: true,
+		},
+	    ],
+
+	    store: {
+		trackRemoved: false,
+		data: {},
+	    },
+
+	    series: [{
+		type: 'line',
+		xField: 'time',
+		yField: 'val',
+		fill: 'true',
+		colors: ['#cfcfcf'],
+		tooltip: {
+		    trackMouse: true,
+		    renderer: function(tooltip, record, ctx) {
+			if (!record || !record.data) return;
+			let date = new Date(record.data.time);
+			let value = (100*record.data.val).toFixed(2);
+			tooltip.setHtml(
+			    `${value} %<br />
+			    ${date}`,
+			);
+		    },
+		},
+		style: {
+		    lineWidth: 1.5,
+		    opacity: 0.60,
+		},
+		marker: {
+		    opacity: 0,
+		    scaling: 0.01,
+		    fx: {
+			duration: 200,
+			easing: 'easeOut',
+		    },
+		},
+		highlightCfg: {
+		    opacity: 1,
+		    scaling: 1.5,
+		},
+	    }],
+	},
+    ],
+
+    setData: function(data) {
+	let me = this;
+	let chart = me.chart;
+	chart.store.setData(data);
+	chart.redraw();
+    },
+
+    // the renderer for the tooltip and last value, default just the value
+    renderer: Ext.identityFn,
+
+    setTitle: function(title) {
+	let me = this;
+	me.title = title;
+	me.getComponent('title').update({ title: title });
+    },
+
+    initComponent: function() {
+	var me = this;
+	me.callParent();
+
+	if (me.title) {
+	    me.getComponent('title').update({ title: me.title });
+	}
+	me.chart = me.getComponent('chart');
+	me.chart.timeaxis = me.chart.getAxes()[1];
+	if (me.color) {
+	    me.chart.series[0].setStyle({
+		fill: me.color,
+		stroke: me.color,
+	    });
+	}
+    },
+});
-- 
2.20.1





  reply	other threads:[~2020-11-10  9:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10  9:18 [pbs-devel] [PATCH proxmox-backup 1/4] api2/status/datastore-usage: add gc-status and history start and delta Dominik Csapak
2020-11-10  9:18 ` Dominik Csapak [this message]
2020-11-10  9:18 ` [pbs-devel] [PATCH proxmox-backup 3/4] ui: refactor calculate_dedup_factor Dominik Csapak
2020-11-10  9:18 ` [pbs-devel] [PATCH proxmox-backup 4/4] ui: Datastores Summary: change layout and chart Dominik Csapak
2020-11-10 10:47 ` [pbs-devel] applied-series: [PATCH proxmox-backup 1/4] api2/status/datastore-usage: add gc-status and history start and delta Thomas Lamprecht

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=20201110091808.4476-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-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