开发者

How to format timevalue to HH:MM:SS in datalabel

开发者 https://www.devze.com 2023-04-10 23:51 出处:网络
So i have a bar graph in crystal reports. On this graph i have a data label attached to each of the graphs that displays the value of the graph in seconds, which appears like so:

So i have a bar graph in crystal reports. On this graph i have a data label attached to each of the graphs that displays the value of the graph in seconds, which appears like so:

How to format timevalue to HH:MM:SS in datalabel

What i would like to do is format this data-label into a time formatting. So for each bar in the graph it would have the data-label appear in the following format:

HH:MM:SS.

i am able to get the time formatting to appear using the following formula:

local NumberVar Sec;
local NumberVar ss;
local NumberVar mm;
local NumberVar hh;
local StringVar SSS;
local StringVar MMM;

Sec := Sum ({GetAlarmSummaryDataSet2Response/GetAlarmSummaryDataSet2Result/Items/AlarmSummaryItem2.StopTime}, {GetAlarmSummaryDataSet2Response/GetAlarmSummaryDataSet2Result/Items/AlarmSummaryItem2.Section}) ;
hh := Int (Sec/3600);
mm :=Int ((Sec/60)- (60* Int(Sec/3600 )));
If mm<10 then MMM := "0" & ToText (mm,0)开发者_运维百科;
If mm>9 Then MMM := ToText(mm,0) ;

ss :=Sec-(3600 * hh ) - (60 * mm ) ;
If ss<10 then SSS := "0" & ToText (ss,0);
If ss>9 Then SSS := ToText(ss,0) ;

ToText ( hh,0) & ":" & MMM & ":" & SSS

But what i am unsure of is how to implement this formula onto a data label.

Any help or suggestions are greatly appreciated.

Thank you


You can choose to display the group name, and you can display and format the summarized value calculated by the chart, but you can't provide a custom formula. It just isn't possible using the chart library in CR XI.

My eventual workaround for this problem:

  1. Modify the value formula to eliminate the aggregate function. (This is necessary because Crystal won't allow an aggregate function in a group name field -- see #2.)
  2. For the group name, specify a formula with the text you want to display in the riser. Include both the label and the formatted value, separated by Chr(13) & Chr(10) to place them on separate lines.
  3. Configure the riser to display the label, not the value.

To apply this to your problem you'd need to make these changes:

  1. Eliminate the aggregate function. Of course I don't know if this will be possible using your setup. Perhaps if you're using a DBMS you could use a SQL command or a stored procedure to calculate the sum before the data reaches Crystal.
  2. Print the label and value together, either on the riser or the X-axis.

If that's not good enough for your application, you might consider CRChart, a commercial replacement which tries to address the sometimes-crippling limitations of Crystal's chart library. (I thought it was too pricey.) I think the @APPEND_DATATEXT macro would let you place a custom value on a riser, but you'd still need to move the summary to the server.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号