I have a Bar series to show number of parts produced at the same time i would like to show percentage of yield produced by that line.
here is what i tried
var labelDefinition=new ChartSeriesLabelDefinition();
labelDefinition.VerticalAlignment=VerticalAlignment.Bottom;
labelDefinition.Template = App.Current.Resources["LabelTemplateString"] as DataTemplate;
BarSeries okSeries = new BarSeries();
okSeries.ItemsSource = this.yields;
okSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "LocationName" };
okSeries.ValueBinding = new GenericDataPointBinding<Yield, int>() { ValueSelector = yield => yield.OK };
okSeries.CombineMode = ChartSeriesCombineMode.Stack;
okSeries.DefaultVisualStyle = App.Current.Resources["YieldOK"] as Style;
okSeries.LabelDefinitions.Add(labelDefinition);
okSeries.ShowLabels = true;
BarSeries nokSeries = new BarSeries();
nokSeries.ItemsSource = this.yields;
nokSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "LocationName" };
nokSeries.ValueBinding = new GenericDataPointBinding<Yield, int>() { ValueSelector = yield => yield.NOK };
nokSeries.CombineMode = ChartSeriesCombineMode.Stack;
nokSeries.DefaultVisualStyle = App.Current.Resources["YieldNOK"] as Style;
PointSeries percentSeries = new PointSeries();
percentSeries.ItemsSource = this.yields;
percentSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "LocationName" };
percentSeries.ValueBinding = new PropertyNameDataPointBinding("Percent");
percentSeries.PointTemplate = App.Current.Resources["PointTemplateBlue"] as DataTemplate;
//percentSeries.LabelDefinitions.Add(labelDefinition);
percentSeries.ShowLabels = true;
<DataTemplate x:Key="LabelTemplateString">
<TextBlock Text="{Binding Path=DataItem.Percent }" FontSize="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=local:YieldChart}, Path=PercentSize}"/>
</DataTemplate>
here is what i tried
var labelDefinition=new ChartSeriesLabelDefinition();
labelDefinition.VerticalAlignment=VerticalAlignment.Bottom;
labelDefinition.Template = App.Current.Resources["LabelTemplateString"] as DataTemplate;
BarSeries okSeries = new BarSeries();
okSeries.ItemsSource = this.yields;
okSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "LocationName" };
okSeries.ValueBinding = new GenericDataPointBinding<Yield, int>() { ValueSelector = yield => yield.OK };
okSeries.CombineMode = ChartSeriesCombineMode.Stack;
okSeries.DefaultVisualStyle = App.Current.Resources["YieldOK"] as Style;
okSeries.LabelDefinitions.Add(labelDefinition);
okSeries.ShowLabels = true;
BarSeries nokSeries = new BarSeries();
nokSeries.ItemsSource = this.yields;
nokSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "LocationName" };
nokSeries.ValueBinding = new GenericDataPointBinding<Yield, int>() { ValueSelector = yield => yield.NOK };
nokSeries.CombineMode = ChartSeriesCombineMode.Stack;
nokSeries.DefaultVisualStyle = App.Current.Resources["YieldNOK"] as Style;
PointSeries percentSeries = new PointSeries();
percentSeries.ItemsSource = this.yields;
percentSeries.CategoryBinding = new PropertyNameDataPointBinding() { PropertyName = "LocationName" };
percentSeries.ValueBinding = new PropertyNameDataPointBinding("Percent");
percentSeries.PointTemplate = App.Current.Resources["PointTemplateBlue"] as DataTemplate;
//percentSeries.LabelDefinitions.Add(labelDefinition);
percentSeries.ShowLabels = true;
<DataTemplate x:Key="LabelTemplateString">
<TextBlock Text="{Binding Path=DataItem.Percent }" FontSize="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=local:YieldChart}, Path=PercentSize}"/>
</DataTemplate>