Although most aspects of your legend are controlled by PopChart Server (or by preferences you set in the appearance file with PopChart Builder), you still control several aspects of your legends dynamically.
Items inside of a legend can be enabled for drill-down effects. For example, you could add a drill-down effect to Atlanta in the legend of the PopChart image that we created in Example 4.7.
For information about drill-down effects in general, see "Drill-down Effects" in Chapter 7.
To add drill-down to an item in the legend with PCScript, you should use the graph. DDEnable() method, just as you would for a data item in a graph (see "PCScript" in Chapter 7). The only difference is that you add the effect to category 0, which represents the legend.
For example, to add drill-down to the Atlanta item in a legend, you would use the following PCScript:
Graph.DDEnable(0, Atlanta, http://mycompany.com)
To add drill down for a legend item, you should add a Drilldown attribute to the Series element that corresponds to the legend item (Series is a subelement of GraphData). For example, to enable drill-down for the Atlanta legend item, the Series tag for Atlanta would look like this:
<Series Name="Atlanta" Drilldown="http://www.mycompany.com" />
Another useful feature is the ability to hide a legend. If your appearance file already contains a legend, but you don't want to show it in certain instances, you can use PCScript or PopChart XML to turn it off.
To hide a legend in PCScript, simply use the legend. Hide() method. For example, if your legend is named legend, you can make it disappear with the PCScript command from below.
To hide a legend in PopChart XML, simply override its Visible attribute to false. For example, if your legend is named legend, you could hide it with the following PopChart XML.
<Legend Name="legend" Visible="False" />
If your appearance file does not contain a legend, but you would like to add one, you can add a legend by declaring a new legend item in PopChart XML. For example, if you wanted to add a legend for the graph named graph, you could do it with the following tag:
<Legend Name="legend" GraphName="graph" Top="400" Left="10" Width="400" Height="50" />
Important: When you add a legend, be sure to associate it with a graph. You do this by setting the GraphName attribute to the name of the graph with which that the legend is associated. Also, be sure to give your legend a distinct name (one that is not already being used).