Email: Password:       Forgot Password 
    .netCodeSG
A Saarsha Group Online Community for dot net codes group like C#, Asp.NET, VB.NET, Sharepoint, JavaScript, JQuery, Ajax, SQL, WCF, WPF.
 
TECHNOLOGIES:
 

Crystal Report Showing Graphical Representation of Data

Article:
Viewed:  2130 
Posted On:  21/09/2014 01:38:18 
How we can show our data as chart in crystal Report ? 

 

In this article I am going to show how we can show our data in chart form in a crystal report. Here in this example I am going to show data fromResourceManagement Table design as below.

1.png

Image 1.

Data in my table.

2.png

Image 2.

Now Open Visual Studio -> File -> New -> Web Site. -> Select ASP.Net website -> OK

3.png

Image 3.

Now Right Click on Solution Explorer -> Add New Item -> Select Crystal Report

4.png

Image 4.

5.png

Image 5.

Here click on Create New Connection -> Select OLE DB (ADO) -> Double Click here A Popup window will open.

6.png

Image 6.

Select Microsoft OLE DB Provider for SQL Server here.

7.png

Image 7.

Here give your SQL Server information and select your DB.

8.png

Image 8.

9.png

Image 9.

Now Select your DB -> Select your Data Table and move it into Right side.

10.png

Image 10.

Now select your Data Column and Click on Finish.

11.png

Image 11.

Now we will do some setting to show data graphically. Right Click On Page Header and Details And click on -> Suppress to hide because we are showing here only Chart.

Not in Menu -> Crystal Report -> Insert -> Chart

12.png

Image 12.

 In Type Unchecked Automatically set chart options. Now here Select Bar

13.png

Image 13.

Now click Data. Here select onChangeNow Select your fields to show in chart.

14.png

Image 14.

Now Select Axes and do the below settings.

15.png

Image 15.

Now select Options and select format.

16.png

Image 16.

Color_1.png

Image 17.

Now set Text font etc.

17.png

Image 18.

Now Drag a Report Viewer on your aspx page:

Drag.png

Image 19.

Now aspx is:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
    Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Chart in Crystal Report</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"
            DisplayGroupTree="False" />
    </div>
    </form>
</body>
</html>

aspx.cs is:

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using CrystalDecisions.CrystalReports.Engine;
 
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        ReportDocument cryRpt = new ReportDocument();
        cryRpt.Load(Server.MapPath("ResourceManagementReport.rpt"));
        CrystalReportViewer1.ReportSource = cryRpt;
    }
}

Now Run application:

Output.png

Image 20.

If your chart is not displaying the in web.config do the following change?

<httpHandlers>
      <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304" />
</httpHandlers>

  Comment:
         HOME   |   Submit Article   |   Contact Us   |   About Us   |   Terms & Condition   |   Advertise With us