I am using https://nuget.org/packages/UltimateXF/ charts in my app and I know how to set data from code behind. My problem is I want to know how to bind data from view model.
<StackLayout Orientation="Vertical" Padding="2" VerticalOptions="FillAndExpand" Grid.Row="1">
<Label Text="Target/achievement" FontSize="Default" TextColor="DarkSlateGray"/>
<Label Margin="10,-5,0,0" HorizontalOptions="StartAndExpand" Text="4000/5000" FontSize="18" TextColor="Black"/>
<ultimateChart:SupportHorizontalBarChartExtended HeightRequest="60" x:Name="lineChart" Margin="0,0,0,0" HorizontalOptions="FillAndExpand"/>
</StackLayout>
This is how I bind data from code behind....
var labels = new List<string>();
var lineEntries = new List<EntryChart>();
lineEntries.Add(new EntryChart(0, 500));
lineEntries.Add(new EntryChart(1, 200));
labels.Add("Gene");
labels.Add("Life");
var lineDataSet4 = new BarDataSet(lineEntries, "")
{
Colors = new List<Color>{
Color.LightSalmon
}
};
var lineData4 = new BarChartData(new List<IBarDataSet>() { lineDataSet4 });
lineChart.ChartData = lineData4;
lineChart.DescriptionChart.Text = "";
lineChart.AxisLeft.DrawGridLines = false;
lineChart.AxisLeft.DrawAxisLine = true;
lineChart.AxisLeft.Enabled = true;
lineChart.AxisRight.DrawAxisLine = false;
lineChart.AxisRight.DrawGridLines = false;
lineChart.XAxis.Granularity = 1f;
lineChart.HeightRequest = 10;
lineChart.AxisRight.Enabled = false;
lineChart.XAxis.XAXISPosition = XAXISPosition.BOTTOM;
lineChart.XAxis.DrawGridLines = false;
lineChart.XAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);