This project is read-only.

FOXCharts - timespan in Y Axis,

Topics: General
May 21, 2009 at 10:19 PM

First, many thanks to everyone involved in Foxcharts, because it is something that was needed really desperately :-)

And question - I have a chart, where numeric values (on Y axis) represent time interval in seconds. I would like to show such values formatted as hours:minutes:seconds (eg. 90065 would be shown as "25:01:05") - on shape legends and also on Y axis scale. Is it possible? Format property is too limited for this and I don't know of any other possibility of transforming shown values.

 

May 21, 2009 at 11:04 PM

Hi,

I would construct a function to transform the numbers into your format, and call that function in your Chart.

A possible solution for such a function (please adjust with error catching)

*numbersToHMS

PARAMETERS tnSeconds
Local lnHour, lnMinutesec, lnMinute, lnSeconds
lnHour   = INT(tnSeconds/(60*60))
lnMinutesec = MOD(tnSeconds,60*60)
lnMinute = INT(m.lnMinutesec/60)
lnSeconds = MOD(m.lnMinutesec,60)
RETURN TRANSFORM(m.lnHour)+":"+PADL(TRANSFORM(m.lnMinute),2,'0')+":"+PADL(TRANSFORM(m.lnSeconds),2,'0')

 

May 22, 2009 at 6:19 AM

Well, I can write such function, but problem lies in that "call that function in your Chart". Could you be more specific on that? Where to call it? I've not found yet where such transformation should take place; but maybe I was looking in wrong places :-)

May 22, 2009 at 3:05 PM

OK, having the knowledge that it CAN be done, I found and successfully used method GetScaleLegend(). But one question remains - is it possible to do similar transformation for shape values legends?

May 22, 2009 at 10:21 PM
Edited May 22, 2009 at 10:37 PM

Kaven,

Suppose you have created a method in your form:

NumberToHMS

In FoxCharts.ShapeToolTip following code:

 This.ToolTip.Caption  = thisForm.NumbertoHMS(tnValue)

That should do what you are looking for.

 

 

 

May 24, 2009 at 6:34 AM

Hi,

    I have no objections to publish, but alas, I had no luck :-) I was sucessful in modifying the values on Y Axis - by changing method GetScaleLegend like this:

Lparameters tnScaleNumber, tnValue

IF (tnScaleNumber == -1) THEN

    **in fact I have no idea what the returned value means in this case; returning different constants had no effect

    RETURN DODEFAULT(tnScaleNumber, tnValue)

ENDIF

** returned value will be a string, not numeric!

RETURN SecsToHMS(tnValue) 

 

But I found no mean to modify shape value legends. In ShapeToolTip() it is possible to do an action just before tooltip is shown (typically changing tooltip caption like This.ToolTip.Caption = "xxxxx" as you recommended), but provide no mean to change shape values (those small numbers above each bar, that can be switched off by ShowValuesOnShapes = .F.). I fear that it is not possible in current version.

 

I've read somewhere that Cesar is going to give user a better control over shape legends, so maybe future versions will support this.

BTW: I received your mail, but I got all replies back  as undelivered. So I post the reply here now.

May 24, 2009 at 8:33 AM

Success!
graph
I finally managed to modify shape legends, but by a little hack. It means that it may stop working in next version; but as for me, it is sufficient that it works now.

The key was to redefine Chart.ShapeLegend._UpdateMeasures() method. The original _UpdateMeasures () method (which is called just before each shape legend is drawn) is already quite prepared for handling custom character data. The only thing I had to do was to take a value, and convert it to caption string if it was numeric. The code is as follows:

LPARAMETERS tlNumeric
**tlNumeric says if a numeric value from This._Value or character value from 
** This.Caption should be used

IF (tlNumeric) THEN
	This.Caption = SecsToHMS(This._Value)
	RETURN DODEFAULT(.F.)
ELSE
	RETURN DODEFAULT(tlNumeric)
ENDIF

 

May 24, 2009 at 8:59 PM

Hi,

Glad you solved.

Actualy this is the way to change any of the values in the chart.

 

 

 

May 25, 2009 at 11:39 PM

Hi Kaven and Koen,

 

Glad you made it work.

Later I hope to have a look at this, and I'll try to provide another solution for this case.

In fact, I do totally agree that FoxCharts should allow users to put some custom texts in the shapes.

Thanks !