Not able to set DisplayRSquare datalabel position in Scatter Chart

Hi,

We are using Aspose cells 4.8.0.14 version, report generates in Excel 2007 format.

In Sctter chart we have option caaled DisplayRSquare value set as TRUE/FALSE. I have changed value as TRUE, but its displays top of the Trend line.

But I want to change the R-Square position to move left most side, how to do set the location for R-Square value.

Also Border was not appearing in the chart

Could please suggest me to resolve this issue

Thanks
K.GNANAVEL

Hi,

I am not sure about your issue but as you are using older version i.e. v4.8.0.x, so I recommend you to use the attached latest version v5.2.1.2.

If you still have any issue, kindly give us more details of your issue. Moreover, give us your sample code and template files to reproduce the issue at our end. We will check it soon.

Thank you.

Thanks for your reply,

I have tried the newer version, but I am not able to compile successfully, because it needs lot of code changes due to version changes.

So Please help me to fix the issue in current version itself, below given the line of code which we written for Tren formula.

Also attached the output file for Aspose cells for your information.

'------------------------------------------------------------------------------

'Applying the Trend Formula

'------------------------------------------------------------------------------

'Adding a Regression Series only if a valid Trend formula is selected and

' both X and Y Metrics are not Date Types

If stcReportData.ReportSpecification.Trend_Formula <> 0 And Not (stcReportData.X_Metric_Value_DataType.ToUpper.Equals(METRIC_TYPE_DATE) And stcReportData.Y_Metric_Value_DataType.ToUpper.Equals(METRIC_TYPE_DATE)) Then

'Exceute if Trend Formula is a valid numeric value

If IsNumeric(stcReportData.ReportSpecification.Trend_Formula) Then

'Set properties of the Regression Series

ReportChart.NSeries.Add(wsData.Name & "!G2:G" & intLastRow, True) 'The Y Co-ordinate values

ReportChart.NSeries(1).XValues = wsData.Name & "!C2:C" & intLastRow

ReportChart.NSeries(1).Name = "Regression"

ReportChart.NSeries(1).Type = ChartType.Scatter

ReportChart.NSeries(1).MarkerStyle = ChartMarkerType.None

boolOverFlow = False

Select Case stcReportData.ReportSpecification.Trend_Formula

Case 7 'TrendlineType.Logarithmic '7

ReportChart.NSeries(1).TrendLines.Add(TrendlineType.Logarithmic, "Logarithmic")

ReportChart.NSeries(1).TrendLines(0).Order = 2

ReportChart.NSeries(1).TrendLines(0).Style = LineType.Solid

Case 6 'TrendlineType.Linear '6

ReportChart.NSeries(1).TrendLines.Add(TrendlineType.Linear, "Linear")

ReportChart.NSeries(1).TrendLines(0).Order = 2

ReportChart.NSeries(1).TrendLines(0).Style = LineType.Solid

Case 3 'TrendlineType.Polynomial ' 3

ReportChart.NSeries(1).TrendLines.Add(TrendlineType.Polynomial, "Polynomial")

If IsNumeric(stcReportData.ReportSpecification.Trend_Order) Then

ReportChart.NSeries(1).TrendLines(0).Order = stcReportData.ReportSpecification.Trend_Order

ReportChart.NSeries(1).TrendLines(0).Style = LineType.Solid

Else

ReportChart.NSeries(1).TrendLines(0).Order = 2

ReportChart.NSeries(1).TrendLines(0).Style = LineType.Solid

End If

Case 5 'TrendlineType.Exponential

ReportChart.NSeries(1).TrendLines.Add(TrendlineType.Exponential, "Exponential")

ReportChart.NSeries(1).TrendLines(0).Order = 2

ReportChart.NSeries(1).TrendLines(0).Style = LineType.Solid

Case 4 'TrendlineType.Power

ReportChart.NSeries(1).TrendLines.Add(TrendlineType.Power, "Power")

