Profile Picture

DateTimeScale and DataBindingManager Help

Posted By Andy Lindsay 12 Years Ago
Author
Message
Andy Lindsay
Posted 12 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)Forum Newbie (2 reputation)

Group: Forum Members
Last Active: 12 Years Ago
Posts: 2, Visits: 1
Hi All, I have a MySQL database which will be loaded with info and i wish to display this as a sampled Line with multiple series.

Its almost working...

Using the examples I have created a Sampled Line Graph that successfully displays data from mySQL database, however its displaying the number of record on the Yaxis. So I took some code from the datetimescale example, the problem is I don't know how to tell the databindingmanager to add the 'date' column of the datasource and use it as the yaxis ? Below is the code i am using

' set a chart title
Dim title As NLabel = NChartControl1.Labels.AddHeader("Date Time Scale")
title.TextStyle.TextFormat = TextFormat.XML
title.TextStyle.FontStyle = New NFontStyle("Times New Roman", 18, FontStyle.Italic)
title.ContentAlignment = ContentAlignment.BottomCenter
title.Location = New NPointL(New NLength(50, NRelativeUnit.ParentPercentage), New NLength(2, NRelativeUnit.ParentPercentage))

' no legend
NChartControl1.Legends.Clear()

' Add a line series
Dim m_chart As NChart = NChartControl1.Charts(0)
Dim m_Line As NLineSeries = CType(m_chart.Series.Add(SeriesType.Line), NLineSeries)

'm_Line = CType(m_Chart.Series.Add(SeriesType.Line), NLineSeries)
m_Line.Name = "Line Series"
m_Line.InflateMargins = True
m_Line.DataLabelStyle.Visible = True
m_Line.MarkerStyle.Visible = True
m_Line.MarkerStyle.BorderStyle.Color = Color.DarkRed
m_Line.MarkerStyle.PointShape = PointShape.Cylinder
m_Line.MarkerStyle.Width = New NLength(1.5F, NRelativeUnit.ParentPercentage)
m_Line.MarkerStyle.Height = New NLength(1.5F, NRelativeUnit.ParentPercentage)

m_Line.SamplingMode = SeriesSamplingMode.Enabled
m_Line.UseXValues = True

' create a date time scale
Dim m_DateTimeScale As NDateTimeScaleConfigurator
Dim dateTimeScale As NDateTimeScaleConfigurator = New NDateTimeScaleConfigurator()

m_DateTimeScale = dateTimeScale
m_DateTimeScale.LabelStyle.Angle = New NScaleLabelAngle(ScaleLabelAngleMode.Scale, 90)
m_DateTimeScale.LabelStyle.ContentAlignment = ContentAlignment.MiddleLeft
m_chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale
Dim xAxis As NAxis = m_chart.Axis(StandardAxis.PrimaryX)
xAxis.ScrollBar.Visible = True

' add interlaced stripe to the Y axis
Dim linearScale As NLinearScaleConfigurator = TryCast(m_chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator, NLinearScaleConfigurator)
Dim stripStyle As NScaleStripStyle = New NScaleStripStyle(New NColorFillStyle(Color.Beige), Nothing, True, 0, 0, 1, 1)
stripStyle.Interlaced = True
stripStyle.SetShowAtWall(ChartWallType.Back, True)
stripStyle.SetShowAtWall(ChartWallType.Left, True)
linearScale.StripStyles.Add(stripStyle)

' apply style sheet
Dim styleSheet As NStyleSheet = NStyleSheet.CreatePredefinedStyleSheet(PredefinedStyleSheet.Nevron)
styleSheet.Apply(NChartControl1.Document)

Dim chart As NCartesianChart = CType(NChartControl1.Charts(0), NCartesianChart)
chart.RangeSelections.Add(New NRangeSelection())
chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = True
chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = True

NChartControl1.Controller.Selection.Add(chart)

' configure interactivity
NChartControl1.Controller.Tools.Add(New NAxisScrollTool())
NChartControl1.Controller.Tools.Add(New NDataZoomTool())

myCommand.Connection = conn
myCommand.CommandText = SQL

myAdapter.SelectCommand = myCommand
myAdapter.Fill(myData)

Dim dataBindingManager As NDataBindingManager = NChartControl1.DataBindingManager

dataBindingManager.EnableDataBinding = True

dataBindingManager.AddBinding(0, 0, "Values", myData, "l1_volts")
dataBindingManager.UpdateChartControl()

NChartControl1.Refresh()




Similar Topics


Reading This Topic