Search code examples
reporting-servicesssrs-2008reportingssrs-2008-r2ssrs-2012

Reporting Services dynamic chart width


I have a bar chart that can display various number of bars depending on user multi-select. How do I get the bar chart to dynamically adjust to the number of bars being displayed? The only solutions I found online were dated 2008 and weren't good solutions either, surely there must be a proper way of doing this?

Thanks


Solution

  • While I was about to rubbish such an idea, as it is known that you cannot dynamically change table sizes and locations, it seems Reporting Services is wonderfully inconsistent.

    If you look in the Properties of the chart there is a field called DynamicWidth, which will, as suggested, dynamically change the width of the chart based on a value.

    For example I have set a parameter called Offset to default to 10.

    You can then set the value of DynamicWidth to

    =CStr(Parameters!Offset.Value) + "cm"
    

    Then, as you change the Offset parameter, the width of the chart changes.

    DynamicWidth = 10

    enter image description here

    And

    DynamicWidth = 20

    enter image description here

    Now how you calculate the width to be meaningful and consistent is up to you (perhaps a permanent value for the size + (number of columns * column width)), but this should get you started.

    Note that a DynamicWidth of 0 causes the report not to render.