We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Detecting Chart changes before rendering

Hi,


Can we find out whether a com.aspose.cells.Chart has changed without completely rendering it? Since Chart.toImage calls are expensive, I’d like to prevent calling this method as much as possible by caching rendered Images.

Complete scenario:
A) I change some cells
B) I call chart.toImage
C) I change some other cells
D) I want to find out whether the changes in C affected the Chart data / layout. If not, I can return the value from B, otherwise, call chart.toImage again.

Is it possible to reference the underlying chart data (everything Chart.toImage uses) and compare that to a cached hash?

Hi Yousef,


Thank you for contacting Aspose support.

I am afraid, Aspose.Cells APIs currently do not provide your requested feature. However, we can log a feature request in our database to provide an appropriate API to accomplish your goals with future releases of Aspose.Cells.

Please note, we can provide IsInChart(int rowIndex, int columnIndex) method to return whether the cell[rowIndex, columnIndex] is in the chart source data. For example if you change the cell[0,1] and cell[0,2], and want to know if chart changes too, you will be able to detect as follow:

if(chart.IsInChart(0,1) || chart.IsInChart(0,2))
{
calls chart2image
}
else { return previous result}

Please confirm if our understanding of your requirement is correct so we could log it for feasibility analysis.

Hi,


Would be great to see this as a feature so we can improve the overall performance of our application using Aspose.

Unfortunately, your example is not a feasible quick fix, because if in step C I would change cells that are not in the chart, but cells who depend on the changed cells are in the chart, I won’t be able to detect the changes.

The appropriate API design would depend on the internal design of your software, but I’d be happy to answer any questions you might have or help in the process.

Hi Yousef,


It would be of great help if you can share a sample spreadsheet and steps to perform the required manipulation in Excel for better understanding of your scenario. What I understand from your recent comments is that you also wish to detect the secondary dependent cells. For instance if value of cell A is dependent on cell B where cell A is part of the chart data-source, and you wish to detect if change to the cell B is going to change the chart. Am I correct in my understanding?

Correct. However, I think your perspective looking at datasource cells overcomplicates things. As not only the series but also the Axis Labels etc. might be based on a cell range.


For a different perspective, consider my following thought-experiment based on some hypotheses as I don’t have access to the Aspose code.

Let’s say the Chart.toImage function might look as follows:

toImage(OutputStream, Options) {
// gather all info about legends, axes, titles, labels, and cell data
chartDrawData = gatherAllChartInfoNeededToDrawChart();
// render the image, including expensive font layouts, path calculations, javax.* / graphics calls
drawChart(chartDrawData);
}

Now, if we could make “gatherAllChartInfoNeededToDrawChart” public, we can compare it to a previous instance (or hash) to see whether any of the data the chart consists of has changed or not.


Hope this helps,

Hi Yousef,


Thank you for sharing further details. Let me discuss these requirements with the product team and come back with more details in this regard.

Hi again,


Thank you for your patience with us. This is to inform you that we have discussed the matter with the product team, and have concluded that it will not be feasible for us to provide the feature as per your request. Reason being, chart’s data source is massive it self so we cannot keep the historical data for later reference.

Hi,


Thanks for checking this out.

However, Aspose does not need to keep the historical data or cache it. It would suffice to be able to access the datasource before drawing, so our application itself can either:
- keep it in cache to compare later
- keep a hash of the data in cache

so we can decide ourselves (not in the aspose layer), whether a rerendering of the image is necessary.

Hope this makes sense,

Hi Yousef,


Your requirement makes sense however, it may not be feasible to support the required feature as you are demanding it to be. Reason being, 1) we tend to provide features that are useful for most of the customers, 2) the feature should not impose performance plenty while degrading overall performance. Anyway, I have to check back with the product team on this so please spare me some more time.

Hi Yousef,


First of all, please accept my sincere apologies for a bit delayed response.

I have discussed this matter with the product team again, and I am afraid, we will not be able to provide the requested feature on the grounds discussed in my previous response. Most importantly, we think that the requested feature will degrade the overall performance of the API.

Hi Babar,


I know performance has always been kept as one of the top priorities at Aspose. This is why we switched year ago from POI to Aspose.

The reason behind this feature request is actually a performance consideration. It significantly impacts the performance of our current users, as we can’t determine whether we need to re-render charts, and have to call this expensive operation every time.

Also, I don’t really see how implementing this can affect the performance of other users. Based on the solution I suggested, it should not have any impact on existing Aspose users. It should be possible to just provide the method which exposes the chart data before rendering. It’s not necessary to built any caching into Aspose itself, just allow access to the data object to enable applications to make better decisions about charts, such as caching.

Thanks again for your consideration,

Hi Yousef,


Thank you for writing back.

I can understand the need of your required feature and I intend to raise your concerns to the product team in the weekly meeting on coming Monday to get better coverage. In the meanwhile, please provide the following information for clarity.

  1. In two operators, whether the chart is re-set?
  2. Or only the cells are changed?
  3. Are the charts you handle include Pivot Charts?
  4. Please provide us some spreadsheets for review

Hi again,


This is to inform you that upon further discussion with the product team, we have logged a formal request in our database to analyze your requested feature for feasibility. The ticket Id for your future reference is CELLSJAVA-41431.

Please note, once we have analyzed the requirement, we will be in a better position to comment on the time required for the implementation. As soon as we have further updates in this regard, we will post here for your kind reference.

Thanks. Will the additional info you requested still be helpful? I didn’t have time to send you this yet.

Hi Yousef,


Yes, please share the information as requested earlier so we could attach it to the ticket for product team’s review.

Hi,

Thanks for using Aspose.Cells for Java.

Please download and try this fix: Aspose.Cells for Java (Latest Version) and let us know your feedback.

Please use chart.isChartDataChanged() method to detect whether the chart changes.

Thanks Shakeel! Is the zip password protected?

Hi,

Thanks for your posting and using Aspose.Cells.

Do you mean zip file of Aspose.Cells for Java (Latest Version). No, it is not password protected. Once, you will extract it, it will contain another zip file, then you extract the another zip file and it will give you the jar file.

Thanks, the password thing was an error in my zip client, fixed now.


As for the isChartDataChanged() method, when does it return true? If the chart data has changed since the last call to chart.toImage(…)?

It seems to work well. I’m having some issues with workbook.calculateFormula() getting stuck though, but this might be because this is the first time I’ve upgraded from 7.x to 8.x - will have to dig in to this more.

Hi Yousef,

yousefdardiry:
Thanks, the password thing was an error in my zip client, fixed now.


It is good to know that you are able to finally test the new release.

yousefdardiry:
As
for the isChartDataChanged() method, when does it return true? If the
chart data has changed since the last call to chart.toImage(…)?


The method detects the changes in the chart’s data source before rendering the chart to image format. At first Chart.toImage call, the chart source data (e.g. XValuesParseData, ValuesParseData) will be recorded. Before calling the Chart.toImage method again, call isChartDataChanged method to check if the chart needs re-rendering.

yousefdardiry:
It
seems to work well. I’m having some issues with
workbook.calculateFormula() getting stuck though, but this might be
because this is the first time I’ve upgraded from 7.x to 8.x - will have
to dig in to this more.


Please feel free to share the sample spreadsheet along with code here so we could also look into the matter and assist you further in this regard.