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

Q2: StackedBar100SeriesDefinition, axisX is broken for >7 bars

2 Answers 68 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Jingying Wu
Top achievements
Rank 1
Jingying Wu asked on 17 Jul 2009, 10:20 PM
I'm upgrading the binaries from Q1 to Q2 and is being blocked by this.
i have 4 graphs, 7 days, 2 weeks, 1 month and 1 year and 3 graphs are now broken : 2 weeks, 1 month and 1 year.

The count of bars are right, but the axis X remains at 8 points and does not match the bars.
I have attached a screenshot here
http://img406.imageshack.us/img406/7171/trendz.jpg

 

            if ((e.Error == null) && (radChartEvaluation2weeks.DefaultView.ChartArea.DataSeries.Count <= 0) && (e.Result != null))  
            {  
                radChartEvaluation2weeks.DefaultView.ChartArea.AxisX.IsDateTime = true;  
                radChartEvaluation2weeks.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "MM/dd";  
                radChartEvaluation2weeks.DefaultView.ChartArea.AxisX.Title = "Last 2 weeks";  
 
                radChartEvaluation2weeks.DefaultView.ChartArea.AxisY.IsZeroBased = true;  
                radChartEvaluation2weeks.DefaultView.ChartArea.AxisY.Title = "Count";  
                radChartEvaluation2weeks.DefaultView.ChartArea.AxisY.AutoRange = true;  
 
                //Add data line                
                DataSeries passAreaSeries = new DataSeries();  
                passAreaSeries.LegendLabel = StatusDataToStringValueConverter.newString("PASS");  
                passAreaSeries.Definition = new StackedBar100SeriesDefinition();  
                passAreaSeries.Definition.ShowItemLabels = false;  
                passAreaSeries.Definition.ShowItemToolTips = true;  
                passAreaSeries.Definition.Appearance.Fill = StatusDataToValueConverter.ColorValue("PASS");  
 
                DataSeries failAreaSeries = new DataSeries();  
                failAreaSeries.LegendLabel = StatusDataToStringValueConverter.newString("FAIL");  
                failAreaSeries.Definition = new StackedBar100SeriesDefinition();  
                failAreaSeries.Definition.ShowItemLabels = false;  
                failAreaSeries.Definition.ShowItemToolTips = true;  
                failAreaSeries.Definition.Appearance.Fill = StatusDataToValueConverter.ColorValue("FAIL");  
 
                DataSeries neverEvaluatedAreaSeries = new DataSeries();  
                neverEvaluatedAreaSeries.LegendLabel = StatusDataToStringValueConverter.newString("NEVEREVALUATED");  
                neverEvaluatedAreaSeries.Definition = new StackedBar100SeriesDefinition();  
                neverEvaluatedAreaSeries.Definition.ShowItemLabels = false;  
                neverEvaluatedAreaSeries.Definition.ShowItemToolTips = true;  
                neverEvaluatedAreaSeries.Definition.Appearance.Fill = StatusDataToValueConverter.ColorValue("NEVEREVALUATED");  
 
                DataSeries errorRetrievalAreaSeries = new DataSeries();  
                errorRetrievalAreaSeries.LegendLabel = StatusDataToStringValueConverter.newString("ERRORDURINGACTUALVALUERETRIEVAL");  
                errorRetrievalAreaSeries.Definition = new StackedBar100SeriesDefinition();  
                errorRetrievalAreaSeries.Definition.ShowItemLabels = false;  
                errorRetrievalAreaSeries.Definition.ShowItemToolTips = true;  
                errorRetrievalAreaSeries.Definition.Appearance.Fill = StatusDataToValueConverter.ColorValue("ERRORDURINGACTUALVALUERETRIEVAL");  
 
                DataSeries errorEvaluateAreaSeries = new DataSeries();  
                errorEvaluateAreaSeries.LegendLabel = StatusDataToStringValueConverter.newString("ERRORDURINGEVALUATION");  
                errorEvaluateAreaSeries.Definition = new StackedBar100SeriesDefinition();  
                errorEvaluateAreaSeries.Definition.ShowItemLabels = false;  
                errorEvaluateAreaSeries.Definition.ShowItemToolTips = true;  
                errorEvaluateAreaSeries.Definition.Appearance.Fill = StatusDataToValueConverter.ColorValue("ERRORDURINGEVALUATION");  
 
                DataSeries errorInitAreaSeries = new DataSeries();  
                errorInitAreaSeries.LegendLabel = StatusDataToStringValueConverter.newString("ERRORDURINGINITALIZATION");  
                errorInitAreaSeries.Definition = new StackedBar100SeriesDefinition();  
                errorInitAreaSeries.Definition.ShowItemLabels = false;  
                errorInitAreaSeries.Definition.ShowItemToolTips = true;  
                errorInitAreaSeries.Definition.Appearance.Fill = StatusDataToValueConverter.ColorValue("ERRORDURINGINITALIZATION");  
 
                foreach (Microsoft.Search.Silverlight.GTI.GTIServiceReference.IndicatorEvaluationTrend trendValue in e.Result.IndicatorEvaluationTrend)  
                {  
                    passAreaSeries.Add(new DataPoint { XValue = trendValue.Date.ToOADate(), YValue = trendValue.PassCount });  
                    failAreaSeries.Add(new DataPoint { XValue = trendValue.Date.ToOADate(), YValue = trendValue.FailCount });  
                    neverEvaluatedAreaSeries.Add(new DataPoint { XValue = trendValue.Date.ToOADate(), YValue = trendValue.NeverEvaluatedCount });  
                    errorRetrievalAreaSeries.Add(new DataPoint { XValue = trendValue.Date.ToOADate(), YValue = trendValue.ErrorDuringActualValueRetrievalCount });  
                    errorEvaluateAreaSeries.Add(new DataPoint { XValue = trendValue.Date.ToOADate(), YValue = trendValue.ErrorDuringEvaluationCount });  
                    errorInitAreaSeries.Add(new DataPoint { XValue = trendValue.Date.ToOADate(), YValue = trendValue.ErrorDuringInitalizationCount });  
                }  
 
                radChartEvaluation2weeks.DefaultView.ChartArea.DataSeries.Add(passAreaSeries);  
                radChartEvaluation2weeks.DefaultView.ChartArea.DataSeries.Add(failAreaSeries);  
                radChartEvaluation2weeks.DefaultView.ChartArea.DataSeries.Add(neverEvaluatedAreaSeries);  
                radChartEvaluation2weeks.DefaultView.ChartArea.DataSeries.Add(errorRetrievalAreaSeries);  
                radChartEvaluation2weeks.DefaultView.ChartArea.DataSeries.Add(errorEvaluateAreaSeries);  
                radChartEvaluation2weeks.DefaultView.ChartArea.DataSeries.Add(errorInitAreaSeries);      
            } 

 

