Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1060
Multiple (dynamic) Series in Data Chart.
posted

Hi,

I have a requirements to create a data chart which eventually have 4 (confirmed: not more not less) series.

  • 2 Line Series
  • 1 Column Series
  • 1 Range Area 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.

Parents Reply Children
No Data