Howdy,
For some reason, I can't figure out how to get an XYScatterLine chart to display data.
I am doing this:
if (includeCharts) { WorksheetCell chartStartCell = worksheet.GetCell($"R{dataStartRow}C{colIndex + 3}", CellReferenceMode.R1C1); WorksheetCell chartEndCell = worksheet.GetCell($"R{dataStartRow + 10}C{colIndex + 15}", CellReferenceMode.R1C1); // calculate the data range... WorksheetChart chart = worksheet.Shapes.AddChart(ChartType.XYScatterLinesNoMarkers, chartStartCell, new Point(x: 0, y: 0), chartEndCell, new Point(x: 100, y: 100)); // get the data cells figured out var xDataStart= worksheet.GetCell($"R{dataStartRow}C{colIndex}", CellReferenceMode.R1C1); var xDataEnd = worksheet.GetCell($"R{dataEndRow}C{colIndex}", CellReferenceMode.R1C1) .ToString() .Split(separator: '!')[1]; var yDataStart = worksheet.GetCell($"R{dataStartRow}C{colIndex + 2}", CellReferenceMode.R1C1); var yDataEnd = worksheet.GetCell($"R{dataEndRow}C{colIndex}", CellReferenceMode.R1C1) .ToString() .Split(separator: '!')[1]; chart.SetSourceData($"{xDataStart}:{xDataEnd},{yDataStart}:{yDataEnd}"); }
I'm aware the way I specify cell range for the data source is a bit hokey, but that is because this is the last sample I tried. I keep thinking I am specifying the cell range in an improper fashion, but what I have is as best I can tell the way you call it out in Excel proper.
The chart ought to be plotting 'Session 1'!$B$24:$B$624 for the x values and 'Session 1'!$D$24:$D$624
What I end up getting is the attached XLSX file.
I can't seem to figure out how to specify the proper cell range. I tried using the worksheet chart example from your gallery application.
I can get that to work, just not an x/y scatter line chart.
Also, I'd really like to add the chart as its own worksheet, see the Desired.xlsx for what I really want in the end.
P{lease not the styling of the x-Axis with labels below the whole chart is my next challenge if you happen to have an example for that with an XYScatterLine plot I'd love to see that as well.
Thanks in advance for any and all help.
7103.D-Meter_Download_SN496_17May2021_095306.xlsxDesired.xlsx
Hello Douglas,
I have been investigating into the behavior you are looking to achieve, and I would recommend taking a look at the sample project I am attaching here as it achieves something similar to what is in your “Desired.xlsx” sheet.
From the code you have provided, I cannot really tell what is wrong in this case, as I do not know the values of the variables that are getting passed into the functions that you are using for the DataStart and DataEnd properties, but I do believe the sample I am attaching may help you to clear this up, as the sample is simply using the xDataStart and yDataEnd variables to define a data region that you can use in this case.
The sample is also using a new type of Worksheet called the Chartsheet, which can help you to achieve the chart that you are showing in your Desired.xlsx workbook. In the sample I am also demonstrating features of the chart such as the axis titles, axis crossing values, and styling the color of the line that is drawn for the XYScatterLinesNoMarkers chart type.
During this sample creation though, I came across an issue in that the TickLabelSpacing and TickMarkSpacing, which would normally determine the interval that the labels and tickmarks were drawn does not seem to be taking any effect. This is unexpected behavior, and as such, I have asked our engineering staff to examine it further. I am still attaching the sample project here, but I have also created you a private support case with an ID of CAS-212586-L3W7V3 that I will be linking the issue that I have logged internally to so you can be notified when a fix becomes available. You can access this private case after signing into your account on the Infragistics website, here: https://es.infragistics.com/my-account/support-activity.
Please let me know if you have any other questions or concerns on this matter.
ExcelChartDemo.zip