#5 Infinite Loop when Drawing


Sparkline Chart Module

Windows XP – Excel 2003 SP 3

Problem Description
Infinite Redraw Loop
Since version 2.5 I have been unable to run Sparklines with any sort of effectiveness. The problem seems to manifest itself when a new sparkline is drawn or the entire sheet is redrawn. At this point, the new Sparkline appears but Excel pegs out the CPU. When a Cntrl+Break is done it will break somewhere within Sparklines, never in the same place. Anything I can do to try to isolate please let me know.

Were any additions to the code surrounding Cell change events added around the time of 2.5?

Reproduction Steps
Unsure at this time.


  • Grant

    Grant - 2009-01-09
    • priority: 5 --> 8
  • nixnut

    nixnut - 2009-01-10

    Try replacing every instance of ActiveCell.CalculateFull in the OnActionsMacros module with ActiveCell.Calculate.

  • Grant

    Grant - 2009-01-13

    I have followed one LineChart draw and the code of the LineChart after its finished is triggering the following code in the clsMyAppEventTrap in the Class Modules.

    Private Sub xlAppEvent_SheetCalculate(ByVal SH As Object)
    End Sub

    After the LineChart completes it triggers this event, the DrawCharts Sub() then retriggers the xlAppEvent_SheetCalculate thus we have an infinite loop.

    Note: This appears to happen with all charts.

  • Grant

    Grant - 2009-01-13

    It seems as though the xlAppEvent_SheetCalculate is needed in order to have charts update automatically. There may be a way to ensure that this event doesn't fire from the DrawCharts() subroutine.

  • Grant

    Grant - 2009-01-13

    After commenting out the DrawCharts() routine in xlAppEvent_SheetCalculate, you no longer are able to see any chart drawn or re-drawn. However, if I go into the Utility module and run in my case the LineChart() function I will be prompted to run another module. I then can select DrawCharts() and all Line Charts will be updated correctly without the infinite loop.

  • nixnut

    nixnut - 2009-01-14

    I don't quite see how DrawCharts would cause a loop. It uses a queue and removes every chart it draws from the queue. So it should draw every chart only once. I've not been able to reproduce this. The only loop I've found so far is caused by an obscure bug in the paretochart.

    But let's assume your analysis is correct. Let's therefore try disabling events for DrawCharts. In the DrawCharts subroutine add Application.EnableEvents = False on the line after Application.Cursor = xlWait and add Application.EnableEvents = True on the line above Application.Cursor = xlDefault. The DrawCharts routine should no longer generate events and therefore no longer trigger a call of xlAppEvent_SheetCalculate.

  • Grant

    Grant - 2009-01-14

    Adding those statements has stopped the infinite looping and all charts on the page are updating (slowly (a few secs per) - but correctly). I'm not sure why DrawCharts would infinite loop on my computer but not yours. The only thought would be if it was due to another add-in I have running.

  • nixnut

    nixnut - 2009-01-15

    So, the good news is the looping stopped. Guess the application.enableevents bits stay then. Thanks for testing that. It could be that another add-in might cause a problem. It could also be that I'm not using the xl2003 version since I don't have xl2003.

    If you think the chart drawing speed is an issue please open a new bug for it. That way we can close this one when we've added the application.enableevents bits in the next release.

    Thanks for taking the time to report, comment and test etc

  • nixnut

    nixnut - 2009-01-20

    I've added the events disabling/enabling to the 3.3_alpha1 release.

  • Fabrice Rimlinger

    • status: open --> closed-accepted

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks