i'm new on live charts and maybe this is a stupid mistake but for now i don't understand why my columns are not displayed on my charts. i have tried but seems that the binding not work correktly. But if i use biding with serire collection this work weel and my columns are displayed.
this is my xaml code :
<lvc:CartesianChart x:Name="ChartICT" Grid.Column="1" Margin="1" LegendLocation="Left">
<lvc:CartesianChart.AxisX>
<lvc:AxesCollection>
<lvc:Axis Labels="{Binding Labels}" LabelsRotation="15" MinValue="1" MaxValue="{Binding MaxValue}">
<lvc:Axis.Separator>
<lvc:Separator Step="1" IsEnabled="True"/>
</lvc:Axis.Separator>
</lvc:Axis>
</lvc:AxesCollection>
</lvc:CartesianChart.AxisX>
<lvc:CartesianChart.AxisY>
<lvc:AxesCollection>
<lvc:Axis Title="Sold Apps" MinValue="1" MaxValue="95" LabelFormatter="{Binding Formatter}" ></lvc:Axis>
</lvc:AxesCollection>
</lvc:CartesianChart.AxisY>
<lvc:CartesianChart.Series>
<lvc:ColumnSeries Values="{Binding Valuess}" DataLabels="True" Title="Prova" Fill="LightBlue" StrokeThickness="1" Visibility="Visible"/>
</lvc:CartesianChart.Series>
</lvc:CartesianChart>
```
and this is my c# code:
public event PropertyChangedEventHandler PropertyChanged;
public void NotifyPropertyChanged(string propname)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propname));
}
}
private string _TitleX;
public string TitleX
{
get => _TitleX;
set
{
_TitleX = value;
NotifyPropertyChanged(nameof(TitleX));
}
}
private int _Step;
public int Step
{
get => _Step;
set
{
_Step = value;
NotifyPropertyChanged(nameof(Step));
}
}
public string[] _Labels;
public string[] Labels
{
get => _Labels;
set
{
_Labels = value;
NotifyPropertyChanged(nameof(Labels));
}
}
public int _MaxValue;
public int MaxValue
{
get => _MaxValue;
set
{
_MaxValue = value;
NotifyPropertyChanged(nameof(MaxValue));
}
}
public LiveCharts.ChartValues<int>[] _Valuess;
public LiveCharts.ChartValues<int>[] Valuess
{
get => _Valuess;
set
{
_Valuess = value;
NotifyPropertyChanged(nameof(Valuess));
}
}
public Func<double, string> Formatter { get; set; }
public SeriesCollection SeriesCollection { get; set; }
List<ChartValues<int>> seriesList = new List<ChartValues<int>>();
public void AddingLabelsX()
{
foreach (LoaData.Product product in products_list)
{
LoaData.Product product1 = new LoaData.Product();
product1.Descrizione = product.Descrizione;
bool alreadyExist = productsDesc_list.Any(v => v == product1.Descrizione);
if (!alreadyExist)
{
productsDesc_list.Add(product1.Descrizione.ToString());
}
}
> `Labels = productsDesc_list.ToArray(); //Labels asseX
> MaxValue = Labels.Length;//Assex
> seriesList.Add(new ChartValues<int> {5,20,50,32,11});
> Valuess = seriesList.ToArray(); `
}`
now what i can do ? thank you everyone.