• Hi Guys,

    I followed this guide to develop a report using RDLC's and the ReportViewer in .NET, and the methods described here seemed to work, but after tweaking my chart I have gained valuable insight into how it works within visual studio 2008 and reportviewer 9 (I am assuming it will be the same in this environment).

    I made 2 parameters for the report, a “StartDate” and an “EndDate” with the format code of “dd MMM yyyy HH:mm”, and I retrieved all events which ran within those periods using my SQL statement. Once I had events, and the grouping the events belonged too, I was then ready to develop my Microsoft Report.

    I then went about implementing the methods described within the article referenced by this forum "Gantt charting for the holidays" and it worked as described, however immediately was confronted with the shortcomings described in David's article, such as grid lines on the chart, and was determined to overcome them as it was requirement of the report I had to generate for the application I am developing for work, and with the axis showing dates I knew I could get this working. I then began changing the chart and tweaking it with several different calculations until I scratched it and started the chart from scratch again.

    In the end I added the bar chart as described, reversed the x axis as described but did not create side margins, and instead of passing in a buffer parameter into the report, I passed in "StartDate" and "EndDate" parameters with the type of datetime (the same format code and values which were used to retrieve the charts events via the SQL statement), and used those as the min and max on the y axis. I then added my category grouping, and was ready to finalise my task by adding the "Values", so I decided to proceed cautiously with rigorous testing by displaying the data in a table above the chart.

    I added the start date of the task, and it seemed as though there would be a bar from the start of the chart to the date I wanted appearing perfectly, however what I wanted was for that bar to be white with the event coming after it, and another white bar to the end. I then went about fiddling with the calculations in several different ways, and by the end of the day had a solution to make the chart appear perfectly, with an understanding of how to replicate it whenever I wanted. The first bar goes to the start of the event, and is in the format of date.

    To accomplish this, I used the format code of “dd MMM yyyy HH:mm” for the start date Value (which is the first Value for the chart, and the only datetime Value which should be used).

    Then the second parameter was

    =DateDiff(DateInterval.Minutes, Fields!StartDate.Value, Fields!EndDate.Value)/1440

    To get an accurate decimal representation of the amount of days the event went for (The tricky part of the chart, which I couldn’t find documented anywhere). Then I used the following for the third Value:

    =DateDiff(DateInterval.Minutes, Fields!EndDate.Value, Parameters!EndDate.Value)/1440

    I coloured the first and third Value white, so it appeared as though they did not even appear on the graph at all, and the chart finally worked with only the events being coloured, and the events lining up perfectly with the grid lines and their dates, bringing me much satisfaction in my job as I was able to solve this problem without any repulsive calculations which will bring pain to my colleagues when it comes time to edit it to suit business requirements.

    I then was confronted with one final issue, if the start date of the task ran before the minimum Value on the y axis (the “StartDate” parameter), it would not be rendered into the chart. I managed to overcome this by modifying the SQL statement to return the “StartDate” parameter + 1 minute if the field was greater than or equal to the “StartDate” parameter, which immediately overcame that issue. This could also be accomplished using immediate if statements within the expression for the first Value in the chart as well via my testing. Hopefully this applies to SQL Server’s Microsoft Reporting, as what I read from your article successfully generated the chart you described.

    Kind regards

    Greg Goldberg