I am struggling to get a BarSeries chart to work in Vertical mode with the Y axis being from a bound string field. If I flip to horizontal it seems to work OK.
In horizontal mode this works;
<charts:XYChart VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="30,10" >
<charts:XYChart.YAxes>
<charts:XYDoubleAxis Minimum="0" Maximum="100"/>
</charts:XYChart.YAxes>
<charts:XYChart.XAxes >
<charts:XYGroupedAxis FontSize="8" />
</charts:XYChart.XAxes>
<charts:BarSeries x:Name="Data" XPath="Category" YPath="Percentage" ItemsSource="{Binding AllSafeCategories, Mode=OneWay}">
</charts:BarSeries>
</charts:XYChart>
But vertical mode does not work, no Y axis labels and no bars are shown;
<charts:XYChart VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="30,10" >
<charts:XYChart.XAxes>
<charts:XYDoubleAxis Minimum="0" Maximum="100"/>
</charts:XYChart.XAxes>
<charts:XYChart.YAxes >
<charts:XYGroupedAxis FontSize="8" />
</charts:XYChart.YAxes>
<charts:BarSeries x:Name="Data" YPath="Category" Orientation="Vertical" XPath="Percentage" ItemsSource="{Binding AllSafeCategories, Mode=OneWay}">
</charts:BarSeries>
</charts:XYChart>
The backing ViewModel has the following class, collection and initialisation data;
public class CategoryBarData
{
public string Category { get; private set; }
public double Percentage { get; private set; }
public CategoryBarData(string category, double percentage)
{
Category = category;
Percentage = percentage;
}
}
public ObservableCollection<CategoryBarData> AllSafeCategories { get; set; }
AllSafeCategories = new ObservableCollection<CategoryBarData>
{
new CategoryBarData("Category 1", 98),
new CategoryBarData("Category 2", 92),
new CategoryBarData("Category 3", 89.3),
new CategoryBarData("Category 4", 75.3),
new CategoryBarData("Category 5", 42.1)
};