This is a migrated thread and some comments may be shown as answers.

Refresh graph

7 Answers 147 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Howard Rybko
Top achievements
Rank 1
Howard Rybko asked on 06 Aug 2007, 04:19 AM
Hi

I have a winforms graph that works 100% except that I cant get it to refresh when new data is loaded.

My vb aspx version works fine.

I have tried various ways based on your examples but no luck

With RadChartCopies  
     Dim s0 As ChartSeries = .Chart.Series(0)  
     If s0 Is Nothing Then  
        .CreateSeries("Copies0", System.Drawing.Color.CadetBlue, Color.DarkSalmon, ChartSeriesType.Area)  
     End If  
     s0.Clear()  
    ' ----- Add data from DataTable generated fro SQL  
    ' ----- Use   s0.Items.Add(seriesItem0)  
    ' -----------------------------------------------  
    '  
    'Have tried these 3 methods   
    '.Invalidate()  
    '.Update()  
    '.Refresh  
End With  
 
 

Your advice would be appreciated.

Thank you
Howard Rybko
Syncrony.com

7 Answers, 1 is accepted

Sort by
0
Dwight
Telerik team
answered on 06 Aug 2007, 04:00 PM
Hi Howard,

Your code looks fine and we are not sure where exactly the problem is. Could you provide us with more information on what type of difficulties you experience?

What I can suggest is to try Rebinding the chart if you use DataBind. If you are not using DataBind, please specify the data source you are using and we will do our best to help you.
 

Regards,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Howard Rybko
Top achievements
Rank 1
answered on 06 Aug 2007, 04:29 PM
Thanks for your help.

Below is the sub that I use to create the graph. It is called multiple times with a different ID - the date retrieval is done via a data object that gets inflated. I am pretty sure that it returns with the correct values each time it is called.

I dont databind directly - not sure if this is the problem.

Here is the graph code:
#Region "Graph"  
        Private Sub GraphCopyCounts()  
            Try  
                Dim ctrlMachine As New KLIX4.DataFunctions_Machines  
                '// Returns datatable with values  
                Dim dt As DataTable = ctrlMachine.GetCopyCountsForGraph(CInt(lblMachineID.Text), _  
                                                                        Now.AddYears(-1), Now, _  
                                                                        PortalID, UserID, UserName)  
                With RadChartCopies  
                    Dim s0 As ChartSeries = .Chart.Series(0)  
                    If s0 Is Nothing Then  
                        .CreateSeries("Copies0", System.Drawing.Color.CadetBlue, Color.DarkSalmon, ChartSeriesType.Area)  
                    End If  
                    s0.Clear()  
                    s0.Name = "Copies" 
                    .ChartTitle.TextBlock.Text = "Copy Counts (last 12 months)" 
                    .Legend.Visible = False 
                    .PlotArea.YAxis.AxisLabel.TextBlock.Text = "Copies" 
                    .PlotArea.XAxis.AxisLabel.TextBlock.Text = "Month" 
                    Dim dbRow As DataRow  
                    For Each dbRow In dt.Rows  
                        If Not (dbRow("ReadDate1") Is Nothing) Then  
                            Dim seriesItem0 As New ChartSeriesItem()  
                            seriesItem0.YValue = CDbl(dbRow("CopyCountDiff"))  
                            s0.Items.Add(seriesItem0)  
                        End If  
                    Next  
                    '.Invalidate()  
                    '.Update()  
                    .Refresh()  
                End With  
            Catch ex As Exception  
                KLIX4.Common.LogErr(PortalID, "KLIX4", UserID, UserName, ex.ToString)  
                Throw  
            End Try  
        End Sub  
#End Region 

I can send you more code if it will help.

Thank you

Howard
0
Dwight
Telerik team
answered on 07 Aug 2007, 08:02 AM
Hi Howard,

The code supplied looks alright except for one issue:

Dim s0 As ChartSeries = .Chart.Series(0)
If s0 Is Nothing Then 
        .CreateSeries("Copies0", System.Drawing.Color.CadetBlue, Color.DarkSalmon, ChartSeriesType.Area)
End If


We couldn't find the code by which you assign the newly created series to s0. Also where/how do you add this series to the chart's series collection?

May I suggest the following correction:

Dim s0 As ChartSeries = .Chart.Series(0) 
If s0 Is Nothing Then  
        s0 = .CreateSeries("Copies0", System.Drawing.Color.CadetBlue, Color.DarkSalmon, ChartSeriesType.Area) 
        .Series.Add(s0); 
End If 
 

Other than that, your code should work fine if you call this method each time the series needs update.

If you have further problems with the chart, please, let us know.
 

Sincerely yours,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Carisch
Top achievements
Rank 1
answered on 29 Aug 2007, 05:57 PM

You say:
What I can suggest is to try Rebinding the chart if you use DataBind. If you are not using DataBind, please specify the data source you are using and we will do our best to help you.

 When I do this, the graph is not redrawn.  FYI, I am binding to an List<T>, not a DB object.

            radChart1.DataSource = myDataSource;  
            radChart1.DataBind();  
 


What am I missing?

0
Dwight
Telerik team
answered on 30 Aug 2007, 02:45 PM
Thank you for the additional details, Brian. I did not try this exact case, but once I did, I experienced the problem you are having. I regret to say that this is a bug in our product, which will be fixed for the Q2 release, scheduled for mid September. I have also updated your Telerik points to reflect your help in locating this bug.

Sorry for the inconvenience.

 
Sincerely yours,
Evtim
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Carisch
Top achievements
Rank 1
answered on 30 Aug 2007, 02:52 PM
The work around that I've come up with is:

Create the graph dynamically rather than in the designer.  When the graph needs to be redrawn, create another one.  Don't forget to bring to front, and it will appear updated.  Actually there are just two on the form now, but at least it seems to work from the user perspective.


Brian.
0
XXXX
Top achievements
Rank 1
answered on 24 Jun 2008, 02:51 PM

Hi all,
  I ran in to this same problem with bound datasource following is my work around if it can help anybody.
I'm using RadControls for WinForms Q1 2008 SP1.

<FONT color=#0000ff size=2>  
<P>object</FONT><FONT size=2obj = radChart1.DataManager.DataSource;</P> 
<P>radChart1.DataManager.DataSource = obj;</P> 
<P>radChart1.DataManager.DataBind();</P> 
<P>radChart1.Refresh();</P></FONT

Yours
      Bj√∂ssi

Tags
Chart (obsolete as of Q1 2013)
Asked by
Howard Rybko
Top achievements
Rank 1
Answers by
Dwight
Telerik team
Howard Rybko
Top achievements
Rank 1
Carisch
Top achievements
Rank 1
XXXX
Top achievements
Rank 1
Share this question
or