MS Chart Control: Getting Started


Scott Mitchell wrote a great series of articles where he describes how to use Microsoft Chart control from simple binding to more complex scenarious. I highly recommend to read his articles for everybody starting working on the control: http://www.4guysfromrolla.com/articles/072209-1.aspx 


 Alex.


 

Comments (17)

  1. tscoccol says:

    Thanks for your blogs, they’ve been very helpful.  Had a question for you — are you familiar with the process of extracting SSRS metadata, from both the database and the .rdl files ?

  2. Igor Leykin says:

    Hi Alex,

    I’m trying to draw multiple graphs, one for each sCyt in my list of unique strings with

    2 series – "MEAN" and "StdDev" – in each graph.

    So, I’m running the method below in a loop, and I’m getting multiple areas on my chart,

    but all of them except the first one are blank, and all series, legends,etc. are drawn

    in the first ChartArea.

    Could you please tell me what am I doing wrong?

    Your help is much appreciated,

    Igor

    bmigor@hotmail.com

    private void showChart(DataSet dataSource, String sCyt, int ii)

           {  

        ChartArea asCyt = new ChartArea(sCyt);

                asCyt.Position.Auto = true;            

               chartCyt.ChartAreas.Add(asCyt);

               chartCyt.DataSource = dataSource;          

               chartCyt.Legends.Add(sCyt);

               chartCyt.Series.Add(sCyt);

               chartCyt.Series.Add(sCyt + 1);

               chartCyt.Series[2*ii].XValueMember = "rownum";

               chartCyt.Series[2*ii].YValueMembers = "Mean";

               chartCyt.Series[2*ii].LegendText = "MEAN  (" + sCyt + ")";

               chartCyt.Series[2*ii + 1].XValueMember = "rownum";

               chartCyt.Series[2*ii + 1].LegendText = "     SD  (" + sCyt + ")";

               chartCyt.Series[2*ii + 1].YValueMembers = "StdDev";

               chartCyt.Series[2*ii + 1].ChartType = SeriesChartType.Point;

               chartCyt.ChartAreas[ii].AxisX.MajorGrid.Enabled = false;

               chartCyt.ChartAreas[ii].AxisX.Title = "Stim Concentration";

               chartCyt.ChartAreas[ii].AxisX.LabelStyle.Interval = 1;

               chartCyt.DataBind();

               for (int i = 0; i < chartCyt.Series[sCyt].Points.Count; i++)

               {

                   chartCyt.Series[sCyt].Points[i].AxisLabel = _arrXlabel[i];

               }

           }

  3. moncheri says:

    Hi Alex

    Is it possible to use this control for SQL Server Reporting Services?

    Thanks in advance.

  4. ccko says:

    Hello,

    i want to create x axis just like below pictures.

    http://img2.pict.com/e9/3a/99/3439672/0/800/1.jpg

    could you please help me?

    thank u.

  5. Anonymous says:

    For those looking for some documentation on how to get started with VS.NET 2010 from an upgraded 2008 project, check out the following:

    Updating Microsoft Charting Controls for .NET from VS.NET 2008 to VS.NET 2010:

    allen-conway-dotnet.blogspot.com/…/updating-microsoft-charting-controls.html

  6. Anonymous says:

    Microsft Chart Control has less feature than the current dundas control.

  7. smcirish says:

    GANTT charts

    Are Gantt charts supported the same way as in Dundas?  The same features, options, etc?

  8. smcirish says:

    GANTT charts

    Are Gantt charts supported the same way as in Dundas?  The same features, options, etc?

  9. smcirish says:

    GANTT charts

    Are Gantt charts supported the same way as in Dundas?  The same features, options, etc?

  10. Anonymous says:

    Hi Alex,

    We are usign Chart control for real-time visualization of continuous-time data received at COM4 (SerialPort object).

    We implemented SerialPort_DataReceived event handler and enqueue the received data (Queue object).

    Then I used a Timer object as a fixed period of 10ms to update the Chart object (in the same way shown in the Real-Time data of the Examples for the Chart control) fron the data in the Queue

    We programm a device attached to the USB port in the PC. The device emulate a COMx port. We define the samples per second (sps) in the device. At a speed of 100sps every thing works fine. However, at 500sps the application loses some data and the graph becomes like "noisy". We added an index for every received data that shows us that some "indexes" (and acordingly some data) lose.

    We notice that "DataReceived()" and "Tick()" events are asynchronous to each other and suspect this could be a problem becous if we are "receiving data" and "Tick()" event interrupts, the we may lose the current data.

    What do you think about?

    Can somebady provide some advice?

    Regards…

    Replays may be send to rr_campos@hotmail.com

  11. Anonymous says:

    Hi ,

    can i reduce the gap between exploded slices of a 3d pie graph?.

    I want slices to be little narrower.

  12. Anonymous says:

    chart1.Series[0]["PieLabelStyle"] = "Outside";

    then

    how can I control  its width.

  13. Anonymous says:

    chart1.Series[0]["PieLabelStyle"] = "Outside";

    then

    how can I control  its width.

  14. Anonymous says:

    hello,i want to know how to set Fixed interval number on each axis。when i used Maximum and Minmum to

    come true,it throw a exception that is 'Axis Object – Auto Interval doesn’t have proper value'

    thank u!

  15. hello,i want to know how to set Fixed interval number on each axis。when i used Maximum and Minmum to

    come true,it throw a exception that is 'Axis Object – Auto Interval doesn’t have proper value'

    thank u!

  16. Hi Alex – I have my chart displaying on screen and I can save it to a .jpg file. Now I want to print it. I can print it if I call it up as the file copy. But I can't print it directly from within VB2010. It's an object so I should be able to work out how to refer to it directly instead of as a file, but this appears to be beyond my capabilities. I can print rtf documents so may be I need to importthe chart to the rtf, add some text and then print it?

    Anything by way of code snippets to assign the chart so that it prints would be appreciated.

       'Sub for printing graphic

       Private Sub PrintGraphic(ByVal sender As Object, ByVal ev As PrintPageEventArgs)

           ' Create the graphic using DrawImage

           ev.Graphics.DrawImage(Image.FromFile(TextBox1.Text), ev.Graphics.VisibleClipBounds)

           ' Specify that this is the last page to print

           ev.HasMorePages = False

       End Sub

       Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

           'Print using and error handler to catch problems

           'Dim PrintForm2 As New Form1

           Try

               AddHandler PrintDocument1.PrintPage, AddressOf Me.PrintGraphic

               PrintDocument1.Print() 'print graphc

           Catch ex As Exception

               MessageBox.Show("Sorry, there is a problem printing", ex.ToString())

           End Try

       End Sub

    This code is from Alessandros Del Sole's book – VB2010 unleashed, and not original to me.

    Thanks Robert

  17. Anonymous says:

    Hi Alex.

    As you are an expert in chart, please, look my question in msdn forum:

    social.msdn.microsoft.com/…/f00a55be-8d5a-4015-8097-1e049ca9f1fa

    Do you can help me?

    My  annotationline desapear when I move the scroolbar.

    Sorry for to use this comment, but I dont know other way to contact you.

    Thanks so much.