Пример #1
0
        private void DrawSecondBarSeries(Graphics graphics, DoubleAxisBarSeries series)
        {
            var spaceY = _categoryHeight;
            var y      = Padding.Top + ((spaceY - BarSize) / 2);

            using (var stringFormat = new StringFormat())
                using (var font = BarValueFont.ToFatFont())
                {
                    stringFormat.LineAlignment = StringAlignment.Center;
                    //stringFormat.Alignment = StringAlignment.Far;

                    for (int i = 0; i < series.Data.Length; i++)
                    {
                        var value = series.Data[i];

                        stringFormat.Alignment = value <= 2 ? StringAlignment.Far : StringAlignment.Near;
                        var color = series.Colors == null ? series.Color : series.Colors[i];
                        using (var brush = new SolidBrush(color))
                        {
                            var length = _widthUnit * value;
                            var x      = Size.Width - Padding.Right - length;
                            graphics.FillRectangle(brush, x, y, length, BarSize);

                            x -= 2;
                            Brush textBrush = value <= 2 ? Brushes.DarkBlue : Brushes.White;

                            graphics.DrawString(string.Format(FormatBarValue, value), font, textBrush, x + 2, y + (BarSize / 2), stringFormat);
                            y += spaceY;
                        }
                    }
                }
        }
Пример #2
0
        private void DrawFirstBarSeries(Graphics graphics, DoubleAxisBarSeries series)
        {
            var spaceY = _categoryHeight;
            var y      = MarginTop + ((spaceY - BarSize) / 2);

            using (var stringFormat = new StringFormat())
            {
                stringFormat.LineAlignment = StringAlignment.Center;
                stringFormat.Alignment     = StringAlignment.Far;
                for (int i = 0; i < series.Data.Length; i++)
                {
                    var value = series.Data[i];
                    var color = series.Colors == null ? series.Color : series.Colors[i];
                    using (var brush = new SolidBrush(color))
                    {
                        var length = _widthUnit * value;
                        graphics.FillRectangle(brush, MarginLeft, y, length, BarSize);
                        graphics.DrawString(string.Format(FormatBarValue, value), BarValueFont, Brushes.White, MarginLeft + length - 2, y + (BarSize / 2), stringFormat);
                        y += spaceY;
                    }
                }
            }
        }