Dundas Charting Tips and Tricks > Using a chart as a subreport > How do I dynamically set chart axis min and max values?

Search the FAQ for entries containing:

Oftentimes an end user would like to have the ability to adjust the x-axis minimum, x-axis maximum, y-axis minimum, and y-axis maximum values dynamically using report parameters. This example shows how to do this from a Reporting Services report where the Dundas Chart is a subreport. The first thing we have to do is to add the four parameters to the main report itself.

Click to View Larger Image

Since this example uses the chart as a subreport you need to right-click on the chart which is a subreport,  click on Properties, click on the Parameters tab and fill in the parameters as seen below.

Click to View Larger Image

Now the final step is to double-click on the Dundas Chart which opens up its properties, and go to the X Axis tab as seen below.

Click to View Larger Image

By clicking on the fx to the right of the Minimum text box you can use the Expression editor and choose the Parameter from the list or you can just type in =Parameters!x_min.Value into the text box. You can do the same for the Maximum text box or just type in =Parameters!x_max.Value.

You will now click on the Y Axis tab and do the same thing but with the y_min and y_max parameters as seen below.

Click to View Larger Image

Now when you run the calling report which contains the Dundas chart as a subreport you will see prompts for the x_min, x_max, y_min, and y_max and the chart will reflect the changes. Here are the parameters when you run the report.

Click to View Larger Image

This sets the X and Y axes in the final chart as seen below.

Click to View Larger Image

Now if you go in and re-run the report and change the x_max value from 160 to 40 you will see the difference automatically in the chart.

Click to View Larger Image

This entry shows you how you can dynamically set the X and Y axes minimum and maximum values dynamically using parameters from within a Reporting Services report. If you chose not to use a Dundas chart as a subreport you could simply do the same thing but just create the parameters in the program that contains the Dundas Chart. Obviously setting the parameters by right-clicking on the subreport would not be needed.