|
|
|
@ -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,9 +249,12 @@ export default class TbFlot { |
|
|
|
formatted = (precision ? formatted : formatted + ".") + ("" + factor).substr(1, this.tickDecimals - precision); |
|
|
|
} |
|
|
|
} |
|
|
|
formatted += ' ' + this.tickUnits; |
|
|
|
if (this.tickUnits) { |
|
|
|
formatted += ' ' + this.tickUnits; |
|
|
|
} |
|
|
|
|
|
|
|
return formatted; |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
this.yaxis.tickFormatter = ctx.yAxisTickFormatter; |
|
|
|
|
|
|
|
@ -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", |
|
|
|
@ -1014,10 +1051,10 @@ export default class TbFlot { |
|
|
|
|
|
|
|
static datakeySettingsSchema(defaultShowLines) { |
|
|
|
return { |
|
|
|
"schema": { |
|
|
|
"schema": { |
|
|
|
"type": "object", |
|
|
|
"title": "DataKeySettings", |
|
|
|
"properties": { |
|
|
|
"title": "DataKeySettings", |
|
|
|
"properties": { |
|
|
|
"showLines": { |
|
|
|
"title": "Show lines", |
|
|
|
"type": "boolean", |
|
|
|
@ -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", |
|
|
|
@ -1076,7 +1118,7 @@ export default class TbFlot { |
|
|
|
}, |
|
|
|
"required": ["showLines", "fillLines", "showPoints"] |
|
|
|
}, |
|
|
|
"form": [ |
|
|
|
"form": [ |
|
|
|
"showLines", |
|
|
|
"fillLines", |
|
|
|
"showPoints", |
|
|
|
@ -1089,6 +1131,7 @@ export default class TbFlot { |
|
|
|
"axisMax", |
|
|
|
"axisTitle", |
|
|
|
"axisTickDecimals", |
|
|
|
"axisTickSize", |
|
|
|
{ |
|
|
|
"key": "axisPosition", |
|
|
|
"type": "rc-select", |
|
|
|
@ -1405,4 +1448,4 @@ export default class TbFlot { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* eslint-enable angular/angularelement */ |
|
|
|
/* eslint-enable angular/angularelement */ |
|
|
|
|