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

和自甴很熟 提交于 2019-12-20 03:28:11

问题


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

  • Placing the chart inside 1st row of Tablix. This didn't aligned it properly.

  • We have read that we can use DynamicWidth and DynamicHeight property of chart, but we don't know how to use it.

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


回答1:


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.



来源:https://stackoverflow.com/questions/22658791/how-do-i-align-the-width-of-chart-with-the-width-of-tablix-in-ssrs-2008-r2-or

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!