Page 1 of 1

TeeChart crashes on canvas drawing.

Posted: Tue Jun 12, 2018 11:40 am
by 16683749
teechartquery.png
teechartquery.png (41.26 KiB) Viewed 11609 times
Hi,
We need to draw around 3000 ellipses using canvas drawing as shown in snapshot attached. We are drawing them with onafterdrawtchart event. As soon as we draw those ellipses, teeChart crashes after few moments. We feel that Teechart is not able to handle this amount of data. So is there a workaround that canvas uses less memory or becomes light weight so as to optimize the drawing for required points?

Also we had one more point in mind i.e. while working on series, we have an option i.e. drawAllPoints, which can be set to false when we do not want the overlapping points to be redrawn or want 1 pixel per point. So is there a similar way for canvas drawing too?

We are using: Teechart activeX pro 2018 and Visual studio 2013


Regards
Bhanu

Re: TeeChart crashes on canvas drawing.

Posted: Thu Jun 14, 2018 9:51 am
by yeray
Hello Bhanu,

Have you seen the Bubble series? You may prefer to use it instead of drawing manually to the canvas.
I can draw 3000 bubbles without crashing in VB6:

Code: Select all

  TChart1.Aspect.View3D = False
  TChart1.Legend.Visible = False
  
  Dim i, j As Integer
  
  TChart1.AddSeries scBubble
  For i = 0 To 3000 - 1
    TChart1.Series(0).asBubble.AddBubble Round(Rnd * 100), Round(Rnd * 100), 10, "", clTeeColor
  Next i
Is it giving any error message when crashing for you?

Regarding drawAllPoints and a system to avoid drawing points/bubbles where there have been points/bubbles already drawn, I'm afraid there's no system like that implemented for Bubbles or for the custom drawing.
However, you could implement a system yourself. Using Bubbles, you could hide other bubbles with the same x and y values and only show the last. Ie:

Code: Select all

  For i = TChart1.Series(0).Count - 1 To 1 Step -1
    j = i - 1
    While (j >= 0) And (TChart1.Series(0).XValues.Value(i) = TChart1.Series(0).XValues.Value(j))
      If (TChart1.Series(0).YValues.Value(i) = TChart1.Series(0).YValues.Value(j)) Then
        TChart1.Series(0).SetNull j
      End If
      j = j - 1
    Wend
  Next i
You can do this with Bubbles because the points are sorted by the x values.
If you prefer to use custom drawing, you may want to keep your array sorted in some way so you can optimize the search for repeated values.