Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While setting properties MinStep and ForceStepToMin, CartesianChart not appearing #1691

Open
vadimffe opened this issue Nov 4, 2024 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@vadimffe
Copy link
Contributor

vadimffe commented Nov 4, 2024

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
Copy link

Hello, i can confirm...i have the same issue here on MAUI - tested on Android and iOS real devices

@beto-rodriguez
Copy link
Owner

I think the issue is caused by the TooltipTextSize property, there is a bug related with #1694 that also affects Tooltips, this should be already fixed in the next version.

@beto-rodriguez beto-rodriguez added the bug Something isn't working label Dec 27, 2024
@beto-rodriguez beto-rodriguez added this to the rc-5 milestone Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants