Change of Recordsource stops the Smoothed line
Change of Recordsource stops the Smoothed line
I have a screen whereby the user selects a date, which creates a new recordset (from Access) grabbing only the records with the specified date. When this recordset is passed to the Series Line for a second time and any time after that, the Series line is no longer Smoothed.
Here is the code to setup the graph during the FormLoad event (there are 7 days to display, so seven Series Lines) :
For i = 0 To 6
TChart1.Series(i).XValues.ValueSource = "dtTime"
TChart1.Series(i).YValues.ValueSource = "AAMean"
TChart1.Series(i).Pen.Width = LineThickness
TChart1.Series(i).asLine.Smoothed = 1
Next i
Here is the code to Redraw the graph...
For i = 0 To 6
strSQL = "SELECT * FROM Analysis WHERE dtDate = #" & Format(DateAdd("d", i, ShowDate), "dd/mmm/yyyy") & "# ORDER BY dtDate, dtTime"
Call dbRecordSet.Open(strSQL)
If dbRecordSet.RecordCount = 0 Then
TChart1.Series(i).Active = False
Else
TChart1.Series(i).Active = True
TChart1.Series(i).DataSource = dbRecordSet
End If
dbRecordSet.Close
Next i
As I say, the series line, when drawn for the first time, is smooth. However, when the recordset is refreshed with new SQL, the line is redrawn and it is not smoothed.
Is there any reason for this or is there a better way for me to deal with making a line smooth?
Thanks in advance.
Ben
Here is the code to setup the graph during the FormLoad event (there are 7 days to display, so seven Series Lines) :
For i = 0 To 6
TChart1.Series(i).XValues.ValueSource = "dtTime"
TChart1.Series(i).YValues.ValueSource = "AAMean"
TChart1.Series(i).Pen.Width = LineThickness
TChart1.Series(i).asLine.Smoothed = 1
Next i
Here is the code to Redraw the graph...
For i = 0 To 6
strSQL = "SELECT * FROM Analysis WHERE dtDate = #" & Format(DateAdd("d", i, ShowDate), "dd/mmm/yyyy") & "# ORDER BY dtDate, dtTime"
Call dbRecordSet.Open(strSQL)
If dbRecordSet.RecordCount = 0 Then
TChart1.Series(i).Active = False
Else
TChart1.Series(i).Active = True
TChart1.Series(i).DataSource = dbRecordSet
End If
dbRecordSet.Close
Next i
As I say, the series line, when drawn for the first time, is smooth. However, when the recordset is refreshed with new SQL, the line is redrawn and it is not smoothed.
Is there any reason for this or is there a better way for me to deal with making a line smooth?
Thanks in advance.
Ben
Re: Change of Recordsource stops the Smoothed line
Hi Ben,
Have you tried cleaning the series before refreshing and reassigning the recordset again?
If it doesn't help, you could try using a second series to draw the smoothed line and try to see it better. The first series could still be the linked to the recordset, refreshing it when needed. Then, the second series could use the first series as datasource, and use a Smoothing function as in the example at "All Features\Welcome !\Functions\Extended\Smoothing SpLine" in the features demo application included with the installation.
If you still have problems with it, don't hesitate to let us know, and please try to arrange a simple example project we can run as-is to reproduce the problem here.
Have you tried cleaning the series before refreshing and reassigning the recordset again?
If it doesn't help, you could try using a second series to draw the smoothed line and try to see it better. The first series could still be the linked to the recordset, refreshing it when needed. Then, the second series could use the first series as datasource, and use a Smoothing function as in the example at "All Features\Welcome !\Functions\Extended\Smoothing SpLine" in the features demo application included with the installation.
If you still have problems with it, don't hesitate to let us know, and please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Change of Recordsource stops the Smoothed line
Thank you for the reply.
I have included an example project which displays a smoothed line when the project is first loaded, but a change of date reloads the line and removes the smoothness. I would be thinking that as the line has been dictated as smooth, it should stay as such (unless I have unknowingly changed it when I refresh the datasource).
Alternatively, I might be accessing and refreshing the datasource in an incorrect manner and there might be a better way of doing it that does not cause the line to appear jagged after a refresh.
Thanks in advance.
Ben
I have included an example project which displays a smoothed line when the project is first loaded, but a change of date reloads the line and removes the smoothness. I would be thinking that as the line has been dictated as smooth, it should stay as such (unless I have unknowingly changed it when I refresh the datasource).
Alternatively, I might be accessing and refreshing the datasource in an incorrect manner and there might be a better way of doing it that does not cause the line to appear jagged after a refresh.
Thanks in advance.
Ben
- Attachments
-
- Graph Smoothed Project.zip
- Example Project
- (54.65 KiB) Downloaded 885 times
Re: Change of Recordsource stops the Smoothed line
Hi Ben,
We are getting a "System error in date query expression 'dtDate = #28/abr/2012#'". Could you please check the project?
We are getting a "System error in date query expression 'dtDate = #28/abr/2012#'". Could you please check the project?
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Change of Recordsource stops the Smoothed line
Apologies for that. I have removed the formatting of the dtDate and have advanced the dates within the data so it should successfully work (there was no error here so I can only assume this was the issue)
Kind regards,
Ben
Kind regards,
Ben
- Attachments
-
- Graph Smoothed Project2.zip
- Updated
- (53.58 KiB) Downloaded 851 times
Re: Change of Recordsource stops the Smoothed line
Hi Ben,
When the Smoothed propery is being set, an internal Line series with a Smoothing function is created. However, when the "parent" series is updated, these internal series and function associated aren't updated.
You have two ways to achieve the same:
- Way #1: Create the internal series and function manually and update it manually.
To do it, change the for loop in your Form_Load() for this, to add the extra series:
And at the end of yor comDate_Change() method, before the call to RefreshData, add the following for loop:
- Way #2: Remove all the series and add them again each time at the begining of your comDate_Change method adding the following:
When the Smoothed propery is being set, an internal Line series with a Smoothing function is created. However, when the "parent" series is updated, these internal series and function associated aren't updated.
You have two ways to achieve the same:
- Way #1: Create the internal series and function manually and update it manually.
To do it, change the for loop in your Form_Load() for this, to add the extra series:
Code: Select all
Private Sub Form_Load()
'...
Dim i As Integer
For i = 0 To 3
.Series(i).Pen.Width = 2
'.Series(i).asLine.Smoothed = 1
.AddSeries scLine
Next
'...
End Sub
Code: Select all
Private Sub comDate_Change()
'...
For i = 0 To 3
.Series(4 + i).SetFunction tfSmoothing
.Series(4 + i).DataSource = .Series(i)
.Series(4 + i).Pen.Width = .Series(i).Pen.Width
.Series(4 + i).Color = .Series(i).Color
.Series(i).Active = False
Next
'...
End Sub
Code: Select all
Private Sub comDate_Change()
TChart1.RemoveAllSeries
Dim i As Integer
With TChart1
For i = 0 To 3
.AddSeries scLine
Next
End With
'...
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Change of Recordsource stops the Smoothed line
Yeray,
Thanks for your assistance. I have successfully managed to keep my lines smooth!
However, and this is tempermental in the test project I am uploading so I hope you are able to replicate at your end (but does it all the time in my live project), Bottom axis resets, so it no longer appears as a Time, but as a value between 0 and 1.
When I trace through the code, it draws the straight lines as per normal. When it gets to the new For loop to assign the line thickness and Smoothness, the line gets redrawn as smooth, but the bottom axis switches from the specified times set up on the graph settings, and changes to 0 to 1.
Any ideas?
Thanks for your assistance. I have successfully managed to keep my lines smooth!
However, and this is tempermental in the test project I am uploading so I hope you are able to replicate at your end (but does it all the time in my live project), Bottom axis resets, so it no longer appears as a Time, but as a value between 0 and 1.
When I trace through the code, it draws the straight lines as per normal. When it gets to the new For loop to assign the line thickness and Smoothness, the line gets redrawn as smooth, but the bottom axis switches from the specified times set up on the graph settings, and changes to 0 to 1.
Any ideas?
- Attachments
-
- Graph Smoothed Project3.zip
- (53.79 KiB) Downloaded 882 times
Re: Change of Recordsource stops the Smoothed line
Hi Ben,
Extending what I said before:
However, you can still force it manually addig this at the end of your comDate_Change() method, before the call to RefreshData:
Note you have to call InternalRepaint to let TeeChart create the Smoothing functions.
Extending what I said before:
But these internal lines aren't inheriting the XValues.DateTime status from its "source" series.Yeray wrote:When the Smoothed propery is being set, an internal Line series with a Smoothing function is created.
However, you can still force it manually addig this at the end of your comDate_Change() method, before the call to RefreshData:
Code: Select all
Private Sub comDate_Change()
'...
TChart1.Environment.InternalRepaint
For i = 0 To TChart1.SeriesCount - 1
.Series(i).XValues.DateTime = True
Next
'...
End Sub
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: Change of Recordsource stops the Smoothed line
Brilliant.
Thanks ever so much for your help Yeray. All working and all sorted!
Thanks ever so much for your help Yeray. All working and all sorted!
Re: Change of Recordsource stops the Smoothed line
Hi Ben,
Glad to hear it!
Glad to hear it!
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |