How do I align the width of chart with the width o

2019-02-26 13:26发布

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条回答
叼着烟拽天下
2楼-- · 2019-02-26 13:49

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.

查看更多
登录 后发表回答