Quantcast
Viewing all articles
Browse latest Browse all 3636

How to Manage property of Chart Expert and Chart Options for ChartObject using .NET RAS SDK.

Hello Friends,

 

I have created a ChartObject and added it to my sample Crystal Report at runtime using .NET RAS SDK. I have also added table at runtime. Here is the sample code:

 

           CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject myChartObject;

           CrystalDecisions.ReportAppServer.ReportDefModel.ChartStyle myChartStyle;

           CrystalDecisions.ReportAppServer.ReportDefModel.Section mySection;

           CrystalDecisions.ReportAppServer.DataDefModel.Fields myFields;

           CrystalDecisions.ReportAppServer.DataDefModel.Field myField;

           CrystalDecisions.ReportAppServer.DataDefModel.SummaryField mySummaryField;

            int myFieldIndex;

 

           CrystalDecisions.CrystalReports.Engine.ReportDocument reportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

          reportDocument.Load(Server.MapPath("/CrystalReport1.rpt"));

          ISCDReportClientDocument myReportClientDocument = reportDocument.ReportClientDocument;

 

          System.Data.DataSet ds = generatCR.createDataSet(_); //here I call method to create dataset

 

          //create xml file for CR

          ds.WriteXml(Server.MapPath("/dataset.xml"), XmlWriteMode.WriteSchema);

 

          CrystalDecisions.ReportAppServer.DataDefModel.ConnectionInfo connectionInfo = generatCR.getConnectionInfo(Server.MapPath("/dataset.xml")); //this is the method to get ConnectionInfo

 

           //creating able for CR - main (columns)

           ISCRTable table1 = DataSetConverter.Convert(ds).Tables[0];

           Table1.ConnectionInfo = connectionInfo;

           myReportClientDocument.DatabaseController.AddTable(table1, null);

           

           myFields = myReportClientDocument.DatabaseController.Database.Tables[0].DataFields;

 

           //Create a chart

           myChartObject = new CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject();

 

           //create a line chart style

           myChartStyle = new CrystalDecisions.ReportAppServer.ReportDefModel.ChartStyle();

           myChartStyle.Type = CrystalDecisions.ReportAppServer.ReportDefModel.CrChartStyleTypeEnum.crChartStyleTypeLine;

           

           //set the chart style to line chart

           myChartObject.ChartStyle = myChartStyle;

 

           //set the chart type to advanced chart

           myChartObject.ChartDefinition.ChartType = CrystalDecisions.ReportAppServer.ReportDefModel.CrChartTypeEnum.crChartTypeDetail;

 

           //set datetime field as condition field

           //get the datetime field

           myFieldIndex = myFields.Find("datetime", CrystalDecisions.ReportAppServer.DataDefModel.CrFieldDisplayNameTypeEnum.crFieldDisplayNameName,

CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleUserDefault);

           myField = (CrystalDecisions.ReportAppServer.DataDefModel.Field)myFields[myFieldIndex];

           myChartObject.ChartDefinition.ConditionFields.Add(myField);

           myField = null;

 

           //set value as data field

           //get {value field}

           myFieldIndex = myFields.Find("value",

CrystalDecisions.ReportAppServer.DataDefModel.CrFieldDisplayNameTypeEnum.crFieldDisplayNameName,

CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleUserDefault);

           myField = (CrystalDecisions.ReportAppServer.DataDefModel.Field)myFields[myFieldIndex];

 

           //create a Sum({Customer.Last Year's Sales})

           mySummaryField = new CrystalDecisions.ReportAppServer.DataDefModel.SummaryField();

           mySummaryField.SummarizedField = myField;

           mySummaryField.Operation = CrystalDecisions.ReportAppServer.DataDefModel.CrSummaryOperationEnum.crSummaryOperationSum;

           mySummaryField.Type = myField.Type;

 

           //add summary field to report client document

           myReportClientDocument.DataDefController.SummaryFieldController.Add(-1, mySummaryField);

           myChartObject.ChartDefinition.DataFields.Add(mySummaryField);

 

           //set chart coordinates and dimensions

           myChartObject.Left = 0;

           myChartObject.Top = 15 * 15; //1px = 15 twips

           myChartObject.Width = 980 * 15; 

           myChartObject.Height = 500 * 15;

 

           //get report header section

           mySection = myReportClientDocument.ReportDefinition.ReportHeaderArea.Sections[0];

 

           //set chart report area to report header

           myChartObject.ChartReportArea = CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindReportHeader;

 

           //add chart in the report header

           myReportClientDocument.ReportDefController.ReportObjectController.Add(myChartObject, mySection, -1);

 

           //Set the ReportSource of the viewer to the report in Session

           Session["myReport"] = reportDocument;

           CrystalReportViewer1.ReportSource = Session["myReport"];

           CrystalReportViewer1.DataBind();

 

Above code is working fine for me and creates a simple line chart.

 

Now I want to modify chart options, data, text, axis and want to use sub category of Line Chart for e.g. "Line chart with markers data points" using code. I want to know how I can performs modifications in a chart through code which I can do through chart expert and chart options.

 

Please tell me where I can get more instructions about classes and methods to fulfill my requirements.

 

Following pictures can clear my question:

 

 

Image may be NSFW.
Clik here to view.
nm1.png

Image may be NSFW.
Clik here to view.
nm1.png

 

Image may be NSFW.
Clik here to view.
nm1.png

 

etc.

 

Please guide me, how I can do that. I will be very thankful to you.

 

Thanks and Regards,

Namrata Mathur


Viewing all articles
Browse latest Browse all 3636

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>