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

UIBarChart Bug #84

Open
AngeloCresta opened this issue May 9, 2024 · 0 comments
Open

UIBarChart Bug #84

AngeloCresta opened this issue May 9, 2024 · 0 comments

Comments

@AngeloCresta
Copy link

Hi, the series have wrong colors:
SunnyUI-BarChartError

I've modified the DrawSeries in (UIBarChart.cs) method as follow:

        protected virtual void DrawSeries(Graphics g, List<UIBarSeries> series)
        {
            if (series == null || series.Count == 0) return;
            using var TempFont = Font.DPIScaleFont(UIStyles.DefaultSubFontSize);
            for (int i = 0; i < Bars.Count; i++)
            {
                var bars = Bars[i];
                foreach (var info in bars)
                {
                    Color color = ChartStyle.GetColor(i);

                    g.FillRectangle(color, info.Rect);

                    if (Option.ShowValue)
                    {
                        string value = info.Value.ToString("F" + info.Series.DecimalPlaces);
                        if (info.Top)
                        {
                            g.DrawString(value, TempFont, color, new Rectangle((int)info.Rect.Center().X - Width, (int)info.Rect.Top - Height, Width * 2, Height), ContentAlignment.BottomCenter);
                        }
                        else
                        {
                            g.DrawString(value, TempFont, color, new Rectangle((int)info.Rect.Center().X - Width, (int)info.Rect.Bottom, Width * 2, Height), ContentAlignment.TopCenter);
                        }
                    }
                }
            }

            for (int i = 0; i < Option.XAxis.Data.Count; i++)
            {
                Bars[0][i].Size = TextRenderer.MeasureText(Bars[0][i].Tips, TempFont);
            }
        }

having the expected result:
SunnyUI-BarChartFixed

Regards,
Angelo

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