Hello,
I have a doubt with the formatting of labels in a pie chart:
The data for the pie chart has two columns: EventName and Duration where Duration is in seconds.
Is there a way to format the label to display the duration like “hh:mm:ss”?
I tried to write an expression binding for the “labelFormat” property, but without success ![:cry: :cry:](http://forum.inductiveautomation.com/images/emoji/twitter/cry.png?v=6)
Thank you
You have to format it in the binding. For example, if the data is bound to a SQL query you can do something like:SELECT DATE_FORMAT(t_stamp, '%h:%i:%s'), duration FROM table
That function above exists in MySQL so it might be different depending on your database.
Thank you Travis,
Yes, I thought about that, but the problem is that Duration is precisely the quantity that is being graphed, and I might have troubles if I cast it into a string, isn’t it?
No, you just want to alter the first column which is the name of each wedge. Leave the duration column alone. It will be a numeric value.
Mmmh, yes, it can work but I’d loose the Event Name, perhaps I can concatenate the Event Name and the formatted duration.
I think it would be great that the labelFormat property could accept formatting codes, something like:
“{1:d}” or “{1:format(‘hh:mm:ss’)}” or “{1:#,##0}” or something like that.
I see. You would have to concatenate the two values since there is a single display for each wedge.
Thank you very much Travis