]>
git.proxmox.com Git - proxmox-widget-toolkit.git/blob - panel/GaugeWidget.js
1 Ext
.define('Proxmox.panel.GaugeWidget', {
2 extend
: 'Ext.panel.Panel',
3 alias
: 'widget.proxmoxGauge',
17 tpl
: '<h3>{title}</h3>'
38 textBaseline
: 'bottom',
53 warningThreshold
: 0.6,
54 criticalThreshold
: 0.9,
56 criticalColor
: '#FF6C59',
57 defaultColor
: '#c2ddf2',
58 backgroundColor
: '#f5f5f5',
63 updateValue: function(value
, text
) {
65 var color
= me
.defaultColor
;
68 if (value
>= me
.criticalThreshold
) {
69 color
= me
.criticalColor
;
70 } else if (value
>= me
.warningThreshold
) {
71 color
= me
.warningColor
;
74 me
.chart
.series
[0].setColors([color
, me
.backgroundColor
]);
75 me
.chart
.series
[0].setValue(value
*100);
77 me
.valueSprite
.setText(' '+(value
*100).toFixed(0) + '%');
78 attr
.x
= me
.chart
.getWidth()/2;
79 attr
.y
= me
.chart
.getHeight()-20;
80 if (me
.spriteFontSize
) {
81 attr
.fontSize
= me
.spriteFontSize
;
83 me
.valueSprite
.setAttributes(attr
, true);
85 if (text
!== undefined) {
86 me
.text
.setHtml(text
);
90 initComponent: function() {
96 me
.getComponent('title').update({title
: me
.title
});
98 me
.text
= me
.getComponent('text');
99 me
.chart
= me
.getComponent('chart');
100 me
.valueSprite
= me
.chart
.getSurface('chart').get('valueSprite');