ReportChart.NSeries(1).TrendLines(0).Order = 2

ReportChart.NSeries(1).TrendLines(0).Style = LineType.Solid

Case Else

ReportChart.NSeries(1).TrendLines.Add(stcReportData.ReportSpecification.Trend_Formula, "TrendNameUnknown")

ReportChart.NSeries(1).TrendLines(0).Order = 2

ReportChart.NSeries(1).TrendLines(0).Style = LineType.Solid

End Select

'ReportChart.NSeries(1).TrendLines(0).Period = 0

ReportChart.NSeries(1).TrendLines(0).Forward = 0

ReportChart.NSeries(1).TrendLines(0).Backward = 0

ReportChart.NSeries(1).TrendLines(0).DisplayRSquared = True

'Setting the DataLabel properties

ReportChart.NSeries(1).TrendLines(0).DataLabels.TextFont.Name = "Arial"

ReportChart.NSeries(1).TrendLines(0).DataLabels.TextFont.Size = 9

ReportChart.NSeries(1).TrendLines(0).DataLabels.TextFont.Color = Color.Black

ReportChart.NSeries(1).TrendLines(0).DataLabels.Border.IsVisible = True

ReportChart.NSeries(1).TrendLines(0).DataLabels.Border.Weight = WeightType.HairLine

ReportChart.NSeries(1).TrendLines(0).DataLabels.Border.Style = LineType.Solid

ReportChart.NSeries(1).TrendLines(0).DataLabels.Border.Color = Color.Black

ReportChart.NSeries(1).TrendLines(0).DataLabels.Position = LabelPositionType.Left

Else

'display message "No Trend formula specified for the report

End If

End If

ReportChart.IsLegendShown = False

'When X-Values are Dates and Comparison Components are selected, wrong scales

'are in display starting in 1/1/1900, So the following code id to get around

'this problem. If X-Values are date types then specify the minimum value on

'the X-Axis

'BDFN

stcReportData.X_MinimumDateMinus10Scale = X_MinimumDateMinus10

stcReportData.Y_MinimumDateMinus10Scale = Y_MinimumDateMinus10

If stcReportData.X_Metric_Value_DataType = METRIC_TYPE_DATE Then

'Calculate Minimum date minus 10%

ReportChart.CategoryAxis.MinValue = DataSheetCells(stcReportData.X_MinimumDateMinus10Scale).DoubleValue

'Reset the formula after setting the min value for X Axis, because its not for display

DataSheetCells(stcReportData.X_MinimumDateMinus10Scale).Formula = ""

End If

If stcReportData.Y_Metric_Value_DataType = METRIC_TYPE_DATE Then

'Calculate Minimum date minus 10%

ReportChart.ValueAxis.MinValue = DataSheetCells(stcReportData.Y_MinimumDateMinus10Scale).DoubleValue

'Reset the formula after setting the min value for Y Axis, because its not for display

DataSheetCells(stcReportData.Y_MinimumDateMinus10Scale).Formula = ""

End If

ReportChart.ValueAxis.TickLabels.Font.Name = "Arial"

ReportChart.ValueAxis.TickLabels.Font.Size = 9

Hi,

I am sorry but we cannot add/amend any modifications in the older versions. We only add or modify changes in the latest version/fix, so to check the issue in the older version is useless. Moreover, this is our company’s policy and we cannot go against it.

I am afraid, there is no way but to use latest version/fix to check the issue. If in any case, it does not work well and the issue still exists, we are bound to try to fix it soon. I know you got to change your existing code segments are some api are renamed and changed in the latest versions, but you have to do. One more thing, in the latest versions of Aspose.Cells, we have re-organized the API structures, we moved certain API to their corresponding namespaces. For example all the chart related API are now present in Aspose.Cells.Charts namespace. I think you got to import two namespaces at least, e.g
Imports Aspose.Cells
Imports Aspose.Cells.Charts.

