How to create multi series line graphs in asp.net by accessing data from SQL server RRS feed

  • Question

  • Dear Sir,

    I have a table in sql server which contains spring water discharge on monthly basis. Structure of table is - <SPRING_CODE, MEASURING DATE, DISCHARGE_LTR). Now I want to create graphs in asp.net in which DISCHARGE will be shown for every month from Jan - Dec and will show separate line for every year.

    So, plz help me to create this type of graphs.




    Thursday, June 2, 2011 7:32 AM

All replies

  • DineshNegi, I guess by asking your question in the Chart Controls for .NET Framework forum you already have started looking at these controls.

    Is your measuring date monthly already or would you need to consolidate/average 2 or more measurements for a given month first? Something to consider.

    Anyway, here are some thoughts:

    I suggest loading your table data into a DataSet. The Chart Controls work well with the DataSet/DateTable classes through the Series.Points.DataBind method. When selecting the data from the db, I would add two additional fields in the select query for datepart(year, MeasuringDate), datepart(month, MeasuringDate). This way, you'll have the year and month split up as separate columns in the DataTable. Each Year becomes a Series in the chart (Chart.Series) with the Month as your X-axis. For the line chart, set each Series.ChartType = SeriesChartType.Line.

    Hope this helps,


    Thursday, June 2, 2011 3:48 PM

    You must use databindCrosstab method to generate multiple series for each Code:


      chart.ChartAreas(0).AxisX.IntervalType = DateTimeIntervalType.Months 

      chart.DataBindCrossTable(gDS, "CODE", "DATE", "LTR", String.Empty)



    Monday, June 6, 2011 7:27 PM