[英]SAPUI5 Line Chart (vizframe) Formatter function not found
I want to format
my time axis
at the sapui5 line chart
with a formatter
. 我想
format
我的time axis
在sapui5 line chart
与formatter
。 With the following code 用下面的代码
dimensions: [{
name: 'time',
value: "{path:'_time', formatter: '" + Formatter.formatTime + "'}"
}],
appears this error: 出现此错误:
formatter function function (time) {
console.warn(time);
var r = time.toLocaleTimeString();
return r;
} not found! -
My formatter.js looks like this: 我的formatter.js看起来像这样:
sap.ui.define([
], function () {
"use strict";
var me = this;
return {
splitThingType: function (type) {
var t = type.split(':')[1];
return t;
},
formatTime: function (time) {
console.warn(time);
var r = time.toLocaleTimeString();
return r;
}
}
});
If I don't use a formatter the chart works but doesn't look that good. 如果我不使用格式化程序,则该图表可以运行,但效果却不佳。
You can use this approach to use formatter in your view. 您可以使用此方法在视图中使用格式化程序。 This is how I usually do.
我通常就是这样。
Step 1: In your view's controller, define formatter. 步骤1:在视图的控制器中,定义格式化程序。 Like:
喜欢:
sap.ui.define(["sap/ui/core/mvc/Controller", "yourFormattersPath/formatter"],
function(Controller, formatter) {
"use strict";
return Controller.extend("com.MyController", {
formatter: formatter,
onInit: function(){
}
});
Step 2: Provide reference in your view where you want to use formatter to format value. 步骤2:在您要使用格式化程序格式化值的视图中提供参考。
dimensions: [{
name: 'time',
value: "{path:'_time', formatter:'.formatter.formatTime'}"
}],
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.