Adding line graph with months and a point for each day

I have data that I need to add a point for each day. I have my code working well enough to label my x axis as mar feb apr etc. Where I'm stuck is on how I add all of the data points.
I have the stored in a datatable with three fields, label (the month), position (an int of its position i.e. 0 is jan, 1 is feb etc), and value (the daily value)

Here's the code I have so far on trying to add the points but it doesn't seem to be working. I'm fairly new with these charts, so please bear with me.

'a holder for the current month

DimcurrentMonth = ""

'a holder for the count

Dimcount = -1

DimrangeTable AsNewDataTable

rangeTable.Columns.Add("Label")

rangeTable.Columns.Add("Position")

rangeTable.Columns.Add("Value")

Using myconn AsNewSqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("connection").ToString)

myconn.Open()

Dimcmd = NewSqlCommand(sql, myconn)

Dimreader = cmd.ExecuteReader()

Whilereader.Read()

'if the currentMonth is new, then we add it to the data table for a range

IfNot(currentMonth = (Format(reader("DateHour"), "MMMM"))) Then

currentMonth = Format(reader("DateHour"), "MMMM")

count = count + 1

EndIf

rangeTable.Rows.Add(currentMonth, count, reader("PointAverage"))

'Dim tempSeries As New ChartSeries

'tempSeries.SetValues(1, 2)

'chart.Series.Add(tempSeries)

EndWhile

myconn.Close()

EndUsing 'using myconn

'add the range

chart.PlotArea.XAxis.AddRange(0, count, 1)

ForEachi AsDataRow InrangeTable.Rows

chart.PlotArea.XAxis(i("Position")).TextBlock.Text = i("Label")

DimtempSeries AsNewChartSeries

tempSeries.SetValues(i("Position"), i("Value"))

chart.Series.Add(tempSeries)

Next

A sample of what my data table would look like is something like this
Label Position Value
january 0 10
january 0 20
january 0 30
february 1 10
february 1 20
etc.

Essentially, I need to add all of the points in each month, but they are in succession by day. So I pull all of the days for jan, feb, and so on. Any ideas on how to go about this?

Petar Marchev

I created a new project using your code. I had to modify it slightly because I do not have your database. When I run the project I do get a populated chart - examine the attached snapshot ChartOk.png.

You said that it isn't working and I can see that it is, but this is probably not the output that you need for your project.

This is why I have attached a very simple project that will get you started with our asp.net ajax chart. I have also attached a snapshot of the output that it produces.

In the attached project I have created a new class DateInfo, which I think suits the needs of your current project. It has properties Position, Value, Label. I have created a list of DateInfo (instead of the DataTable) that will be the source of the chart. I have removed the DataTable because it was an unneeded intermediary.

Now we should specify how the chart should process a DateInfo. This is done in html by setting the DataXColumn and DataYColumn properties of the chart series and DataLabelsColumn property of the X axis.

I hope this short introduction helps. I would suggest that you examine our online demos so that you get familiar with the chart features, limitations and how to-s.

All the best,
Petar Marchev
the Telerik team

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

Second Edit* So I'm a bit further but I'm still stuck. I am adding things to the graph but it looks crazy so I'm not doing something right. In order to help you guys help me, I posted is some of the data I am using. You see how the label is the month the position is the int position, the value is the y value and count is where it sits within a given x position. Here is a link to some code. http://dl.dropbox.com/u/4979877/code.txt You can take this and create the same data table I'm using to help me figure this out. I pasted my code below the data as to how I'm trying to do it now. Hopefully I got you enough stuff to help me out :). Thanks in advance.

Petar Marchev

I created a new project using the code you have provided. I had to make slight changes to it so that I can run and test it.

I see a total of 10 bars and a lot of labels. The reason for the many labels is that you have many items. The reason for only 10 bars is that for each series item of the same month you are specifying the same XValue:

myPoint.XValue = i("Position")

If you want to see a different bar for each data item you need to give each series item a unique XValue, for instance:

myPoint.XValue = counter

counter = counter + 1

If you need further help - you can send us a drawing of some sort, so that we can understand what are the needed results and output.

Until then, I again recommend that you examine our examples here, so that you can learn what is possible and how to achieve it with RadChart.

Regards,
Petar Marchev
the Telerik team

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.