jaczjill
jaczjill

Reputation: 334

How do I align the width of chart with the width of Tablix in SSRS 2008 R2 ? OR how to use DynamicWidth Property?

I am in a mid of creating a SSRS report, the report consists of a tablix and a chart, both depicts same data i.e. same database query.

The actual number of columns of the Tablix is dynamically decided by the number of rows returns by the query. We are displaying records in a COLUMN-WISE manner.

Example:
If 5 records are returned by the query then 5 columns will be displayed in Tablix...
If 8 records are returned by the query then 8 columns will be displayed in Tablix...

The number of records returned by the query is dynamic, hence the width of Tablix is dynamic.


Now about the chart, the width of chart always remains fixed, but we want that it should be same as the width of tablix, that means we require the bars of the Bar-chart should be aligned with the columns of the Tablix as each bar of chart depicts data in each column of Tablix.

We can manually change the width of chart, but it doesn't always gets aligned with the width of Tablix.


What we have tried which didn't worked

Anyone knows how do we align chart with dynamic width Tablix?

Upvotes: 2

Views: 4494

Answers (1)

Nathan Griffiths
Nathan Griffiths

Reputation: 12756

The number of columns is dynamic, but you know the width of each column as all the dynamic columns will be the same width. You also know the number of rows in your Dataset, so you can use an expression in DynamicWidth to make the chart width equal to the sum of the column widths.

For example if your dynamic columns are 2.5cm width and you have a dataset called Dataset1 then the expression for DynamicWidth property of the chart would be:

=2.5*CountRows("DataSet1") & "cm"

If you have any static columns in the table then you'll also need to add the width of those to the expression.


Having said all that, you mention aligning the bars of the bar chart with each column. If you want a single bar associated with the value in each column then alternatively you can look at adding a column oriented Data Bar inside a cell in your dynamic column, instead of the separate chart.

Upvotes: 1

Related Questions