Ask a questionAsk a question
 

AnswerHelp Needed

  • Friday, November 06, 2009 3:06 PMNuamangcu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I am new in Microsoft .net Chart . Can anyone one guide me how to take a start up on it.
    Muhammad Nouman

Answers

  • Friday, November 06, 2009 4:35 PMjwavila Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code

    you can check these 2 links for some info

    http://weblogs.asp.net/dwahlin/archive/2008/11/25/getting-started-with-the-asp-net-3-5-chart-control.aspx


    http://blogs.msdn.com/alexgor/archive/tags/Chart/default.aspx


    I started with the first one. Although I wasn't using a database for the chart, I was using a datatable. So I was able to use the info to figure out how to display data in the chart. Then I just played around with a number of things, seeing what happened.

    other than those, just add a ChartControl to your Form, and start looking at all the Methods and Properties for it.

    start by typing Chart1. in your code editor.

    here is a simple example of how to plot data from an array to get you started :)

        Dim values1 As New List(Of Double)
        Dim values2 As New List(Of Double)
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            
            Chart1.Series(0).Points.DataBindY(values1)
            Chart1.Series(1).Points.DataBindY(values2)
    
         End Sub
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            values1.AddRange(New Double() {10.2, 23.6, 7.5, 9.8, 14.0})
            values2.AddRange(New Double() {5.9, 20.1, 12.8, 16.4, 8.2})
    
            Chart1.Series.Add("Series2")
    
            'stacked column style
            'With Chart1.Series(0)
            '    .LabelFormat = "0.0"
            '    .ChartType = DataVisualization.Charting.SeriesChartType.StackedColumn
            '    .IsValueShownAsLabel = True
            '    .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
            '    .Color = Color.Blue
            '    .BackSecondaryColor = Color.Aqua
            'End With
    
            'With Chart1.Series(1)
            '    .LabelFormat = "0.0"
            '    .ChartType = DataVisualization.Charting.SeriesChartType.StackedColumn
            '    .IsValueShownAsLabel = True
            '    .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
            '    .Color = Color.Purple
            '    .BackSecondaryColor = Color.Magenta
            'End With
    
            'side by side columns
            With Chart1.Series(0)
                .LabelFormat = "0.0"
                .ChartType = DataVisualization.Charting.SeriesChartType.Column
                .IsValueShownAsLabel = True
                .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
                .Color = Color.Blue
                .BackSecondaryColor = Color.Aqua
                .LegendText = "Values 1"
            End With
    
            With Chart1.Series(1)
                .LabelFormat = "0.0"
                .ChartType = DataVisualization.Charting.SeriesChartType.Column
                .IsValueShownAsLabel = True
                .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
                .Color = Color.Purple
                .BackSecondaryColor = Color.Magenta
                .LegendText = "Values 2"
            End With
    
            Chart1.ChartAreas(0).AxisX.Interval = 1
    
        End Sub
    

     

All Replies

  • Friday, November 06, 2009 4:35 PMjwavila Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code

    you can check these 2 links for some info

    http://weblogs.asp.net/dwahlin/archive/2008/11/25/getting-started-with-the-asp-net-3-5-chart-control.aspx


    http://blogs.msdn.com/alexgor/archive/tags/Chart/default.aspx


    I started with the first one. Although I wasn't using a database for the chart, I was using a datatable. So I was able to use the info to figure out how to display data in the chart. Then I just played around with a number of things, seeing what happened.

    other than those, just add a ChartControl to your Form, and start looking at all the Methods and Properties for it.

    start by typing Chart1. in your code editor.

    here is a simple example of how to plot data from an array to get you started :)

        Dim values1 As New List(Of Double)
        Dim values2 As New List(Of Double)
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            
            Chart1.Series(0).Points.DataBindY(values1)
            Chart1.Series(1).Points.DataBindY(values2)
    
         End Sub
    
    
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            values1.AddRange(New Double() {10.2, 23.6, 7.5, 9.8, 14.0})
            values2.AddRange(New Double() {5.9, 20.1, 12.8, 16.4, 8.2})
    
            Chart1.Series.Add("Series2")
    
            'stacked column style
            'With Chart1.Series(0)
            '    .LabelFormat = "0.0"
            '    .ChartType = DataVisualization.Charting.SeriesChartType.StackedColumn
            '    .IsValueShownAsLabel = True
            '    .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
            '    .Color = Color.Blue
            '    .BackSecondaryColor = Color.Aqua
            'End With
    
            'With Chart1.Series(1)
            '    .LabelFormat = "0.0"
            '    .ChartType = DataVisualization.Charting.SeriesChartType.StackedColumn
            '    .IsValueShownAsLabel = True
            '    .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
            '    .Color = Color.Purple
            '    .BackSecondaryColor = Color.Magenta
            'End With
    
            'side by side columns
            With Chart1.Series(0)
                .LabelFormat = "0.0"
                .ChartType = DataVisualization.Charting.SeriesChartType.Column
                .IsValueShownAsLabel = True
                .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
                .Color = Color.Blue
                .BackSecondaryColor = Color.Aqua
                .LegendText = "Values 1"
            End With
    
            With Chart1.Series(1)
                .LabelFormat = "0.0"
                .ChartType = DataVisualization.Charting.SeriesChartType.Column
                .IsValueShownAsLabel = True
                .BackGradientStyle = DataVisualization.Charting.GradientStyle.TopBottom
                .Color = Color.Purple
                .BackSecondaryColor = Color.Magenta
                .LegendText = "Values 2"
            End With
    
            Chart1.ChartAreas(0).AxisX.Interval = 1
    
        End Sub
    

     

  • Friday, November 20, 2009 6:11 AMNuamangcu Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi dear , such a nice reply regarding Microsoft .net Charts to my thread. Its really very helpful.

    I am gonna implement it in customized way in my application then ll let you know in case of any further quires.

    can you please add me to your msn Messenger contacts so i can take your assistance any time. It will be so nice of you.

    My email is nauman_gcu@hotmail.com

    thank you very much   
    Muhammad Nouman