For complate reference please see the Aspose.Cells for .NET documentation including API References

Thank you.



Hi ,

I have downloaded the latest version ( 5.2.2) and worked with your sample code today, still I am not getting the borders for RSquare (R2) label border while saving the workbook in .XLSX format.

But when We tried to save the workbook in .xls format, border and font color is appearing.

Please suggest me what to in the cvoding side for Display RSquaretExtbox with Border and leftmost side of the plot.

Below given lines of code for sttting properties of TrendLine and attched the code in the attachments.

'Trend Lines

chart.NSeries.Add("Data!B2:B10", True)

chart.NSeries(1).XValues = "Data!A2:A10"

chart.NSeries(1).Type = ChartType.Scatter

chart.NSeries(1).TrendLines.Add(TrendlineType.Logarithmic, "Logarithmic")

chart.NSeries(1).TrendLines(0).Order = 2

chart.NSeries(1).TrendLines(0).Style = Drawing.LineType.Solid

chart.NSeries(1).TrendLines(0).DisplayRSquared = True

chart.NSeries(1).TrendLines(0).DataLabels.Border.IsVisible = True

chart.NSeries(1).TrendLines(0).DataLabels.Border.Style = Drawing.LineType.Solid

chart.NSeries(1).TrendLines(0).DataLabels.Border.Weight = Drawing.WeightType.SingleLine

chart.NSeries(1).TrendLines(0).DataLabels.Border.Color = Color.Maroon

chart.NSeries(1).TrendLines(0).DataLabels.TextFont.Color = Color.Blue

chart.NSeries(1).TrendLines(0).DataLabels.Position = LabelPositionType.Left

Thanks

K.GNANAVEL

Hi,

Thanks for providing us the sample code.

I have tested your code and am able to reproduce the issue (for XLSX file) as you have described. I have logged your issue into our issue tracking system with an id: CELLSNET-24389. We are already working on your issue. Once we figure it out, we will let you know about it.

Thank you.

Hi,

Please try the Aspose.Cells for .NET 5.2.2.6.We have fixed the issue you mentioned.

The issues you have found earlier (filed as 24389) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Thanks,

I have tried the same and find 2 issues, Could you please help me on this.

1. border is Not appearing in XLSX format, evene we written the code to display the border.

chart.NSeries(1).TrendLines(0).DataLabels.Border.Style = Drawing.LineType.Solid

chart.NSeries(1).TrendLines(0).DataLabels.Border.Color = Color.Black

chart.NSeries(1).TrendLines(0).DataLabels.Border.Weight = Drawing.WeightType.SingleLine

chart.NSeries(1).TrendLines(0).DataLabels.Border.IsVisible = True

2. Not able to set the location for the Display RSquare Label , acullay We need to display the value in the left top most corner.

Please help me to resolve the above given 2 issues in the new version.

Hi,

1) I have tested your project (you posted in one of your previous post) with our latest version v5.3.0
and it works fine with it. I just changed a line of code in your project i.e.
chart.NSeries(1).TrendLines(0).DataLabels.Border.Color = Color.Maroon
to:
chart.NSeries(1).TrendLines(0).DataLabels.Border.Color = Color.Black

I have also attached the output XLSX file, it is fine based on your code you wrote. Kindly check it.

2) How could you move the Trendlines data labels to your desired postion in MS Excel, we follow MS Excel standards. If you have different opinion, kindly perform your task in MS Excel, you are to choose from the Trendlines options that MS Excel provides and not to use Mouse by just dragging and dropping the equation to your desired location. We will check it soon.

Thank you.

Hi,

1. Border is Not appearing in XLSX format

It works fine.

2. Not able to set the location for the Display RSquare Label

Please add the following code:


chart.NSeries[1].TrendLines[0].DataLabels.X = -1608;

chart.NSeries[1].TrendLines[0].DataLabels.Y = -694;


Please use our latest version of Aspose.Cells for .NET 5.3.0