While setting properties MinStep and ForceStepToMin, CartesianChart not appearing
vadimffe opened this issue · 1 comments
vadimffe commented
Describe the bug
I am using CartesianChart in this way
XAML part:
<lvc:CartesianChart Series="{Binding MyChartData}"
XAxes="{Binding ChartXAxes }"
YAxes="{Binding ChartYAxes }"
TooltipBackgroundPaint="{Binding TooltipBackgroundPaint}"
TooltipTextPaint="{Binding TooltipTextPaint}"
TooltipTextSize="10">
</lvc:CartesianChart>
ViewModel part:
private void InitializeChartXAxes()
{
this.ChartXAxes = new Axis[]
{
new Axis
{
Labeler = value =>
{
try
{
if (value is double doubleValue)
{
// Convert double to month value (1-12)
int monthValue = (int)doubleValue;
// Validate the month value
if (monthValue >= 1 && monthValue <= 12)
{
// Get month name
DateTime dateTime = new DateTime(1, monthValue, 1);
return dateTime.ToString("MMM"); // Returns abbreviated month name (Jan, Feb, etc.)
}
}
return "N/A";
}
catch (Exception ex)
{
this.Logger.LogWarning($"Exception: {ex}");
return "Error";
}
},
LabelsPaint = new SolidColorPaint(SKColors.White),
// Each unit represents one month
UnitWidth = TimeSpan.FromDays(30).Ticks,
// Minimum step between labels is one month
MinStep = TimeSpan.FromDays(30).Ticks,
ForceStepToMin = true,
},
};
}
Note that some months can have zero values, should be also visible.
After update to 2.0.0-rc3.3 and v2.0.0-rc4 part below makes chart not appearing.
MinStep = TimeSpan.FromDays(30).Ticks,
ForceStepToMin = true,
However in 2.0.0-rc2 everything is working fine with my current setup. So in newest versions if I remove MinStep
and ForceStepToMin
, chart is appearing, but then I am not able to set these values properly. I have not yet investigated all the recent changes in details. Just reporting an issue I am currently facing.
Desktop (please complete the following information):
- OS: Windows 11
- NET MAUI
XamMattia83 commented
Hello, i can confirm...i have the same issue here on MAUI - tested on Android and iOS real devices