Pie Chart for two attributes of an entity

0
I have an entity DiskSpace and two attributes UsedSpace and FreeSpace. These attributes store % of free and used disk space, Consider its 30 used and 70 free. How can I make a pie chart for disk space showing free space 70% and used space 30%? In pie chart properties it takes only 1 name attribute and value attribute in “data points” section? How can I set it to take two attributes FreeSpace and UsedSpace and make a pie chart out of it. Like we can specify multiple series in other charts to plot multiple values on a axis.
asked
2 answers
2

Umar,

Pie chart only accepts one series.  So to plot those two values in a pie chart, you’ll have to create a separate entity and populate those values as separate objects in that entity with a label and a value.

Mike

answered
2

Hi Umar Shabbir!

Try using Google chart widget : https://appstore.home.mendix.com/link/app/2091/

Download Google chart widget.

Create a dataview with datasource as microflow and place Google piechart widget inside the dataview.

In Microflow, create an object (ex: Result) with one attribute of type string with the below JSON value and return this object. (Can be a non-persistent one too!)

{
"cols": [
       {"id":"","label":"Name","pattern":"","type":"string"},
        {"id":"","label":"Percentage","pattern":"","type":"number"}
       ],
 
"rows": [
        {"c":[{"v":"FreeSpace","f":null},{"v":'+$Diskspace/FreeSpace+',"f":null}]},
        {"c":[{"v":"UsedSpace","f":null},{"v":'+$Diskspace/UsedSpace+',"f":null}]}
             ]
}

Note: You can also add multiple rows to show values of multiple attributes. 

Now configure the Google pie chart widget with data source as shown below:

 

Now the Piechart gets generated with the rendered values of two different attributes!

Hope this helps!

Thanks!

 

 

 

answered