none
convert chart to table RRS feed

  • Question

  • Hi,

    I have a windows form that displays a graph (x,y scatter).  On one user selection, I want the graph to display some numerical data, in a table format with columns, rows, headings and such like.

    Is it possible to convert the chart type to a table?

    If not, the one way around it I can think of is to overlay a new richtextbox when the user chooses that selection, but that's not as clever.

    Thanks,

    Philip

    • Moved by Bob Wu-MT Wednesday, August 29, 2012 10:29 AM (From:Windows Forms General)
    Saturday, August 11, 2012 1:35 PM

Answers

  • This issue has now been solved.  I have used annotations to display text on the graph, having cleared all axis and graph type data.  Annotations were useful in controlling where the text was displayed and as string format.  It isn't wholly ideal, but it was a neat workaround solution.

    Thanks for the suggestions.

    Philip

    • Marked as answer by newmanpj Tuesday, October 16, 2012 8:51 AM
    Tuesday, October 16, 2012 8:51 AM

All replies

  • Probably you can bind the DataSource of chart to DataGridView too. This way graphical data will be displayed in chart and same numeric data will be displayed in DatagridView

    Gaurav Khanna | Microsoft VB.NET MVP


    Saturday, August 11, 2012 2:04 PM
  • Hi,

    that sounds like it could be the way forward.  The help files are a little unclear to me though.

    Currently, I have Chart1.Series(0).Points.DatabindXY(X,Y) where X and Y are 1-dimensional arrays of numbers/data.  X and Y aren't gathered from a datasource, but they are calculated in my program.

    How is best to use the new DataGridView you suggest?

    Thanks,

    Philip

    Monday, August 13, 2012 9:50 PM
  • May be you can add a "For" loop and fill DataGridView.

            For Each item As DataPoint In Chart1.Series(0).Points
                'Use item.XValue and item.YValues, and add them to DataGridView
            Next


    Gaurav Khanna | Microsoft VB.NET MVP

    • Proposed as answer by Bob Wu-MT Tuesday, August 14, 2012 7:23 AM
    Tuesday, August 14, 2012 3:59 AM
  • Hi,

    thanks for your reply.  I am pretty new to VB coding, so I am a little unclear.  How do I add the X and Y values to a DataGridView?

    I will eventually like to add in column headers.

    I will also like to format the table so the background is completely white with no gridlines, and also like to highlight some text or underline it.  Is this possible with DataGridView?

    Thanks.

    Tuesday, August 14, 2012 6:20 PM
  • Try following code

      For Each item As DataPoint In Chart1.Series(0).Points
                Dim i As Integer = DataGridView1.Rows.Add()
                Dim dr As DataGridViewRow = DataGridView1.Rows(i)
                dr.Cells(0).Value = item.XValue
                For y As Integer = 1 To item.YValues.Count
                    dr.Cells(y).Value = item.YValues(y - 1)
                Next
            Next

    To remove Grid

     DataGridView1.CellBorderStyle = DataGridViewCellBorderStyle.None

    You can highlight text or underline using Style of cell or you can try code in following link

    http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/26bc45a2-15ef-49c1-aa18-a7fdcb20b14d/


    Gaurav Khanna | Microsoft VB.NET MVP

    Tuesday, August 14, 2012 6:50 PM
  • Hi,

    thanks for your reply.  being a bit dumb, the code says DataPoint is not defined; what should I define it as? Double?

    Philip

    Friday, August 17, 2012 4:01 PM
  • Add following namespace in your class file

    Imports System.Windows.Forms.DataVisualization.Charting //VB.NET
    using System.Windows.Forms.DataVisualization.Charting //C#

    http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.datapoint(v=vs.100).aspx


    Gaurav Khanna | Microsoft VB.NET MVP

    Friday, August 17, 2012 5:59 PM
  • Nearly, but not quite there.

    Namespace is added, and that's fine now.

    My issue is this; this function isn't necessarily linked to the data that is currently displayed on the chart.  I have several click buttons to choose from, all of which display different data.  This one deals with data I want displayed in a table, or text format.

    So I cant really use for each item as datapoint as you suggest.

    The data I want to display is calculated before the plot function is called.  There are four arrays of data, typically between 3 and 10 rows long.

    So basically, I want to set up a main header in the table, then label each column, Tp, Tq, Rp, Rq, and then display the values in each of the arrays, variable names the same as the column headers.

    Thanks,

    Phil

    Tuesday, August 21, 2012 6:09 PM
  •  I cant really use for each item as datapoint as you suggest.

    I don't understand. What you mean?



    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, August 23, 2012 10:20 AM
  • The original response suggested using

    For Each item As DataPoint In Chart1.Series(0).Points
    ' code
    Next

    However, I cannot do this, since the data I want to show in a table will not necessarily be the same data that is currently displayed in the chart, and is safe to assume that will never be the case. 

    Thursday, August 23, 2012 5:38 PM
  • So what kind of data should be show in the DataGridView?

    Where or how can we get these data?

    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us

    Friday, August 24, 2012 8:42 AM
  • Hi,

    The data I want to display is calculated before the plot function is called.  There are four arrays of data, typically between 3 and 10 rows long.

    Basically, I want to set up a main header in the table, then label each column, Tp, Tq, Rp, Rq, and then display the values in each of the arrays, variable names are Tp, Tq, Rp, Rq.

    Thanks,

    Phil

    Friday, August 24, 2012 5:24 PM
  • Hi Phil,

    I move it to Visual Studio Report Controls forum for better support.

    I'm sorry that it seems that Chart Controls for .NET Framework is a more appropriate forum, can moderator of this forum help move this thread.

    Sorry for any inconvenience this may cause.

    Best Regards,


    Bob Wu [MSFT]
    MSDN Community Support | Feedback to us


    • Edited by Bob Wu-MT Wednesday, August 29, 2012 10:33 AM
    Wednesday, August 29, 2012 10:28 AM
  • This issue has now been solved.  I have used annotations to display text on the graph, having cleared all axis and graph type data.  Annotations were useful in controlling where the text was displayed and as string format.  It isn't wholly ideal, but it was a neat workaround solution.

    Thanks for the suggestions.

    Philip

    • Marked as answer by newmanpj Tuesday, October 16, 2012 8:51 AM
    Tuesday, October 16, 2012 8:51 AM