StepAreaSeries not showing after adding them in code behind

2 posts, 1 answers
  1. CreoniX
    CreoniX avatar
    28 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 });
                    if(!IsDetailMode.Value)
                        productionList.Add(new ChartDisplayData { XValue = pi.End, YValue = 0 });
                });
                ProductionSeries.ItemsSource = productionList;
                int MaxBtlCounter = MaxChartValue;
                UpDownTimeChart.Series.Add(ProductionSeries);
                //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));
                    serieStyle.Setters.Add(serieColorSetter);
                    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;

                        downTimeList.Add(cdcStart);
                        downTimeList.Add(cdcEnd);
                    }
                    serie.ItemsSource = downTimeList;
                    UpDownTimeChart.Series.Add(serie);
                }
            }
    WPF
              

                   
    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
    Admin
    Petar Marchev avatar
    968 posts

    Posted 08 Apr 2014 Link to this post

    Hello,

    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.

    Regards,
    Petar Marchev
    Telerik
     

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top