I am getting a variable number of labels on my x-axis when trying to show a chart. I want a label for each item on the x-axis. I have uploaded a zip file with a picture of the result I'm seeing. Can anyone help me?
My data source is an ObservableCollection<Agent> and I'm trying to plot Agent.FullName (x-axis) by Agent.UnitsSold (y-axis).
public class Agent : INotifyPropertyChanged
{
private string m_lastName;
private string m_firstName;
private int m_unitsSold;
public event PropertyChangedEventHandler PropertyChanged;
public Agent()
{
FirstName = string.Empty;
LastName = string.Empty;
UnitsSold = 0;
}
public string LastName
{
get { return m_lastName; }
set { m_lastName = value; FirePropertyChanged("LastName"); }
}
public string FirstName
{
get { return m_firstName; }
set { m_firstName = value; FirePropertyChanged("FirstName"); }
}
public string FullName
{ get { return FirstName + " " + LastName; } }
public int UnitsSold
{
get { return m_unitsSold; }
set { m_unitsSold = value; FirePropertyChanged("UnitsSold"); }
}
private void FirePropertyChanged(string propertyName)
{
PropertyChangedEventHandler temp = PropertyChanged;
if (temp != null)
temp(this, new PropertyChangedEventArgs(propertyName));
}
}
<syncfusion:Chart Name="Chart1" Margin="0" Background="White">
<syncfusion:Chart.Header>
<TextBlock FontSize="20" TextWrapping="Wrap" FontWeight="Regular">Agents- Units Sold</TextBlock>
</syncfusion:Chart.Header>
<!--Chart area to present chart segments-->
<syncfusion:ChartArea IsContextMenuEnabled="False" ContextMenu="{x:Null}" >
<syncfusion:ChartArea.ColorModel>
<syncfusion:ChartStyleModel Palette="Metro"/>
</syncfusion:ChartArea.ColorModel>
<!--Chart area Legend declaration-->
<syncfusion:ChartArea.Legend>
<syncfusion:ChartLegend Name="Legend1" syncfusion:Chart.Dock="{Binding ElementName=Position1, Path=SelectedItem, Mode=TwoWay}"></syncfusion:ChartLegend>
</syncfusion:ChartArea.Legend>
<syncfusion:ChartArea.PrimaryAxis>
<syncfusion:ChartAxis Header="Agents" RangePadding="Normal" HidePartialLabel="False" LabelRotateAngle="90" EdgeLabelsDrawingMode="Shift"></syncfusion:ChartAxis>
</syncfusion:ChartArea.PrimaryAxis>
<syncfusion:ChartArea.SecondaryAxis>
<syncfusion:ChartAxis Header="Units Sold" EdgeLabelsDrawingMode="Shift"></syncfusion:ChartAxis>
</syncfusion:ChartArea.SecondaryAxis>
<!--Chart series declaration-->
<syncfusion:ChartSeries Name="SeriesA" Type="Column" IsIndexed="True" Unit="Units" DataSource="{Binding Agents}" BindingPathX="FullName" BindingPathsY="UnitsSold" Label="Office" StrokeThickness="0.5" >
</syncfusion:ChartSeries>
</syncfusion:ChartArea>
</syncfusion:Chart>
Attachment:
ChartLabel_Example_1433814a.zip