This is a migrated thread and some comments may be shown as answers.

StepAreaSeries not showing after adding them in code behind

1 Answer 10 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
JIG
Top achievements
Rank 1
JIG asked on 07 Apr 2014, 02:34 PM
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 !

1 Answer, 1 is accepted

Sort by
0
Accepted
Petar Marchev
Telerik team
answered on 08 Apr 2014, 08:21 AM
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.

 
Tags
ChartView
Asked by
JIG
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or