Hi,
I have a requirements to create a data chart which eventually have 4 (confirmed: not more not less) series.
All these series must be created dynamically (i.e. their X-Axis and Y-Axis points) based on some calculation on my DTO object. Previously I successfully created a chart using xamWebChart which have one line series and 1 column series, as described here. Now my requirement is to add Range Area series in it as shown in this images.
I found that xamDataChart only have this "Range Area Series" but I don't know how can I create datapoints dynamically in it. Here is the some sample code which I did previously for creating xamWebChart. I will appreciate if someone help me to give any idea how can I achieve my requirements. If I can also add "Range Area Series" (or something similar to requirements) then it will be awesome.
/*************************************Create Series and Axes of chart*********************/
/* minyear and maxyear have number of points to be created.
theChart.Series.Clear(); theChart.Axes.Clear(); int mYear = minYear; Series lineSeries = new Series { ChartType = ChartType.Line, AxisX = "x1", AxisY = "y1" }; Series columnSeries = new Series { ChartType = ChartType.Column, AxisX = "x1", AxisY = "y2", Stroke = new SolidColorBrush(Colors.Transparent), Opacity = 0.2, UseDataTemplate = true }; columnSeries.DataPointStyle = (Style)this.Resources["columnSeriesPointStyle"]; LinearGradientBrush linBrush = new LinearGradientBrush(); linBrush.Opacity = 0.2; linBrush.GradientStops.Add(new GradientStop { Color = Infragistics.ColorConverter.FromString("#FFBF00") }); columnSeries.Fill = linBrush; while (mYear <= maxYear) { lineSeries.DataPoints.Add(new DataPoint(0, mYear.ToString()) { Marker = new Marker { Type = MarkerType.None } }); columnSeries.DataPoints.Add(new DataPoint(0)); mYear = mYear + 1; } Axis x1Axis = new Axis { AxisType = AxisType.PrimaryX, Name = "x1" }; x1Axis.MajorGridline = new GridlineGroup { Visibility = Visibility.Collapsed }; x1Axis.MinorGridline = new GridlineGroup { Visibility = Visibility.Collapsed }; Axis y1Axis = new Axis { AxisType = AxisType.PrimaryY, Name = "y1" }; y1Axis.MajorGridline = new GridlineGroup { Visibility = Visibility.Collapsed }; y1Axis.MinorGridline = new GridlineGroup { Visibility = Visibility.Collapsed }; Axis y2Axis = new Axis { AxisType = AxisType.SecondaryY, Name = "y2", Minimum = 0, Maximum = 1, Unit = 1, AutoRange = false, Visibility = Visibility.Collapsed }; y2Axis.MajorGridline = new GridlineGroup { Visibility = Visibility.Collapsed }; y2Axis.MinorGridline = new GridlineGroup { Visibility = Visibility.Collapsed }; theChart.Axes.Add(x1Axis); theChart.Axes.Add(y1Axis); theChart.Axes.Add(y2Axis); theChart.Series.Add(lineSeries); theChart.Series.Add(columnSeries);
/***************************************Add Chart points and Data*************************/
Axis y1Axis = theChart.Axes.FirstOrDefault<Axis>(axis => axis.AxisType == AxisType.PrimaryY);Series lineSeries = theChart.Series.FirstOrDefault<Series>(series => series.ChartType == ChartType.Line);int seriesDataPointInedex = 0;while (mYear <= maxYear){ lineSeries.DataPoints[seriesDataPointInedex].Value = valueofPoint; seriesDataPointInedex = seriesDataPointInedex + 1; mYear = mYear + 1;}Series columnSeries = theChart.Series.FirstOrDefault<Series>(series => series.ChartType == ChartType.Column);DataPoint dp = columnSeries.DataPoints[ddlYear.SelectedIndex];dp.Value = 1;
Kindly help.
The DatChart control handles data points differently from XamWebChart. The number of points is inferred from your data; there is no way to add/remove points directly to the chart. If you add a value to your data, the chart will add a point to the series. Please check out the code in our DV samples to get more familiar with the DataChart control:http://samples.infragistics.com/sldv/ComponentOverview.aspx?cn=data-chart
Thank you Max for your response. So its mean I will not have access to set each point marker in Data Chart. For example for some datapoint I want to display Marker and for some don't want to display marker on that point?
Moreover I will also have to move column chart bases on Year value selected in combo. Basically I am using Column chart to highlight year only.
And also just a confirmation, does Web Chart does not have this Area Chart category?
Thanks,
M. Irfan