protected override void BuildComponents(GdiContainer mainContainer, GdiRectangle chartContainer) { base.BuildComponents(mainContainer, chartContainer); // Add left, right captions const int RectWidth = 200; var rectTop = Padding.Top + _chartRect.Height / 2 + 10; if (!string.IsNullOrWhiteSpace(LeftCaption)) { var rect = new GdiRectangle { Margin = new PointF(_chartRect.Left - RectWidth / 2, rectTop), Size = new SizeF(RectWidth, 30) }; mainContainer.AddChild(rect); rect.AddChild(new GdiText { Font = SlimFont.Default, Content = LeftCaption, HorizontalAlignment = GdiSharp.Enum.GdiHorizontalAlign.Center, VerticalAlignment = GdiSharp.Enum.GdiVerticalAlign.Middle, TextAlign = StringAlignment.Center }); } if (!string.IsNullOrWhiteSpace(RightCaption)) { var rect = new GdiRectangle { Margin = new PointF(Padding.Left + _chartRect.Width - RectWidth / 2, rectTop), Size = new SizeF(RectWidth, 30) }; mainContainer.AddChild(rect); rect.AddChild(new GdiText { Font = SlimFont.Default, Content = RightCaption, HorizontalAlignment = GdiSharp.Enum.GdiHorizontalAlign.Center, VerticalAlignment = GdiSharp.Enum.GdiVerticalAlign.Middle, TextAlign = StringAlignment.Center }); } }
private void AddVerLabelAxis(GdiContainer mainContainer, GdiRectangle chartContainer) { mainContainer.AddChild(new GdiVerLabelAxis { Margin = new PointF(0, Padding.Top), Size = new SizeF(Padding.Left, chartContainer.Size.Height), Labels = Categories, LabelHeight = _categoryHeight, LabelOffsetX = Padding.Left - 10, Font = Font }); }
private void AddHozLabelAxis(GdiContainer mainContainer, GdiRectangle chartContainer) { mainContainer.AddChild(new GdiHozLabelAxis { Size = new SizeF(chartContainer.Size.Width, Padding.Bottom), Margin = new PointF(Padding.Left, this.Size.Height - Padding.Bottom), LeftToRightLabels = Categories, LabelWidth = _categoryWidth, LabelOffsetX = _categoryWidth / 2, LabelOffsetY = 10, Font = Font }); }
private void AddHozLabelAxis(GdiContainer mainContainer, GdiRectangle chartContainer) { var leftToRightLabels = Enumerable.Range(0, 100 / StepSize + 1) .Select(x => string.Format(FormatAxisValue, x * StepSize)).ToArray(); mainContainer.AddChild(new GdiHozLabelAxis { Size = new SizeF(chartContainer.Size.Width, Padding.Bottom), Margin = new PointF(Padding.Left, this.Size.Height - Padding.Bottom), RootX = 0, LeftToRightLabels = leftToRightLabels, LabelWidth = _widthUnit * StepSize, Font = Font }); }
private void AddVerLabelAxis(GdiContainer mainContainer, GdiRectangle chartContainer) { var labels = Enumerable.Range(0, 100 / StepSize + 1) .Select(x => string.Format(FormatAxisValue, x * StepSize)).Reverse().ToArray(); var labelHeight = _heightUnit * StepSize; mainContainer.AddChild(new GdiVerLabelAxis { Margin = new PointF(0, Padding.Top), Size = new SizeF(Padding.Left, chartContainer.Size.Height), Labels = labels, LabelHeight = labelHeight, LabelOffsetX = Padding.Left - 10, LabelOffetY = -labelHeight / 2, Font = Font }); }
private void AddHozLabelAxis(GdiContainer mainContainer, GdiRectangle chartContainer) { var leftToRightLabels = Enumerable.Range(0, (int)Math.Ceiling(_maxValue / StepSize)) .Select(x => string.Format(FormatAxisValue, x * StepSize)).ToArray(); var rightToLeftLabels = Enumerable.Range(0, (int)Math.Ceiling(Math.Abs(_minValue) / StepSize)) .Select(x => string.Format(FormatAxisValue, -x * StepSize)).ToArray(); mainContainer.AddChild(new GdiHozLabelAxis { Size = new SizeF(chartContainer.Size.Width, Padding.Bottom), Margin = new PointF(Padding.Left, this.Size.Height - Padding.Bottom), RootX = _rootX - Padding.Left, LeftToRightLabels = leftToRightLabels, RightToLeftLabels = rightToLeftLabels, LabelWidth = _widthUnit * StepSize, Font = Font }); }
protected virtual void AddSubTitle(GdiContainer mainContainer) { if (SubTitle == null || string.IsNullOrWhiteSpace(SubTitle.Text)) { return; } var gdiText = new GdiText { Content = SubTitle.Text, TextColor = SubTitle.Color, HorizontalAlignment = GdiSharp.Enum.GdiHorizontalAlign.Center, VerticalAlignment = GdiSharp.Enum.GdiVerticalAlign.Bottom, Margin = new PointF(0, 10), Font = new SlimFont(SubTitle.FontName, SubTitle.FontSize, FontStyle.Bold) }; mainContainer.AddChild(gdiText); }
protected virtual void BuildComponents(GdiContainer mainContainer, GdiRectangle chartContainer) { if (Legend != null && Legend.Items == null) { CreateLegendItems(); } if (Legend != null && Legend.Items != null && Legend.Items.Any()) { mainContainer.AddChild(new GdiLegend { Margin = new PointF(this.Padding.Left, 10), VerticalAlignment = GdiSharp.Enum.GdiVerticalAlign.Bottom, Size = new SizeF( LegendWidth == 0 ? chartContainer.Size.Width : LegendWidth, LegendHeight == 0 ? Math.Max(GdiLegendItem.LineHeight, this.Padding.Bottom - 50) : LegendHeight), Legend = Legend }); } AddTitle(mainContainer); AddSubTitle(mainContainer); }