Maybe a simple one, but I can't see it:
I have a form with on it a simple image control.
On that image control I draw lines with Graham's chart dll.
When I have seen the chart I close the form and I thought that that would
clear the image, but it doesn't, so when I make a new chart and load the form
again I see the old chart plus the new one.
This is the relevant code section:
LineChart.New1(imgChart.Width, imgChart.Height)
LineChart.Text = strTerm
LineChart.Color = Rgb(255,255,230)
LineChart.MaxScaleValue = dMaxValue
LineChart.MinScaleValue = dMinValue 'no effect with positive values
LineChart.ShowGrid = True
LineChart.AddXAxisText(1, 80, strMinDate)
LineChart.AddXAxisText(160, imgChart.Width - 1, strMaxDate)
LineChart.XAxisIntervalValue = 240 'to avoid any ticks on the X-axis
For n = 0 To lRecords - 1
'the + 1 and - 1 x-axis adjustments are to prevent
'these values falling of the image on the device
'-------------------------------------------------
If n = 0 Then
LineChart.AddPoint(1, ArrayListValues1.Item(n))
Else
If n < lRecords - 1 Then
LineChart.AddPoint(Int((ArrayListDateTicks.Item(n) - lMinDate) / dXAxisFactor), _
ArrayListValues1.Item(n))
Else
LineChart.AddPoint(imgChart.Width - 1, ArrayListValues1.Item(n))
End If
End If
Next n
Linechart.LineWidth = 1
LineChart.AddLine
imgChart.Image = LineChart.Draw
frmChart.Show
The arraylists are cleared before adding new values (from a SQLite Reader) and they are not the problem.
Thanks again for any advice.
This line assigns a new Bitmap ,with the chart drawn on it, to the Image property of the Image control. I can't see how the old Bitmap could still be visible. Are you doing "LineChart.New1(imgChart.Width, imgChart.Height)" the second time around? This is needed to clear the LineChart or you will get the old data redrawn.
OT:
When posting code, highlight the code text in the input window and click the # icon above it.
This adds the code tag, and makes your post a bit more readable. eg.
Code:
Sub Globals 'Declare the global variables here. End Sub
Sub App_Start Form1.Show End Sub
Sorry for grumbling, grovel, grovel
__________________
.
.
. Don't ask, I'm fine, honest. !!
.
.
. Just a little crazy at times
O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80
> Are you doing "LineChart.New1(imgChart.Width, imgChart.Height)" the second time around?
Yes, that runs every time. Just tested it to make sure.
I must be overlooking something simple here.
I have attached the full code of this Sub as a zipped text file.
I have attached the full code of this Sub as a zipped text file.
You are making things unnecessarily complicated. Just post the sbp file then I can run it directly otherwise I have to prat around recreating all the objects etc. and I have too much to do to waste time redoing what you have already done
OK, attached the source file. Bear in mind that you can't run it as you haven't got the SQLite db file. This is a very large file, but if you need it then I can make a small one and post that.
All solved.
This was a simple and plain bug in my code and sorry to cause and wasted time anywhere.
I have 4 arraylists and they all need clearing before the next chart is made, but I had forgotten to clear ArrayListDateTicks.
Once that was done all was fine.