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) {
|
||||
return this.ticksFormatterFunction(value);
|
||||
}
|
||||
|
||||
var factor = this.tickDecimals ? Math.pow(10, this.tickDecimals) : 1,
|
||||
formatted = "" + Math.round(value * factor) / factor;
|
||||
if (this.tickDecimals != null) {
|
||||
@ -248,10 +249,13 @@ export default class TbFlot {
|
||||
formatted = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision);
|
||||
}
|
||||
}
|
||||
if (this.tickUnits) {
|
||||
formatted += ' ' + this.tickUnits;
|
||||
return formatted;
|
||||
}
|
||||
|
||||
return formatted;
|
||||
};
|
||||
|
||||
this.yaxis.tickFormatter = ctx.yAxisTickFormatter;
|
||||
|
||||
if (settings.yaxis) {
|
||||
@ -262,6 +266,16 @@ export default class TbFlot {
|
||||
this.yaxis.labelFont.color = this.yaxis.font.color;
|
||||
this.yaxis.labelFont.size = this.yaxis.font.size+2;
|
||||
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) {
|
||||
try {
|
||||
this.yaxis.ticksFormatterFunction = new Function('value', settings.yaxis.ticksFormatter);
|
||||
@ -491,9 +505,19 @@ export default class TbFlot {
|
||||
|
||||
createYAxis(keySettings, units) {
|
||||
var yaxis = angular.copy(this.yaxis);
|
||||
var tickDecimals, tickSize;
|
||||
|
||||
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 min = angular.isDefined(keySettings.axisMin) ? keySettings.axisMin : yaxis.min;
|
||||
@ -504,6 +528,7 @@ export default class TbFlot {
|
||||
yaxis.max = max;
|
||||
yaxis.tickUnits = units;
|
||||
yaxis.tickDecimals = tickDecimals;
|
||||
yaxis.tickSize = tickSize;
|
||||
yaxis.alignTicksWithAxis = position == "right" ? 1 : null;
|
||||
yaxis.position = position;
|
||||
|
||||
@ -549,7 +574,7 @@ export default class TbFlot {
|
||||
}
|
||||
}
|
||||
yaxis.hidden = hidden;
|
||||
var newIndex = -1;
|
||||
var newIndex = 1;
|
||||
if (!yaxis.hidden) {
|
||||
this.options.yaxes.push(yaxis);
|
||||
newIndex = this.options.yaxes.length;
|
||||
@ -932,6 +957,16 @@ export default class TbFlot {
|
||||
"title": "Ticks formatter function, f(value)",
|
||||
"type": "string",
|
||||
"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": [
|
||||
"yaxis.min",
|
||||
"yaxis.max",
|
||||
"yaxis.tickDecimals",
|
||||
"yaxis.tickSize",
|
||||
"yaxis.showLabels",
|
||||
"yaxis.title",
|
||||
"yaxis.titleAngle",
|
||||
@ -1063,6 +1100,11 @@ export default class TbFlot {
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"axisTickSize": {
|
||||
"title": "Axis step size between ticks",
|
||||
"type": "number",
|
||||
"default": null
|
||||
},
|
||||
"axisPosition": {
|
||||
"title": "Axis position",
|
||||
"type": "string",
|
||||
@ -1089,6 +1131,7 @@ export default class TbFlot {
|
||||
"axisMax",
|
||||
"axisTitle",
|
||||
"axisTickDecimals",
|
||||
"axisTickSize",
|
||||
{
|
||||
"key": "axisPosition",
|
||||
"type": "rc-select",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user