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

Chart not rendered if i set "LegendTextSize" with Library ver. >= 2.0.0-rc3 (MAUI) #1694

Open
XamMattia83 opened this issue Nov 6, 2024 · 0 comments

Comments

@XamMattia83
Copy link

Describe the bug
Hello!

I have a CartesianChart (with Column Series) with a "customized" legend. If i set any value on "LegendTextSize" the chart will not appear so, for now, i need to remove it.

Everything was working till ver. 2.0.0-rc2 included.

Here my XAML:

                    <lvc:CartesianChart
                        Grid.Row="1"
                        AnimationsSpeed="00:00:00.100"
                        HeightRequest="270"
                        LegendBackgroundPaint="{Binding LegendBackground}"
                        LegendPosition="Bottom"
                        LegendTextPaint="{Binding LegendTextPaint}"
                        LegendTextSize="8"
                        Series="{Binding Series}"
                        XAxes="{Binding XAxes}"
                        YAxes="{Binding YAxes}" />

View Model:

    public ObservableCollection<ISeries> Series { get; set; }                       
    public Axis[] XAxes { get; set; }                                           
    public Axis[] YAxes { get; set; }
    public SolidColorPaint LegendTextPaint { get; set; } = new SolidColorPaint
    {
        Color = SKColors.LightGray,
    };

    public SolidColorPaint LegendBackground { get; set; } = new SolidColorPaint
    {
        Color = SKColors.Transparent,
    };

    private ObservableValue BarAhScarica = new(0);
    private ObservableValue BarAhAutoScarica = new(0);
    private ObservableValue BarAhCarica = new(0);
    private ObservableValue BarAhReflow = new(0);

//
..more code here
//

//Inside the View model Constructor:

        Series =
        [
            new ColumnSeries<ObservableValue>
            {
                Name = AppResources.Scarica,
                Values = new ObservableCollection<ObservableValue> {BarAhScarica},
                DataLabelsPaint = new SolidColorPaint(SKColors.Red),
                DataLabelsSize = 10,                                                                            
                DataLabelsFormatter = (point) => point.Coordinate.PrimaryValue.ToString("F1")+ " Ah",          
                Fill = new SolidColorPaint(SKColors.Red),
                MaxBarWidth = 100,
                Padding = 10,
                DataLabelsPadding = new Padding(5,5),
                ClippingMode = ClipMode.None,
            },

            new ColumnSeries<ObservableValue>
            {
                Name = AppResources.AutoDisch,
                Values = new ObservableCollection<ObservableValue> {BarAhAutoScarica},
                DataLabelsPaint = new SolidColorPaint(SKColors.Orange),
                DataLabelsSize = 10,
                DataLabelsFormatter = (point) => point.Coordinate.PrimaryValue.ToString("F1") + " Ah",
                Fill = new SolidColorPaint(SKColors.Orange),
                MaxBarWidth = 100,
                Padding = 10,
                DataLabelsPadding = new Padding(5,5),
                ClippingMode = ClipMode.None,
            },

            new ColumnSeries<ObservableValue>
            {
                Name = AppResources.Carica,
                Values = new ObservableCollection<ObservableValue> {BarAhCarica},
                DataLabelsPaint = new SolidColorPaint(SKColors.LightGreen),
                DataLabelsSize = 10,
                DataLabelsFormatter = (point) => point.Coordinate.PrimaryValue.ToString("F1")+ " Ah",
                Fill = new SolidColorPaint(SKColors.LightGreen),
                MaxBarWidth = 100,
                Padding = 10,
                DataLabelsPadding = new Padding(5,5),
                ClippingMode = ClipMode.None,
            },

            new ColumnSeries<ObservableValue>
            {
                Name = AppResources.Reflow,
                Values = new ObservableCollection<ObservableValue> {BarAhReflow},
                DataLabelsPaint = new SolidColorPaint(SKColors.DodgerBlue),
                DataLabelsSize = 10,
                DataLabelsFormatter = (point) => point.Coordinate.PrimaryValue.ToString("F1") + " Ah",
                Fill = new SolidColorPaint(SKColors.DodgerBlue),
                MaxBarWidth = 100,
                Padding = 10,
                DataLabelsPadding = new Padding(5,5),
                ClippingMode = ClipMode.None,
            },
        ];

        XAxes =
        [
            new Axis
            {
                Labels = ["","","",""],
            }
        ];

        YAxes =
        [
            new Axis
            {
                Labels = [""]
            }
        ];

Smartphone (please complete the following information):

  • Device: Emulator or real device (Android, not tested yet on iPhone)
  • OS: Android 14

Current Lib tested: 2.0.0-rc4.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant