cancel
Showing results for 
Search instead for 
Did you mean: 

XML Fragment: Problem with formatter for BarChart [Float required]

0 Kudos

Hi UI5 experts,

I'm struggling now for a long time building an UI5 app with bar charts. The formatter assignment in the XML fragment crashes (UI5 application hangs). The chrome debugger shows "string existing, float required".

I searched now for a long time SCN and Stackoverflow.

My project has following structure.

App -> controller

App -> view

App -> util -> formatter.js

UI5 Worklist -> jump to detail -> "Object.js" is the view controller for view "Object.view.xml".

[Object.js]
========

sap.ui.define([ "ns/controller/BaseController", "sap/ui/model/json/JSONModel", "sap/ui/core/routing/History", "ns/util/formatter" ],

function ( BaseController, JSONModel, History, formatter ) { "use strict"; return BaseController.extend("vjtf.controller.Object",{

formatter: formatter,

...

My XML view embedds the XML fragment as follows:
============

<content>

<core:Fragment id="Time" fragmentName="ns.view.Time" type="XML" /> </content>

...

Formatter:
========

sap.ui.define([], function() { "use strict"; return {

getFloat: function(sValue) {

var oNumberFormat = sap.ui.core.format.NumberFormat.getFloatInstance({ maxFractionDigits: 2, groupingEnabled: true, groupingSeparator: ",", decimalSeparator: "." }); return oNumberFormat.parse(sValue); },

===============

In the fragment i want to use the BarChart:
TimeSecMin = String with e.g. "34.00", contains data because label to BarChart is showing value !

<BulletMicroChartData value="{path: 'TimeSecMin', formatter : '.formatter.getFloat'}" color="Error"/>

!!! --- !!!

Indipending from which UI5 control I use, InteractiveBarChart, Bullet, what else, my formatter is not working or not called correctly. I think my dependency formulation is correct.

!!! --- !!!

All SCN entries describe the above way to use a formatter in an XML fragment.

My fragment is not instanciated programmatically ! So I'm not able to deliver "this" as the controller object into the XML fragment, where I want to use the formatter.

1.) Does anybody see a problem in my code approach?
2.) Does anybody has a reference code for an XML fragment - not instanciated by program - only embed into / called from the main view as I did - using a Chart with float variable?

Thanks in advance
Klaus Wegener

Accepted Solutions (0)

Answers (0)