I have a stacked bar chart where some of the bars far exceed the automatically generated Y-axis maximum (see attached "clipped stacked bar chart.jpg").
The data comes from an ObservableCollection of a domain object with five floats( called Series1 through Series5). I tried modifying the height of the chart in the completed event. I'm not sure how understandable the partially scrubbed code is, but here is the event and two methods called in the call stack.
Thanks.
The data comes from an ObservableCollection of a domain object with five floats( called Series1 through Series5). I tried modifying the height of the chart in the completed event. I'm not sure how understandable the partially scrubbed code is, but here is the event and two methods called in the call stack.
void GetViewCompleted(object sender, GetViewCompletedEventArgs e) { txtUnAssignedMsg.Visibility = Visibility.Collapsed; SetChart("MyXThing", Y1, Y2, Y3, Y4, Y5); if (e.Result.Count > 0) { radChart1.ItemsSource = e.Result; #region Manipulating the Y Axis span double sum = 0; foreach (var fleetView in e.Result) { sum = Math.Max(sum, fleetView.Series1 + fleetView.Series2 + fleetView.Series3 + fleetView.Series4 + fleetView.Series5); } ChartArea chartArea = radChart1.DefaultView.ChartArea; chartArea.AxisY.AutoRange = true; double min = chartArea.AxisY.ActualMinValue; double max = chartArea.AxisY.ActualMaxValue; double step = chartArea.AxisY.ActualStep; chartArea.AxisY.AutoRange = false; //chartArea.AxisY.MaxValue = sum; // This throws an exception chartArea.AxisY.AddRange(min, sum, step); // This gives me an unreadable scale #endregion } }This results in an even more messed up chart as seen in the attached "bar chart with modified y maximum.jpg". What is the best way to ensure that large outlying stacked bar charts are not clipped?public void SetChart(string strXValue, string y1, string y2, string y3, string y4, string y5) { radChart1.ItemsSource = null; radChart1.SeriesMappings.Clear(); const int distance = 15; MapPresentationToStackedBarChart(strXValue, y1, distance, SERIES1); MapPresentationToStackedBarChart(strXValue, y2, distance, SERIES2); MapPresentationToStackedBarChart(strXValue, y3, distance, SERIES3); MapPresentationToStackedBarChart(strXValue, y4, distance, SERIES4); MapPresentationToStackedBarChart(strXValue, y5, distance, SERIES5); }private void MapPresentationToStackedBarChart(string strXValue, string yValue, int distance, string series) { if (!string.IsNullOrEmpty(yValue)) { var mapping5 = new SeriesMapping(); mapping5.ItemMappings.Add(new ItemMapping() { AggregateFunction = ChartAggregateFunction.None, DataPointMember = DataPointMember.XCategory, FieldName = strXValue }); mapping5.ItemMappings.Add(new ItemMapping(series, DataPointMember.YValue, ChartAggregateFunction.None)); var sbsd5 = new StackedBarSeriesDefinition {LabelSettings = {LabelDisplayMode = LabelDisplayMode.Outside, Distance = distance}}; mapping5.SeriesDefinition = sbsd5; mapping5.LegendLabel = yValue; radChart1.SeriesMappings.Add(mapping5); } }
Thanks.