cancel
Showing results for 
Search instead for 
Did you mean: 

ReportAppServer.ReportDefModel.ChartObject

Former Member
0 Kudos

I am using CRVS2010 and trying to get access to the text of the x and y axis in a graph.

Using the ReportAppServer.ReportDefModel.ChartObject I do not see a way to do this.

I need to get to this text in order to provide foreign language support at runtime.

Is there someway I can do this ?

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Doyle,

Our Charting dll is a third party dll so it's limited in what you can get to. In CR Designer right click on the chart and Select Chart Expert. Those are the only option that at one time could be accessed but in .NET it's even less now.

You may have to do this in CR Designer using formula to replace the characters.

I do have this sample code to add a chart at runtime. I may work for you also, delete your existing chart and add this code ti add the new one...


private void AddChart_Click(object sender, EventArgs e)
{
    CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject boChartObject;
    CrystalDecisions.ReportAppServer.ReportDefModel.ChartStyle boChartStyle;
    CrystalDecisions.ReportAppServer.ReportDefModel.Section boSection;
    CrystalDecisions.ReportAppServer.DataDefModel.Fields boFields;
    CrystalDecisions.ReportAppServer.DataDefModel.Field boField;
    CrystalDecisions.ReportAppServer.DataDefModel.SummaryField boSummaryField;
           
    int boFieldIndex;

    rpt.Load("D:\\CPP Net\\RASXIR2Printer2K8\\rcapi_cs_add_chart\\SimpleRCAPIReport.rpt");
    rptClientDoc = rpt.ReportClientDocument;
 
    boFields = rptClientDoc.DatabaseController.Database.Tables[0].DataFields;

    //Create a chart
    boChartObject = new CrystalDecisions.ReportAppServer.ReportDefModel.ChartObject();
    //create a bar chart style
    boChartStyle = new CrystalDecisions.ReportAppServer.ReportDefModel.ChartStyle();
    boChartStyle.Type = CrystalDecisions.ReportAppServer.ReportDefModel.CrChartStyleTypeEnum.crChartStyleTypeBar;
    //set the chart style to bar chart
    boChartObject.ChartStyle = boChartStyle;

    //set the chart type to advanced chart
    boChartObject.ChartDefinition.ChartType = CrystalDecisions.ReportAppServer.ReportDefModel.CrChartTypeEnum.crChartTypeDetail;
    //set Customer Name field as condition field
    //get the Customer Name field
    boFieldIndex = boFields.Find("Customer Name",
        CrystalDecisions.ReportAppServer.DataDefModel.CrFieldDisplayNameTypeEnum.crFieldDisplayNameName,
        CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleUserDefault);
    boField = (CrystalDecisions.ReportAppServer.DataDefModel.Field)boFields[boFieldIndex];
    boChartObject.ChartDefinition.ConditionFields.Add(boField);
    boField = null;
    //set Last Year's Sales as data field
    //get {Customer.Last Year's Sales field}
    boFieldIndex = boFields.Find("Last Year's Sales",
        CrystalDecisions.ReportAppServer.DataDefModel.CrFieldDisplayNameTypeEnum.crFieldDisplayNameName,
        CrystalDecisions.ReportAppServer.DataDefModel.CeLocale.ceLocaleUserDefault);
    boField = (CrystalDecisions.ReportAppServer.DataDefModel.Field)boFields[boFieldIndex];
    //create a Sum({Customer.Last Year's Sales})
    boSummaryField = new CrystalDecisions.ReportAppServer.DataDefModel.SummaryField();
    boSummaryField.SummarizedField = boField;
    boSummaryField.Operation = CrystalDecisions.ReportAppServer.DataDefModel.CrSummaryOperationEnum.crSummaryOperationSum;
    boSummaryField.Type = boField.Type;
    //add summary field to report client document
    rptClientDoc.DataDefController.SummaryFieldController.Add(-1, boSummaryField);
    boChartObject.ChartDefinition.DataFields.Add(boSummaryField);
    //set chart coordinates and dimensions (0, 0), width = 7 inches, height = 5 inches
    boChartObject.Left = 0;
    boChartObject.Top = 0;
    boChartObject.Width = 7 * 1440;      // 1 inch = 1440 twips
    boChartObject.Height = 5 * 1440;
    //get report header section
    boSection = rptClientDoc.ReportDefinition.ReportHeaderArea.Sections[0];
    //set chart report area to report header
    boChartObject.ChartReportArea = CrystalDecisions.ReportAppServer.ReportDefModel.CrAreaSectionKindEnum.crAreaSectionKindReportHeader;
    //add chart in the report header
    rptClientDoc.ReportDefController.ReportObjectController.Add(boChartObject, boSection, -1);
    MessageBox.Show("Chart Added", "RAS", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

Don

Former Member
0 Kudos

Hi,

I did as you described but in my report data point is not shown. How can I solve this problem? Help pease ...

Answers (1)

Answers (1)

Former Member
0 Kudos

Thanks Don , Can you point me to the part of the api where I can get to the formula(s) ?

0 Kudos

Hi Doyle,

Sorry I just remembered that API was not made available in the .NET SDK, it was exposed in the RDC...

Do you have Cr 2008 or CR 2011? You can set the Local and Language in the Designer and that text is dynamic I believe so if the data converts to another language then CR should display the other language also.

If it's static text then only other option is to possible use a formula set the language. I'll check with the report Design team to see if they know of how to...

Thanks again

Don

Former Member
0 Kudos

All the RAS dlls we are referencing have a Product Version of 13.0.1.220... Thanks Don

0 Kudos

Correct...

I checked with the design team and they suggested another way, create your chart off of a formula. The X and Y labels can then be edited using the Formula and Text Object API's.

Don

Former Member
0 Kudos

Don, I think the light bulb just went on for me. I was expecting the ChartObject.ChartStyle.TextOptions to present X and Y label text properties per the VISUAL STUDIO properties window on the Graph !!! Now that I open the Chart in Design view and Select Chart Options I see that the designer presents the Y axis labeled Group Title and the X axis as Data Title and there are properties for both of these on ChartObject.ChartStyle.TextOptions.

This may be easier than we thought.

Can you take a look at my other thread of today were I am getting an error on getting a reference to a ISCDReportClientDocument.

Almost there and thanks a bunch...