beto-rodriguez / LiveCharts2

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
https://livecharts.dev
MIT License
4.39k stars 574 forks source link

Inhalt von DataLabel wird beim aktualisieren vom Hintergrund überdeckt #1446

Closed TimDokter closed 1 month ago

TimDokter commented 9 months ago

Ich lasse mir in einem DataLabel einen Wert anzeigen, dieser wird beim aktualisieren aber manchmal zufäälig von der Hintergrundfarbe überdeckt. Hoffentlich kann mir wer weiterhelfen. Her mein Code und die Bilder

diagrammCorrect- diagrammIncorrect

            // Erstellen der Positionen-Säule Top100
            List<int> positionen = reportData.Select(bahnhof => bahnhof.Positionen).ToList();
            ColumnSeries<int> positionenSeries = new ColumnSeries<int>
            {
                Name = "Positionen",
                Values = positionen,
                Fill = new SolidColorPaint(new SKColor(54, 52, 54)) ,
                Stroke = new SolidColorPaint(SKColors.Black) ,
                Padding = -40,
                DataLabelsSize = 50 ,                 
                DataLabelsPosition = DataLabelsPosition.End,
                DataLabelsFormatter = point => point.Coordinate.PrimaryValue.ToString(),
                DataLabelsPaint = new SolidColorPaint(SKColors.Black),
            };

            //Höchsten Wert aus Positionensäule Top 100 ermitteln
            MaxWertTop100 = positionen.Max();

            // Erstellen der Behälter-Säule Top 100
            List<int> behaelter = reportData.Select(bahnhof => bahnhof.Behaelter).ToList();
            LineSeries<int> behaelterSeries = new LineSeries<int>
            {
                Name = "Behälter",
                Values = behaelter,
                Fill = new SolidColorPaint(SKColors.Transparent),
                Stroke = new SolidColorPaint(SKColors.Black),
                GeometrySize = 65,
                DataLabelsSize = 50,
                IsHoverable = true,
                DataLabelsPosition = DataLabelsPosition.Middle,
                DataLabelsFormatter = point => point.Coordinate.PrimaryValue.ToString(),
                DataLabelsPaint = new SolidColorPaint(SKColors.Black),
            };

            behaelterSeries.OnPointMeasured(point =>
            {
                SolidColorPaint paint = null;
                if (gesamtanzahlBehaelter >= GelbRotValue)
                {
                    paint = new SolidColorPaint(SKColors.Red) { StrokeThickness = 10 };
                    point.Visual.Stroke = paint;
                    point.Visual.Fill = new SolidColorPaint(SKColors.White) { ZIndex = 0 };
                    point.Label.Fill = new SolidColorPaint(SKColors.Black) { ZIndex = 20 };
                }
                else if (gesamtanzahlBehaelter >= GrünGelbValue)
                {
                    paint = new SolidColorPaint(SKColors.Yellow) { StrokeThickness = 10 };
                    point.Visual.Stroke = paint;
                    point.Visual.Fill = new SolidColorPaint(SKColors.White) { ZIndex = 0 };
                    point.Label.Fill = new SolidColorPaint(SKColors.Black) { ZIndex = 20 };
                }
                else if (gesamtanzahlBehaelter <= GelbGrünValue)
                {
                    paint = new SolidColorPaint(SKColors.Green) { StrokeThickness = 10 };
                    point.Visual.Stroke = paint;
                    point.Visual.Fill = new SolidColorPaint(SKColors.White) { ZIndex = 0 };
                    point.Label.Fill = new SolidColorPaint(SKColors.Black) { ZIndex = 20 };
                }
                else if (gesamtanzahlBehaelter <= RotGelbValue)
                {
                    paint = new SolidColorPaint(SKColors.Yellow) { StrokeThickness = 10 };
                    point.Visual.Stroke = paint;
                    point.Visual.Fill = new SolidColorPaint(SKColors.White) { ZIndex = 0 };
                    point.Label.Fill = new SolidColorPaint(SKColors.Black) { ZIndex = 20 };
                }
            });
beto-rodriguez commented 2 months ago

English translation (AI):

I have a value displayed in a DataLabel, but it is sometimes accidentally covered by the background color when it is updated. Hopefully someone can help me. Give me my code and the pictures

I am afraid I don't understand the issue,

Where should labels be placed?