1
votes

May I ask can xpages display data similar to fraction format?

We have to develop a web application using domino designer version 8.5.2.

One of our task is to display data in fraction format(or similar).

Please imagine the following scenario/case:

There are several groups of people, e.g. Group A, Group B, Group C and Group D

Each group has different number of people, e.g. Group A has 10 people, Group B has 30 people, Group C has 15 people and Group D has 26 people

There are several activities, e.g. Activity 1, Activity 2, Activity 1, Activity 3, Activity 4, Activity 5

We would like to know the number of people in a group joined each activity and have a statics show in percentage.

For example, the result would be look like something like this:

sample

However, we are not sure whether it is possible to do this in xpages.

We did some research and read books but we do not have any proper or relevant results at the moment yet.

Therefore I would like to seek your advice or suggestion on this issue please. Thank you very much.

Regards,

beginner

Edit - Update

After receive two answers, we have an idea about display 29/50. we try the following experiment and it can show 29/50.

Here is our attempt: (in computed field, the converter is xp:convertNumber. The value is javascript and the code looks like this:)

var num1 = "3";
var num2 = "10";
return num1  + "/" + num2;

The result can display 3/10 because we set the exact numbers(num1 and num2) in javascript.

But what about if num1 and num2 are dynamic number or retrieve the number from a view?

We are currently try to solve this issue.

Grateful for your advice please. Thank you very much.

2

2 Answers

5
votes

Yes you can, by using number converters. For example here are some computed fields whose values are calculated as fractions, but displayed as percentages:

<xp:text escape="true" id="computedField1" value="#{javascript:return 29/30;}">
    <xp:this.converter>
        <xp:convertNumber type="percent"></xp:convertNumber>
    </xp:this.converter>
</xp:text>
<xp:br />
<xp:text escape="true" id="computedField2" value="#{javascript:return 12/30;}">
    <xp:this.converter>
        <xp:convertNumber type="percent"></xp:convertNumber>
    </xp:this.converter>
</xp:text>
<xp:br />
<xp:text escape="true" id="computedField3" value="#{javascript:return 15/30;}">
    <xp:this.converter>
        <xp:convertNumber type="percent"></xp:convertNumber>
    </xp:this.converter>
</xp:text>

This will output:

97%
40%
50%
1
votes

You can do fractions like: 110 using code like this <sup>1</sup>&frasl;<sub>10</sub>