Charts: Dynamic ranges, and Smart Labels/Postitioning

Good day,

First off I would like to say that your support team is fantastic! I have had several questions and issues regarding the spreadsheet control (I almost feel like a professional tester for this at this point), and your team has been very patient, kind, and quick, and I appreciate it!

I have a couple questions regarding the spreadsheet control and its charts:

1) I have a situation where I have a SQLite query being placed into a few columns of the spreadsheet control and a chart that visualizes the data. The query info that comes in is dynamic and can cause the range to grow, but the chart range doesn't grow with it. In this situation the chart is created at run time initially and is based off of the spreadsheet range, and then the document is saved. The query is re-run periodically but in this situation it is not possible to data-bind the chart to the SQLite query, it must be drawing its info directly from the spreadsheet control range.

So, my question is this: Is there a way to make a range become a dynamic table that grows automatically when the next available row is used (much like Excel tables).

I.e. If my chart is pulling from "A1:C4", and then data is added in A5, B5, and C5, the chart needs to then auto update to include the new row (series). Is there a way to do this?

2) I have an issue with chart labels overlapping. I have tried all standard positions (center, best fit, etc.) and none of them are flexible enough to prevent overlapping. Is there any kind of "smart label" system that can be put in to place? In the past, with Excel, I was able to click on each individual data label and simply drag them to either side of the column or maker and they would then stay in the same place even when the chart was updated with different data? Is it possible to select and drag individual data labels and have their position saved?

Thanks!

3 Replies

TL Thirumurugan Loganathan Syncfusion Team January 11, 2018 04:34 PM UTC

Hi Travis, 
 
Please find the below details for asked queries, 
 
S.No 
Query 
Comments 
 
1 
Auto update chart when add the new row at the runtime 
 
Charts will update automatically when change the value of a cell, which cell should resides in the given DataRange of the chart. But you could not add new series based on the data entered in the new row at runtime. Anyhow this can be achieved by an workaround method that is If you want to add new series in the existing chart based on the values entered in the new row/column, you need to set the DataRange up to newly added row. Please find the below code sample for your reference. 
 
 
private void ChartBtn_Click(object sender, EventArgs e) 
{ 
            var chart = spreadsheet.AddChart(spreadsheet.ActiveSheet); 
            GridRangeInfo range = spreadsheet.ActiveGrid.SelectedRanges.ActiveRange; 
            chart.DataRange = spreadsheet.ActiveSheet.Range[range.Left,range.Top,range.Bottom,range.Right]; 
 
            var shape = chart as ShapeImpl; 
            shape.Top = 100; 
            shape.Left = 200; 
 
            chart.ChartType = ExcelChartType.Column_Clustered; 
            spreadsheet.ActiveGrid.GraphicModel.InvalidateGraphicObjects(); 
            spreadsheet.ActiveGrid.GraphicModel.InvalidateGraphicVisual(); 
} 
 
 
 
2 
Drag and drop the data label as in MS-Excel 
In spreadsheet, Chart is rendered as an image so that currently spreadsheet does not have support to drag and drop the data label alone within the chart.  
 
 
 
Regards, 
Thirumurugan 



TC Travis Chambers January 14, 2018 07:32 PM UTC

Thank you for your response. I had forgotten that the charts are rendered as images. The only work around I can come up with is to use a combo chart of column + scattered line with markers. The scattered line seems to pull each point away from the middle series so that the only series that may see overlapping is the middle one. This is better than nothing, however, the far left and right points are sitting on the edge of the plot area (i.e. the first point on the line sits on the y axis line so only half the point is visible). Is there a way to give some cushion between the outer points and the edges of the plot area?

thanks.


DB Dinesh Babu Yadav Syncfusion Team January 15, 2018 06:46 AM UTC

Hi Travis, 
 
Sorry for the inconvenience. 
 
As mentioned in earlier update, chart is rendered as an image in Spreadsheet. So, you cannot reset the plot area. However, you increase the height and width of the shape which may overcome the overlapping issue as like below code example. 
 
Code Example[C#]: 
var shape = chart as ShapeImpl;
shape.Top = 200;
shape.Left = 300;
            
//Resizes the shappe,
shape.Scale(100, 80);
 
chart.Series[0].SerieType = ExcelChartType.Column_Clustered;
chart.Series[1].SerieType = ExcelChartType.Scatter_Line_Markers;
 
 
Could you check with the above code example and approach the same in your application?. If the issue is still persist, we suggest you to replicate the issue in a sample and revert us with the replication procedure which would help us to analyze and validate the issue better and update you an appropriate solution. 
 
Please let us know if you require further assistance. 
 
Regards, 
Dinesh Babu Yadav 


Loader.
Up arrow icon