StepAreaSeries not showing after adding them in code behind

2 posts, 1 answers
  1. CreoniX
    CreoniX avatar
    58 posts
    Member since:
    Sep 2009

    Posted 07 Apr 2014 Link to this post

    Basically the problem is I'm trying to add series to the graph but I've tried everything possible in the StepAreaSeries they just won't show

            private void FillChart()
                IList<ChartDisplayData> productionList = new List<ChartDisplayData>();
                IList<ChartDisplayData> downTimeList = new List<ChartDisplayData>();
                //resize chart width based on number of points
                UpDownTimeChart.Width = ContentGrid.ActualWidth - 100;
                _Items.Where(c => c.DTID == null).ToList().ForEach(pi => 
                    productionList.Add(new ChartDisplayData { XValue = pi.Start, YValue = pi.CounterBTL.Value });
                        productionList.Add(new ChartDisplayData { XValue = pi.End, YValue = 0 });
                ProductionSeries.ItemsSource = productionList;
                int MaxBtlCounter = MaxChartValue;
                //Remove previous DT charts
                UpDownTimeChart.Series.RemoveAll(c => c.Name != "ProductionSeries");
                IEnumerable<IGrouping<Guid?, Item>> DTTypeIDs = _Items.Where(c => c.DTID != null).GroupBy(c => c.DTCauseTypeID);
                foreach (IGrouping<Guid?, Item> DTTypeID in DTTypeIDs)
                    Item DTItem = _Items.Where(c => c.DTCauseTypeID == DTTypeID.Key).FirstOrDefault();
                    StepAreaSeries serie = new StepAreaSeries();
                    serie.CombineMode = Telerik.Charting.ChartSeriesCombineMode.None;
                    serie.CategoryBinding = new PropertyNameDataPointBinding{ PropertyName = "XValue"};
                    serie.ValueBinding = new GenericDataPointBinding<ChartDisplayData, int> { ValueSelector = Data => Data.YValue };
                    Style serieStyle = new Style();
                    serieStyle.TargetType = typeof(Path);
                    Setter serieColorSetter = new Setter();
                    serieColorSetter.Property = StepAreaSeries.FillProperty;
                    serieColorSetter.Value = new SolidColorBrush(StringExtensions.HexStringToColor(DTItem.DTCauseTypeColor));
                    serie.AreaShapeStyle = serieStyle;

                    foreach (var item in DTTypeID)
                        var cdcStart = new ChartDisplayData();
                        cdcStart.XValue = item.Start;
                        cdcStart.YValue = item.CounterBTL.Value;
                        var cdcEnd = new ChartDisplayData();
                        cdcEnd.XValue = item.End;
                        cdcEnd.YValue = 0;

                    serie.ItemsSource = downTimeList;

    1.<telerik:RadCartesianChart x:Name="UpDownTimeChart"><br>                <telerik:RadCartesianChart.HorizontalAxis><br>                    <telerik:DateTimeContinuousAxis LabelFormat="HH:mm" PlotMode="OnTicks" MajorStepUnit="Hour"<br>                                                    MaximumTicks="25" MajorTickOffset="1" MajorStep="1"/><br>                </telerik:RadCartesianChart.HorizontalAxis><br>                <telerik:RadCartesianChart.VerticalAxis><br>                    <telerik:LinearAxis Maximum="{Binding MaxChartValue}"/><br>                </telerik:RadCartesianChart.VerticalAxis><br>                <telerik:StepAreaSeries x:Name="ProductionSeries" CategoryBinding="XValue" ValueBinding="YValue"><br>                    <telerik:StepAreaSeries.AreaShapeStyle><br>                        <Style TargetType="Path"><br>                            <Setter Property="Fill" Value="Green"/><br>                        </Style><br>                    </telerik:StepAreaSeries.AreaShapeStyle><br>                </telerik:StepAreaSeries><br>            </telerik:RadCartesianChart>

    Can someboy help me out on this issue? Thanks !
  2. Answer
    Petar Marchev
    Petar Marchev avatar
    996 posts

    Posted 08 Apr 2014 Link to this post


    Thank you for the attached code snippet. I was unable to get the code behind part running due to missing elements. However, I think I see what is happening.

    You are using the following code:
    serieStyle.TargetType = typeof(Path);
    serieColorSetter.Property = StepAreaSeries.FillProperty;

    This is a type mismatch. You probably intended to se the Path.Fill property:
    serieColorSetter.Property = Path.FillProperty;

    Give this a try, I think it will solve the issue. I hope this information helps.

    Petar Marchev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top