"Timeseries - Flot" widget improvements
This commit is contained in:
parent
34641d5395
commit
8e2dfc3ea4
@ -238,19 +238,30 @@ export default class TbFlot {
|
|||||||
if (this.ticksFormatterFunction) {
|
if (this.ticksFormatterFunction) {
|
||||||
return this.ticksFormatterFunction(value);
|
return this.ticksFormatterFunction(value);
|
||||||
}
|
}
|
||||||
var factor = this.tickDecimals ? Math.pow(10, this.tickDecimals) : 1,
|
if (this.tickDecimals) {
|
||||||
formatted = "" + Math.round(value * factor) / factor;
|
value = value.toFixed(this.tickDecimals);
|
||||||
if (this.tickDecimals != null) {
|
|
||||||
var decimal = formatted.indexOf("."),
|
|
||||||
precision = decimal === -1 ? 0 : formatted.length - decimal - 1;
|
|
||||||
|
|
||||||
if (precision < this.tickDecimals) {
|
|
||||||
formatted = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
formatted += ' ' + this.tickUnits;
|
if (this.tickUnits) {
|
||||||
return formatted;
|
value = value + ' ' + this.tickUnits;
|
||||||
}
|
}
|
||||||
|
if (this.tickSize) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// var factor = this.tickDecimals ? Math.pow(10, this.tickDecimals) : 1,
|
||||||
|
// formatted = "" + Math.round(value * factor) / factor;
|
||||||
|
// if (this.tickDecimals != null) {
|
||||||
|
// var decimal = formatted.indexOf("."),
|
||||||
|
// precision = decimal === -1 ? 0 : formatted.length - decimal - 1;
|
||||||
|
//
|
||||||
|
// if (precision < this.tickDecimals) {
|
||||||
|
// formatted = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// formatted += ' ' + this.tickUnits;
|
||||||
|
return value;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
this.yaxis.tickFormatter = ctx.yAxisTickFormatter;
|
this.yaxis.tickFormatter = ctx.yAxisTickFormatter;
|
||||||
|
|
||||||
@ -262,6 +273,8 @@ export default class TbFlot {
|
|||||||
this.yaxis.labelFont.color = this.yaxis.font.color;
|
this.yaxis.labelFont.color = this.yaxis.font.color;
|
||||||
this.yaxis.labelFont.size = this.yaxis.font.size+2;
|
this.yaxis.labelFont.size = this.yaxis.font.size+2;
|
||||||
this.yaxis.labelFont.weight = "bold";
|
this.yaxis.labelFont.weight = "bold";
|
||||||
|
this.yaxis.tickSize = settings.yaxis.tickSize || null;
|
||||||
|
this.yaxis.tickDecimals = settings.yaxis.tickDecimals || null;
|
||||||
if (settings.yaxis.ticksFormatter && settings.yaxis.ticksFormatter.length) {
|
if (settings.yaxis.ticksFormatter && settings.yaxis.ticksFormatter.length) {
|
||||||
try {
|
try {
|
||||||
this.yaxis.ticksFormatterFunction = new Function('value', settings.yaxis.ticksFormatter);
|
this.yaxis.ticksFormatterFunction = new Function('value', settings.yaxis.ticksFormatter);
|
||||||
@ -489,7 +502,7 @@ export default class TbFlot {
|
|||||||
var yaxis = angular.copy(this.yaxis);
|
var yaxis = angular.copy(this.yaxis);
|
||||||
|
|
||||||
var label = keySettings.axisTitle && keySettings.axisTitle.length ? keySettings.axisTitle : yaxis.label;
|
var label = keySettings.axisTitle && keySettings.axisTitle.length ? keySettings.axisTitle : yaxis.label;
|
||||||
var tickDecimals = angular.isDefined(keySettings.axisTickDecimals) ? keySettings.axisTickDecimals : 0;
|
//var tickDecimals = angular.isDefined(keySettings.axisTickDecimals) ? keySettings.axisTickDecimals : 0;
|
||||||
var position = keySettings.axisPosition && keySettings.axisPosition.length ? keySettings.axisPosition : "left";
|
var position = keySettings.axisPosition && keySettings.axisPosition.length ? keySettings.axisPosition : "left";
|
||||||
|
|
||||||
var min = angular.isDefined(keySettings.axisMin) ? keySettings.axisMin : yaxis.min;
|
var min = angular.isDefined(keySettings.axisMin) ? keySettings.axisMin : yaxis.min;
|
||||||
@ -499,7 +512,6 @@ export default class TbFlot {
|
|||||||
yaxis.min = min;
|
yaxis.min = min;
|
||||||
yaxis.max = max;
|
yaxis.max = max;
|
||||||
yaxis.tickUnits = units;
|
yaxis.tickUnits = units;
|
||||||
yaxis.tickDecimals = tickDecimals;
|
|
||||||
yaxis.alignTicksWithAxis = position == "right" ? 1 : null;
|
yaxis.alignTicksWithAxis = position == "right" ? 1 : null;
|
||||||
yaxis.position = position;
|
yaxis.position = position;
|
||||||
|
|
||||||
@ -904,6 +916,11 @@ export default class TbFlot {
|
|||||||
"type": "number",
|
"type": "number",
|
||||||
"default": null
|
"default": null
|
||||||
},
|
},
|
||||||
|
"tickSize": {
|
||||||
|
"title": "Step size between ticks",
|
||||||
|
"type": "number",
|
||||||
|
"default": null
|
||||||
|
},
|
||||||
"showLabels": {
|
"showLabels": {
|
||||||
"title": "Show labels",
|
"title": "Show labels",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
@ -928,7 +945,13 @@ export default class TbFlot {
|
|||||||
"title": "Ticks formatter function, f(value)",
|
"title": "Ticks formatter function, f(value)",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
|
},
|
||||||
|
"tickDecimals": {
|
||||||
|
"title": "The number of decimals to display",
|
||||||
|
"type": "number",
|
||||||
|
"default": 0
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -986,6 +1009,8 @@ export default class TbFlot {
|
|||||||
"items": [
|
"items": [
|
||||||
"yaxis.min",
|
"yaxis.min",
|
||||||
"yaxis.max",
|
"yaxis.max",
|
||||||
|
"yaxis.tickSize",
|
||||||
|
"yaxis.tickDecimals",
|
||||||
"yaxis.showLabels",
|
"yaxis.showLabels",
|
||||||
"yaxis.title",
|
"yaxis.title",
|
||||||
"yaxis.titleAngle",
|
"yaxis.titleAngle",
|
||||||
@ -1010,24 +1035,24 @@ export default class TbFlot {
|
|||||||
|
|
||||||
static datakeySettingsSchema(defaultShowLines) {
|
static datakeySettingsSchema(defaultShowLines) {
|
||||||
return {
|
return {
|
||||||
"schema": {
|
"schema": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "DataKeySettings",
|
"title": "DataKeySettings",
|
||||||
"properties": {
|
"properties": {
|
||||||
"showLines": {
|
"showLines": {
|
||||||
"title": "Show lines",
|
"title": "Show lines",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": defaultShowLines
|
"default": defaultShowLines
|
||||||
},
|
},
|
||||||
"fillLines": {
|
"fillLines": {
|
||||||
"title": "Fill lines",
|
"title": "Fill lines",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"showPoints": {
|
"showPoints": {
|
||||||
"title": "Show points",
|
"title": "Show points",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": false
|
"default": false
|
||||||
},
|
},
|
||||||
"tooltipValueFormatter": {
|
"tooltipValueFormatter": {
|
||||||
"title": "Tooltip value format function, f(value)",
|
"title": "Tooltip value format function, f(value)",
|
||||||
@ -1054,11 +1079,6 @@ export default class TbFlot {
|
|||||||
"type": "string",
|
"type": "string",
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
},
|
||||||
"axisTickDecimals": {
|
|
||||||
"title": "Axis tick number of digits after floating point",
|
|
||||||
"type": "number",
|
|
||||||
"default": 0
|
|
||||||
},
|
|
||||||
"axisPosition": {
|
"axisPosition": {
|
||||||
"title": "Axis position",
|
"title": "Axis position",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -1072,7 +1092,7 @@ export default class TbFlot {
|
|||||||
},
|
},
|
||||||
"required": ["showLines", "fillLines", "showPoints"]
|
"required": ["showLines", "fillLines", "showPoints"]
|
||||||
},
|
},
|
||||||
"form": [
|
"form": [
|
||||||
"showLines",
|
"showLines",
|
||||||
"fillLines",
|
"fillLines",
|
||||||
"showPoints",
|
"showPoints",
|
||||||
@ -1084,7 +1104,6 @@ export default class TbFlot {
|
|||||||
"axisMin",
|
"axisMin",
|
||||||
"axisMax",
|
"axisMax",
|
||||||
"axisTitle",
|
"axisTitle",
|
||||||
"axisTickDecimals",
|
|
||||||
{
|
{
|
||||||
"key": "axisPosition",
|
"key": "axisPosition",
|
||||||
"type": "rc-select",
|
"type": "rc-select",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user