I’m trying to duplicate a chart I’ve seen in application, but am having trouble doing with C1Chart. The chart I’m trying to duplicate is the attached chart1.png. It is the plotted difference between points in two other data sets, the difference between dataseries(0).y and dataseries(1).y all across the x axis.
The generated data seems to be okay, but when I put together the alarm zone, I don’t get what I’m looking for. If I set all the extents to 0 I get chart2.png, which is close but not exact. It seems to connect the Y of the first and last points. If I try to set the extents to match the data I get chart3.png doesn’t show an alarm zone at all.
I’ve pasted my code for setting up the data series and alarm zone below.
Can anyone tell me what I’m missing in setting up this chart?
Dim devDataSeries2 As C1.Win.C1Chart.ChartDataSeries = devChartData.SeriesList.AddNewSeries()
devDataSeries2.X.Length = 2000
devDataSeries2.Y.Length = 2000
devDataSeries2.SymbolStyle.Color = Drawing.Color.BlueViolet
devDataSeries2.SymbolStyle.OutlineColor = Drawing.Color.Black
devDataSeries2.SymbolStyle.Shape = C1.Win.C1Chart.SymbolShapeEnum.None
devDataSeries2.LineStyle.Pattern = C1.Win.C1Chart.LinePatternEnum.Solid
devDataSeries2.LineStyle.Color = Drawing.Color.Red
Dim azs As C1.Win.C1Chart.AlarmZonesCollection = chrtSpectralDeviation.ChartArea.PlotArea.AlarmZones
Dim az As C1.Win.C1Chart.AlarmZone = azs.AddNewZone()
az.BackColor = Drawing.Color.FromArgb(100, Drawing.Color.LimeGreen)
az.Shape = C1.Win.C1Chart.AlarmZoneShapeEnum.Polygon
'az.PolygonData.PolygonSource = C1.Win.C1Chart.PolygonSourceEnum.DataSeries
'az.PolygonData.SeriesIndex = 0
az.PatternStyle = Drawing.Drawing2D.HatchStyle.Vertical
az.Name = "Deviation"
az.UpperExtent = 0 'pntsYMax
az.LowerExtent = 0 'pntsYMin
az.NearExtent = 0 'diffpts2(0).X
az.FarExtent = 0 'diffpts2(diffpts2.GetUpperBound(0)).X
az.Visible = True
Please refer to the attached sample wherein I have constructed two datasets both containing Products table of C1Nwind database.
The series being plotted on the chart contains Y values taken as the difference between the Column1 values & Column3 values of the Products Table in DataSet1 & DataSet2 respectively.
Let me know if I misunderstood your query.
Thank you for responding, that does get me a chart that has the alarm zone look I want, but the data does not seem to follow. What seems to always happen is that the first and last points are connected and the alarm zone is shown between that connecting line and the curve of the data, as shown in my chart2.png. What I need to see is the alarm zone between 0 and the difference data. So I’m not sure if I need to chart 0 and the difference value on the same X axis point, of if there is some other way to do it.
I tried to modify your example but couldn’t get anything to work right. Do I need to chart 0 and the value on more than one Y series to get what I’m looking for?
Could you please elaborate more on what exactly you meant by creating the 'alarm zone between 0 and the difference data? It would be better if you can post a small sample replicating the issue with the data that you are using to plot the alarm zone along with the desired output so that I could provide you with further assistance accordingly ?
I’ve put together a Q&D program to illustrate what I’m trying to do. As you can see from the chart that I’d like to duplicate in chart1.png, all of the data looks to be shown as a distance from 0, with a nice, smooth line.
The issues I’m having with C1Chart are that the only way I can get a base line of 0 across the whole chart is to add a 0 value a at the first and last X coordinates. I think this is an invalid solution as it’s not the true data set. What I get without those erroneous data points when the alarm zone gets applied is the charted line, then a line that connects the first and last points, presumably because the chart is closing the polygon of the alarm zone. In addition, if I apply a FitType of Spline, the alarm zone does not match the spline, it sticks to the rigid polygon shape.
All of this is with an XYPlot, what I’m wondering at this point, given the issues that I keep running into, is whether or not I need to try a different type of chart, like HiLo, to get what I’m looking for. As you use two Y values, I think that might get me closer, but I’m not really sure about having the points close together with a smooth profile.
Thank you for your help. Please let me know if you have any questions.
It is the design behaviour that Alarm Zones are created against the y-values of the data & if you require a straight line from start to end then you would have to explicitly set the first & last y-values to zero.
Please refer to “AlarmZoneShapes” sample; you may find it in My Documents-Componentone Samples-Studio for Winforms-C1Chart-CS-AlarmZoneShapes, for more information on the same.
Let me know if you have any further queries.
You must be logged in to reply to this topic.