Create Chart in SSRS(RDLC) Report

Sksamantaray
Posted by in ASP.NET category on for Beginner level | Points: 200 | Views : 21795 red flag

In this article ,we will see how to create a Chart in SSRS(RDLC) Report.

Introduction

Asp.Net provides a wonderful reporting tool using which we can create different kinds of charts like Line chart, bar chart,pie chart etc. in addition to tabular reports.

Objective
To create a column chart to show category-wise total sale made.

 

Requisites

1.Create a Procedure to fetch the required data for your report.
2.Add a Chart Control to report file i.e RDLC file and the fields to it.
3.Report-viewer to run the Report 
 

Using the code

// 1. Procedure to fetch product-wise sales amount                                                                  create procedure spProductDetails
as
Begin
select Categories.CategoryName ,Total=sum((Quantity *
 [Order Details].UnitPrice-Discount ) )from [Order Details] ,Products,Categories 
where products.ProductID=[Order Details].ProductID and Categories .CategoryID=Products .CategoryID 
group by Categories.CategoryName   
End                                                                                   
// 2.Add Chart Control to RDLC                                                         
Add an appropriate chart control to the Rdlc file, in this article i have added a column chart.Then drag the categoryname field to the category axis and total to value box as shown in the diagram below and save the file


//3.Add a Report Viewer to the ASPX page from the toolbox                            <form id="form1" runat="server">
    <div>
    
        <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" 
            Font-Size="8pt" Height="400px" Width="674px">
            <LocalReport ReportPath="Report.rdlc">
                <DataSources>
                    <rsweb:ReportDataSource DataSourceId="ObjectDataSource1" 
                        Name="DataSet3_spProductDetails" />
                </DataSources>
            </LocalReport>
        </rsweb:ReportViewer>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" 
            TypeName="DataSet3TableAdapters.spProductDetailsTableAdapter">
        </asp:ObjectDataSource>
    
    </div>
    </form>                                
Run the Report, you will have the following output.

Conclusion

From the above discussion it is very much clear that creating a chart in SSRS (RDLC) is an easy task. In this  way we can add different kinds of charts as per requirement.


Page copy protected against web site content infringement by Copyscape

About the Author

Sksamantaray
Full Name: Sanjaya Kumar Samantaray
Member Level: Silver
Member Status: Member
Member Since: 11/6/2011 3:05:05 PM
Country: India
Thanks, Sanjay

Wipro Technology

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)