Refresh graph

8 posts, 0 answers
  1. Howard Rybko
    Howard Rybko avatar
    51 posts
    Member since:
    Jan 2006

    Posted 05 Aug 2007 Link to this post

    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
  2. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 06 Aug 2007 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Howard Rybko
    Howard Rybko avatar
    51 posts
    Member since:
    Jan 2006

    Posted 06 Aug 2007 Link to this post

    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
  5. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 07 Aug 2007 Link to this post

    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
  6. Carisch
    Carisch avatar
    25 posts
    Member since:
    Aug 2007

    Posted 29 Aug 2007 Link to this post

    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?

  7. Dwight
    Admin
    Dwight avatar
    475 posts

    Posted 30 Aug 2007 Link to this post

    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
  8. Carisch
    Carisch avatar
    25 posts
    Member since:
    Aug 2007

    Posted 30 Aug 2007 Link to this post

    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.
  9. XXXX
    XXXX avatar
    57 posts
    Member since:
    Jun 2008

    Posted 24 Jun 2008 Link to this post


    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

Back to Top
UI for WinForms is Visual Studio 2017 Ready