Sub1
sda.Fill(dt)
Dim chart As NChart = NChartControl1.Charts(0)
chart.LabelLayout.EnableInitialPositioning = True
Dim rnd As New Random
Dim OldSeries As String = ""
Dim NewSeries As String = ""
For i As Integer = 0 To dt.Rows.Count - 1
NewSeries = dt.Rows(i)(0).ToString
Dim line As New NLineSeries()
chart.Series.Add(line)
line.MultiLineMode = MultiLineMode.Series
line.Legend.TextStyle.FontStyle.EmSize = New NLength(8)
line.DataLabelStyle.Visible = True
line.Name = NewSeries
line.LineSegmentShape = LineSegmentShape.Line
line.UseXValues = True
line.BorderStyle.Color = Color.Black
line.DataLabelStyle.Visible = True
line.InflateMargins = True
line.MarkerStyle.Visible = True
line.MarkerStyle.BorderStyle.Color = Color.Black
line.MarkerStyle.FillStyle = New NColorFillStyle(Color.FromArgb(255, rnd.Next(255), rnd.Next(255), rnd.Next(255)))
line.MarkerStyle.PointShape = i
line.MarkerStyle.Width = New NLength(2, NRelativeUnit.ParentPercentage)
line.MarkerStyle.Height = New NLength(2, NRelativeUnit.ParentPercentage)
UpdateTimeSpan(NewSeries, i)
Next
' apply style sheet
Dim styleSheet As NStyleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.FreshMultiColor)
styleSheet.Apply(NChartControl1.Document)
UpdateDateTimeScale()
End Sub
Private Sub UpdateTimeSpan(Test As String, Pnt As Integer)
Dim myConnection As New SqlConnection(strConnString)
Dim myReader As SqlDataReader = Nothing
Dim dt As New DataTable()
Dim con As New SqlConnection(strConnString)
Dim sda As New SqlDataAdapter()
Dim cmd As New SqlCommand("GetProductionTestDaily")
cmd.CommandType = CommandType.StoredProcedure
Dim dteFrom As Date
Dim dteTo As Date
Dim txtTest As String Dim startDate As DateTime = DateTime.Parse(Me.txtdteFrom.Text)
dteTo = DateAdd(DateInterval.Day, 1, CDate(Me.txtdteTo.Text)).ToString
Dim endDate As DateTime
Dim rnd As New Random
endDate = dteTo
dteFrom = Me.txtdteFrom.Text
txtTest = Me.ddTest.SelectedValue
cmd.Parameters.AddWithValue("@dteFrom", dteFrom)
cmd.Parameters.AddWithValue("@dteTo", dteTo)
cmd.Parameters.AddWithValue("@Test", Test)
cmd.Connection = con
sda.SelectCommand = cmd
If startDate > endDate Then
Dim temp As DateTime = startDate startDate = endDate
endDate = temp
End If ' Get the line series from the chart
Dim chart As NChart = NChartControl1.Charts(0)
Dim line As NLineSeries = CType(chart.Series(0), NLineSeries)
Dim span As TimeSpan = endDate.Subtract(startDate)
span = New TimeSpan(span.Ticks / 30)
Dim span1 As TimeSpan '= span.Days
line.UseXValues = True
sda.Fill(dt)
If span.Ticks > 0 Then
For i As Integer = 0 To dt.Rows.Count - 1 dteTo = dt.Rows(i)(0)
span1 = dteTo.Subtract(startDate)
startDate = startDate.AddDays(span1.Days)
line.XValues.Add(startDate)
line.Values.Add(dt.Rows(i)(1))
line.MarkerStyle.PointShape = Pnt
Next
End If
End Sub