Merge pull request #526 from jktu2870/flot
UI:Fix 'Timeseries - Flot' widget (the legend breaks tooltips)
This commit is contained in:
commit
2e445e79b6
@ -238,6 +238,7 @@ 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,
|
var factor = this.tickDecimals ? Math.pow(10, this.tickDecimals) : 1,
|
||||||
formatted = "" + Math.round(value * factor) / factor;
|
formatted = "" + Math.round(value * factor) / factor;
|
||||||
if (this.tickDecimals != null) {
|
if (this.tickDecimals != null) {
|
||||||
@ -248,9 +249,12 @@ export default class TbFlot {
|
|||||||
formatted = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision);
|
formatted = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formatted += ' ' + this.tickUnits;
|
if (this.tickUnits) {
|
||||||
|
formatted += ' ' + this.tickUnits;
|
||||||
|
}
|
||||||
|
|
||||||
return formatted;
|
return formatted;
|
||||||
}
|
};
|
||||||
|
|
||||||
this.yaxis.tickFormatter = ctx.yAxisTickFormatter;
|
this.yaxis.tickFormatter = ctx.yAxisTickFormatter;
|
||||||
|
|
||||||
@ -262,6 +266,16 @@ 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";
|
||||||
|
if (angular.isNumber(settings.yaxis.tickSize)) {
|
||||||
|
this.yaxis.tickSize = settings.yaxis.tickSize;
|
||||||
|
} else {
|
||||||
|
this.yaxis.tickSize = null;
|
||||||
|
}
|
||||||
|
if (angular.isNumber(settings.yaxis.tickDecimals)) {
|
||||||
|
this.yaxis.tickDecimals = settings.yaxis.tickDecimals
|
||||||
|
} else {
|
||||||
|
this.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);
|
||||||
@ -491,9 +505,19 @@ export default class TbFlot {
|
|||||||
|
|
||||||
createYAxis(keySettings, units) {
|
createYAxis(keySettings, units) {
|
||||||
var yaxis = angular.copy(this.yaxis);
|
var yaxis = angular.copy(this.yaxis);
|
||||||
|
var tickDecimals, tickSize;
|
||||||
|
|
||||||
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;
|
if (angular.isNumber(keySettings.axisTickDecimals)) {
|
||||||
|
tickDecimals = keySettings.axisTickDecimals;
|
||||||
|
} else {
|
||||||
|
tickDecimals = yaxis.tickDecimals;
|
||||||
|
}
|
||||||
|
if (angular.isNumber(keySettings.axisTickSize)) {
|
||||||
|
tickSize = keySettings.axisTickSize;
|
||||||
|
} else {
|
||||||
|
tickSize = yaxis.tickSize;
|
||||||
|
}
|
||||||
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;
|
||||||
@ -504,6 +528,7 @@ export default class TbFlot {
|
|||||||
yaxis.max = max;
|
yaxis.max = max;
|
||||||
yaxis.tickUnits = units;
|
yaxis.tickUnits = units;
|
||||||
yaxis.tickDecimals = tickDecimals;
|
yaxis.tickDecimals = tickDecimals;
|
||||||
|
yaxis.tickSize = tickSize;
|
||||||
yaxis.alignTicksWithAxis = position == "right" ? 1 : null;
|
yaxis.alignTicksWithAxis = position == "right" ? 1 : null;
|
||||||
yaxis.position = position;
|
yaxis.position = position;
|
||||||
|
|
||||||
@ -549,7 +574,7 @@ export default class TbFlot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
yaxis.hidden = hidden;
|
yaxis.hidden = hidden;
|
||||||
var newIndex = -1;
|
var newIndex = 1;
|
||||||
if (!yaxis.hidden) {
|
if (!yaxis.hidden) {
|
||||||
this.options.yaxes.push(yaxis);
|
this.options.yaxes.push(yaxis);
|
||||||
newIndex = this.options.yaxes.length;
|
newIndex = this.options.yaxes.length;
|
||||||
@ -932,6 +957,16 @@ 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
|
||||||
|
},
|
||||||
|
"tickSize": {
|
||||||
|
"title": "Step size between ticks",
|
||||||
|
"type": "number",
|
||||||
|
"default": null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -990,6 +1025,8 @@ export default class TbFlot {
|
|||||||
"items": [
|
"items": [
|
||||||
"yaxis.min",
|
"yaxis.min",
|
||||||
"yaxis.max",
|
"yaxis.max",
|
||||||
|
"yaxis.tickDecimals",
|
||||||
|
"yaxis.tickSize",
|
||||||
"yaxis.showLabels",
|
"yaxis.showLabels",
|
||||||
"yaxis.title",
|
"yaxis.title",
|
||||||
"yaxis.titleAngle",
|
"yaxis.titleAngle",
|
||||||
@ -1014,10 +1051,10 @@ 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",
|
||||||
@ -1063,6 +1100,11 @@ export default class TbFlot {
|
|||||||
"type": "number",
|
"type": "number",
|
||||||
"default": 0
|
"default": 0
|
||||||
},
|
},
|
||||||
|
"axisTickSize": {
|
||||||
|
"title": "Axis step size between ticks",
|
||||||
|
"type": "number",
|
||||||
|
"default": null
|
||||||
|
},
|
||||||
"axisPosition": {
|
"axisPosition": {
|
||||||
"title": "Axis position",
|
"title": "Axis position",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -1076,7 +1118,7 @@ export default class TbFlot {
|
|||||||
},
|
},
|
||||||
"required": ["showLines", "fillLines", "showPoints"]
|
"required": ["showLines", "fillLines", "showPoints"]
|
||||||
},
|
},
|
||||||
"form": [
|
"form": [
|
||||||
"showLines",
|
"showLines",
|
||||||
"fillLines",
|
"fillLines",
|
||||||
"showPoints",
|
"showPoints",
|
||||||
@ -1089,6 +1131,7 @@ export default class TbFlot {
|
|||||||
"axisMax",
|
"axisMax",
|
||||||
"axisTitle",
|
"axisTitle",
|
||||||
"axisTickDecimals",
|
"axisTickDecimals",
|
||||||
|
"axisTickSize",
|
||||||
{
|
{
|
||||||
"key": "axisPosition",
|
"key": "axisPosition",
|
||||||
"type": "rc-select",
|
"type": "rc-select",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user