Hello!
I made a line graph that is giving me the following output:
Below is the basic code:
chartProcessStats1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart 'chartProcessStats1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ScatterLineChart
Dim temparrayx() As Decimal = New Decimal() {-10, 10, 100, 110, 120} Dim temparrayy() As Decimal = New Decimal() {0.5, 3, 2, 3, 1}
Dim graphval As New NumericSeries()
Dim k As Integer = 0
chartProcessStats1.LineChart.ChartComponent.Series.Clear()
While (k < temperaturearray.Length)
graphval.Points.Add(New NumericDataPoint(temparrayy(k), temparrayx(k), False))
k = k + 1 End While
chartProcessStats1.LineChart.ChartComponent.Series.Add(graphval)
temperaturearray = {} errorarray = {}
It appears the output is a result of the x axis being entered as a string rather than a decimal (despite the fact the actual array is made up of decimal values). Is there a way to enter the x axis as decimals (so the graph scales properly)?
Thanks in advance!
Consolidated Below
John,
Thank you for the reply! I had a few issues with your code. I was able to play around with the example you gave me and eventually got this graph (as I'm sure was the expected result):
I was still getting the following error on the form page, however:
Regardless, if it was able to run, this is probably a moot point (just thought I'd let you know, in case the sample code you're giving is providing some kind of odd error).
I edited my original code to fit your example (shown below):
Dim k As Integer = 0 Dim temprow Dim temparrayx() As Decimal = New Decimal() {-10, 10, 100, 110, 120} Dim temparrayy() As Decimal = New Decimal() {0.5, 3, 2, 3, 1}
UltraDataSource1.Band.Columns.Add("ColumnX", GetType(Integer)) UltraDataSource1.Band.Columns.Add("ColumnY", GetType(Integer))
temprow = New Object() {errorarray(k), temperaturearray(k)} UltraDataSource1.Rows.Add(temprow)
chartProcessStats1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ScatterLineChart chartProcessStats1.DataSource = UltraDataSource1 chartProcessStats1.ScatterChart.ColumnX = 0 chartProcessStats1.ScatterChart.ColumnY = 1 chartProcessStats1.ScatterChart.ConnectWithLines = True chartProcessStats1.DataBind()
Unfortunately, I got the following error:
I'm assuming the way I added the points to the chart is incorrect. Any help you can give me would be greatly appreciated. Thanks!
Hello Jeremy,
The LineChart will populate the series’ Y values with one row’s data found in each numeric column, and populate the X values according to the string keys of the columns themselves. It knows the x values only by the string keys, so this doesn’t provide the functionality of the chart understanding your x values that you want.
The Scatter Chart will populate the series using 2 numeric columns, and you will specify the X and Y columns via the UltraChart.ScatterChart.ColumnX and UltraChart.ScatterChart.ColumnY properties. For more information on this, please visit: http://help.infragistics.com/doc/WinForms?page=Chart_Working_with_Scatter_Chart_Data.html
This will allow the chart to understand your X values and, among other things, space out your points along the X axis according to their value. I’ve attached a sample project which should show you how you can create a ScatterChart with this ability.
Concerning changing the range of the axis, you’ll need to set the Axis’ RangeType to Custom to see your RangeMin and RangeMax settings appear.
Please let me know if there’s anything further I can help you with.