B4J Question xChart: how correct to ClearData ?

peacemaker

Expert
Licensed User
Longtime User
Hi, ALl

I'm using xChart v.9, if to stop the timer a and use .ClearData - see the crach error:

How correct to see blank chart after some work?
 

klaus

Expert
Licensed User
Longtime User
What exactly did you do to get the error ?

You can do it with this:
B4X:
    tmrDynamic.Enabled = False        'stop the Timer
    DynamicLines1.ClearData                'clear the data
    DynamicLines1.DrawEmptyChart    'draw an empty chart
But, the chart is completely empty.
ClearData clears everything for a new chart.
You cannot draw a chart without data, it will show an error.

You could do something like this:
B4X:
    tmrDynamic.Enabled = False        'stop the Timer
    DynamicLines1.ClearData                'clear the data

    'redefine the lines 
    DynamicLines1.AddLine2("Speed", xui.Color_Red, 2dip, "CIRCLE", False, xui.Color_Red)
    DynamicLines1.AddLine2("Direction", xui.Color_Blue, 2dip, "SQUARE", True, xui.Color_Blue)

    'set one dummy point
    DynamicLines1.AddLineMultiplePoints("", Array As Double(0, 1), False)

    'draw the empty chart
    DynamicLines1.DrawChart

But, in this case you will see Y scales only if you set AutomaticScales = False.
With automatic scales, no scale is displayed because they are not known.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
do something like this
Yes, i did so:
Sub Stop
Sub Start (where CreateDynamicData and DrawDynamicLinePoints)
and again Stop.

Crashed in a second after DynamicLines1.ClearData. I did not know about "DynamicLines1.DrawEmptyChart", thanks.
But it did not help.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
It's huge already. And not on EN.
I can send you privately, maybe one class file to see privately?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
OK, thanks, Klaus - but i did not finish making charts filling - maybe something wrong with my init of the chart.
Will report here later, when finished.
Your example of the lib works OK without crash with .ClearData, checked.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…