Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 setting Y-Axis Label by code

Author  Topic 

hashbang
Starting Member

1 Post

Posted - 2005-08-11 : 22:01:30
I am having difficulty setting the label for a chart's y-axis. I want the y-axis labels to show either "ON" or "OFF". The data I have is from a building management system, and it shows whether a device (air conditioner, security system) is on or off at a given time. What I wanted to show are multiple sensor states on top of each other. The data looks like:


SensorID BinaryState Date
-------- ----------- ----------------
106 0 1/1/2005 0:00:00
106 0 1/1/2005 1:00:00
106 0 1/1/2005 2:00:00
106 0 1/1/2005 3:00:00
106 1 1/1/2005 4:00:00
106 1 1/1/2005 5:00:00

22 0 1/1/2005 0:00:00
22 0 1/1/2005 1:00:00
22 1 1/1/2005 2:00:00
22 1 1/1/2005 3:00:00
22 1 1/1/2005 4:00:00
22 1 1/1/2005 5:00:00

38 1 1/1/2005 0:00:00
38 1 1/1/2005 1:00:00
38 1 1/1/2005 2:00:00
38 1 1/1/2005 3:00:00
38 0 1/1/2005 4:00:00
38 0 1/1/2005 5:00:00


Currently, in the y-axis format value, I have:


=code.ShowLabel(fields!binarystate.value)


This is the code for ShowLabel()


Function ShowLabel(byval i as integer) as string
IF i mod 2 = 0 then
return "OFF"
Else
return "ON"
End If
End Function


I added a rownumber to each binary value (this way the line graph does not overlap) and used this value as the y-axis. The above code results in the y-axis displaying "OFF".

If I change the ShowLabel() function to this:


Function ShowLabel(byval i as integer) as string
return "LINE: " & Cstr(i)
End Function


The y-axis actually shows the correct value:

LINE: 5
LINE: 4
LINE: 3
LINE: 2
LINE: 1

Why is it that the code is not firing when I use mod as in previous example of showLabel(). Btw - the X-axis is the [date] the reading was taken.

Any workarounds would be greatly appreciated.
   

- Advertisement -