2 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 23 Jul 2009, 09:11 AM
Hi Jingying Wu,

Indeed, RadChart behaves differently in the Q2.2009 release and the reason is a new feature which the previous versions lacked. It is called "strict mode" and is enabled automatically as soon as a data point from the data source gets its XValue set. This instructs the 'X' axis to start placing each item on exactly the place corresponding to is XValue property. You can find more information on this here.

What we would recommend you is to start using the new "categorical axis" feature, which will group your bars in categories placed continuously on the x axis(without gaps). You can find more information here.

Here are the steps you should do:
  1. Set AxisX.IsDateTime property to false.
  2. Replace all manually added DataSeries instances with their SeriesMapping counterparts. For example the first DataSeries should be replaced with somthing like this:
                SeriesMapping passAreaMapping = new SeriesMapping(); 
                passAreaMapping.LegendLabel = StatusDataToStringValueConverter.newString("PASS"); 
                passAreaMapping.SeriesDefinition = new StackedBar100SeriesDefinition(); 
                passAreaMapping.SeriesDefinition.ShowItemLabels = false
                passAreaMapping.SeriesDefinition.ShowItemToolTips = true
                passAreaMapping.SeriesDefinition.Appearance.Fill = StatusDataToValueConverter.ColorValue("PASS"); 
     
                ItemMapping m1 = new ItemMapping("PassCount", DataPointMember.YValue); 
                ItemMapping m2 = new ItemMapping("Date", DataPointMember.XCategory); 
     
                passAreaMapping.ItemMappings.Add(m1); 
                passAreaMapping.ItemMappings.Add(m2); 
     
                radChartEvaluation2weeks.SeriesMappings.Add(passAreaMapping); 
     
                radChartEvaluation2weeks.ItemsSource = e.Result.IndicatorEvaluationTrend; 
  3. Bind the control to the data source as shown in the last line of code above.
  4. Change the type of the Date field to string.

We are sorry for this inconvenience and hope this will help you. Should you have any further questions, please do not hesitate to write us back.

Kind regards,
Velin
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rory
Top achievements
Rank 1
answered on 17 Aug 2009, 05:00 PM
Hello,
I used your code for my Chart where we wanted January, February, March... on the XAxis and it worked great.  
Thank very much.
Tags
Chart
Asked by
Jingying Wu
Top achievements
Rank 1
Answers by
Velin
Telerik team
Rory
Top achievements
Rank 1
Share this question
or