Ultimate-Xamarin-Forms-KIT
Ultimate-Xamarin-Forms-KIT copied to clipboard
Is there a way to set formatted label axes names on Y axes ?
looking for a way to apply new TextByIndexXAxisFormatter(labels);
on Y axes
Yep, i found that bug, You just re-create new XAxisConfig for change labels Eg: var XAsix = new XAxisConfig(); XAsix.XAXISPosition = XAXISPosition.BOTTOM; XAsix.DrawGridLines = false; XAsix.LabelRotationAngle = 90; XAsix.AxisValueFormatter = new TextByIndexXAxisFormatter(labels); chart.XAxis = XAsix;
Its available from 2.3.3-alpha2 version, i will fix this bug at the next version
Thanks for your answer, but this overrides the current XAxis labels and it does not reach the expected result. This just rotates labels on X axis and write them on the bottom of the chart. The expected result is to write the labels on the YAxis without overriding XAxis labels.
Thanks for your time
@etu31327 can you show how you binded x axis labels.because i am not able to set chart.XAxis = XAsix; from MVVM viewmodel. its working from backend c#.
@eliyasbaby
in the OnAppearing method in the code behind, I call a public method implemented in my view model that will fill a XAxis property also declared in the view model and then I add it in my chart:
protected override void OnAppearing() { base.OnAppearing(); InitializeComponent(); ((MyViewModel)BindingContext).FillXAxis(); myChart.XAxis = ((MyViewModel)BindingContext).XAxis; };
Here is the called method :
public void FormatNightData() { XAxis = ToXAxisLabel(data) }
For example if x labels are hours :
`
private XAxisConfig ToXAxisLabel(DateTime[] dateTimes)
{
XAxisConfig xAxis = new XAxisConfig();
xAxis.DrawGridLines = false;
xAxis.XAXISPosition = 0;
var labels = new List<string>();
foreach (DateTime dateTime in dateTimes)
{
labels.Add(dateTime.ToString("HH:mm"));
}
xAxis.AxisValueFormatter = new TextByIndexXAxisFormatter(labels);
return xAxis;
}`
How to change AxisValueFormatter on button click
How to change AxisValueFormatter on button click
Solved problem by passing list of label to CustomXAxisValueFormatter in place of list of model class.