When you create your appearance file in PopChart Builder, you are able to customize the general appearance of your scales in the various scale properties dialogs. In most cases, you will provide the appearance file with several preferences regarding the appearance of your scale labels, and then elect to have PopChart Server automatically format your scale labels.
Most of the time, PopChart Server will automatically format your scales and scale labels in such a manner as to keep them meaningful and visually appealing. In certain situations, though, you may want to manually format your scale labels.
Scales appear along the sides and bottom of your graph area. They help identify data items and their values. Along each scale are several tick marks, which correspond to gridlines in the area behind the graph. At each major tick mark (the larger ones), there will be a scale label.
Note: There are also a number minor tick marks between each major tick mark. You cannot control the format of minor tick marks dynamically.
There are two main types of scales: category scales and value scales.
The category scale is almost always along the bottom of the graph (the exception being Horizontal Bar graphs). Scale labels and tick marks along category scales, of course, correspond to categories. You cannot format a category scale dynamicallyhowever, you can customize the behavior of your category scale in PopChart Builder (see "Scale Label Adjustments" in Chapter 1 of the PopChart Builder User Guide).
Value scales are used to indicate the value of a certain data item. In graphs that use categorical data, there will be one value scale, either on the left or right of the graph. Line Bar graphs also have a secondary value scale for the scale that appears on the right. In plot graphs, there are two value scales: one on the bottom and one on the side. Dual y scale graphs also have a y2 scale opposite of the main value scale.
The range of your value scales greatly affects the look of your graph, as the size of your data items depend upon the scale range. For example, a bar value of 78 in a scale range of 0-80 would go almost to the top of the graph, while in a scale range of 50-500 it would barely be visible. Likewise, a bar with the value of 40 would be invisible in a range of 50-500, while it would be cut off in a range of 0-30.
When you adjust the formatting of a value scale in PCScript, you will use the graph. SetScale() method. The first parameter of this method will always be the name of the scale that you want to dynamically adjust. These names are pre-set, and are as follows:
value | Main value scale. |
---|---|
svalue | Secondary value Scale |
x | X Scale |
y | Y Scale |
y2 | Secondary y scale |
time | Time scale |
Automatic scaling is a convenient feature that is turned on by default in most appearance files. But for those who always like to know what PopChart Server is doing, it can be somewhat confusing.
When your scale range is set to automatic, PopChart Server looks for the highest and lowest data item and makes sure that the scale is at least n percent higher and n percent lower than those data items (n is set by the appearance file, and is usually 10). By default, most graphs are set so that the base of the scale is zero, unless there is a negative data item.You can adjust these settings in your appearance file with Scale Properties menus in PopChart Builder.
PopChart Server will also adjust the starting and ending points, as well as the scale labels, so that they are on nice, even numbers, such as multiples of ten or twenty or one hundred. The exact numbers it chooses will depend on the overall range for your data.
When you use the graph. SetScale() in conjuction with automatic scaling, you can provide PopChart Server with a few other preferences that affect the way it determines scales. You can send it a maximum and minimum value for the scale range, as well as a limit to how many tick marks should be shown. PopChart Server will set the scale so that it is no smaller than the range you provided with the maximum and minimum values. It will still try to even out the range so that the scale labels are still nice, round numbers. It will ignore the maximum or minimum value if the size of the scale would have been larger without the specified maximum or minimum value. PopChart Server will also make sure that there are no more tick marks than the number you specified, although there may be less.
To use automatic scaling in PCScript, simply set the second argument of graph. SetScale() to auto. The third parameter you specify should be the maximum value for the scale. The fourth parameter, which is optional, should be the minimum value. The fifth parameter, which is also optional, should be the maximum number of ticks.
For example, to tell PopChart Server to use automatic scaling on the y scale with a maximum value for the scale range of 195, a minimum value of 95, and a maximum number of ticks value of 8, you would use the following command.
graph.setScales(y, auto, 195, 95,8)
To use automatic scaling, set the value of the SetScaleValues attribute in your graph's ValueScale element to Automatically. Then set the following attributes: MinimumValue, MaximumValue, and MaximumMajorTicks. You may also be interested in these attributes: PercentUnderMinValue, PercentOverMaxValue, and SetScaleBaseToZero.
You can also manually set the range of your scales. Fortunately, PopChart Server's behavior in this case is much more intuitive. The values you set for maximum, minimum, and number of ticks is exactly what PopChart Server will end up using.
To manually set the range of a scale, you will set the second parameter of graph. SetScale() to manual and the third parameter to the maximum value of the scale range. If you want to set a minimum value for a range, simply include a fourth parameter specifying the minimum value. To set the number of major ticks in your graph, you can also set a fifth parameter.
For example, to set the maximum value of your value scale range to 1000, you would use the following command.
graph.setScale(value,manual,1000)
If you wanted to set the range of the scale along the x-axis of an X-Y graph to 500-1000, you would use the following command.
graph.setScale(value,manual,1000,500)
Finally, to set the number of major tick marks that will appear in your graph to 8, you would use the following command.
graph.setScale(manual,1000,500,8)
You can also manually set the range in PopChart XML. To do this, simply override the MaximumValue, MinimumValue, and ManualMajorTicks attributes of a graph's ValueScale element. You will also need to set the SetScaleValues attribute to Manually, as shown below.
<ValueScale Position="Left" SetScaleValues="Manually" MaximumValue="1000" MinimumValue="500" ManualMajorTicks="8" />
A new feature in PopChart Server 4.0.5 is logarithmic scales. These allow you to better graph large ranges of data values.
You can enable logarithmic scales in an appearance file by selecting Use Logarithmic Scales from the General pane of a Value Scale Properties dialog.
You can enable logarithmic scales dynamically in PopChart XML by setting the UseLogScale attribute of your ValueScale element to True.