protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); _categoryHeight = chartContainer.Size.Height / Categories.Length; _widthUnit = chartContainer.Size.Width / 100; }
public void Render(GdiContainer component) { using (var graphics = GetGraphics()) { RenderComponent(graphics, component); } }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); const int NumberOfColumns = 4; _categoryHeight = chartContainer.Size.Height / Categories.Length; _maxValue = DataSet.SelectMany(x => x.Data).Max(x => x) * 1.1f; _minValue = DataSet.SelectMany(x => x.Data).Min(x => x) * 1.1f; if (StepSize == 0) { var range = _maxValue - _minValue; if (range < NumberOfColumns) { StepSize = 1; } else { StepSize = (int)(range / NumberOfColumns); } } if (_minValue > 0) { _minValue = 0; } _widthUnit = chartContainer.Size.Width / (Math.Abs(_minValue) + _maxValue); _rootX = Padding.Left + (_widthUnit * Math.Abs(_minValue)); }
protected override void BuildComponents(GdiContainer mainContainer, GdiRectangle chartContainer) { base.BuildComponents(mainContainer, chartContainer); AddChartArea(chartContainer); AddVerLabelAxis(mainContainer, chartContainer); AddHozLabelAxis(mainContainer, chartContainer); }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); if (StepSize <= 0) { throw new ArgumentException("Invalid StepSize"); } if (StepSize <= 0 || Categories.Length < 3) { throw new ArgumentException("Invalid data"); } _maxRadius = Math.Min(chartContainer.Size.Width, chartContainer.Size.Height) / 2; _centerPoint = new PointF(Padding.Left + _maxRadius, Padding.Top + _maxRadius); var maxDataValue = MaxDataValue > 0 ? MaxDataValue : DataSets.SelectMany(x => x.Data).Max(); maxDataValue = (int)Math.Ceiling((double)maxDataValue / StepSize) * StepSize; // round it _numberOfSteps = (int)Math.Ceiling(maxDataValue / StepSize) + 1; // remove this variable _stepSizeInPixel = _maxRadius / _numberOfSteps; _unitPixel = _maxRadius / (maxDataValue + StepSize); }
protected override void BuildComponents(GdiContainer mainContainer, GdiRectangle chartContainer) { base.BuildComponents(mainContainer, chartContainer); var rangeBar = AddRangeBar(chartContainer); AddRangeBarColumns(chartContainer, rangeBar); AddRangeBarLabels(chartContainer, rangeBar); }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); this.MainContainer.BackgroundColor = Color.Transparent; _chartRect = CalculateChartRect(); this.LegendWidth = _chartRect.Width; this.LegendHeight = this.Size.Height - this.Padding.Top - _chartRect.Height / 2 - 50; }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); _categoryWidth = chartContainer.Size.Width / Categories.Length; _heightUnit = chartContainer.Size.Height / 100; this.LegendHeight = Padding.Bottom - 50; }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); _categoryHeight = chartContainer.Size.Height / Categories.Length; _maxValue = FindMaxValueFromBothDataSets() * 1.1f; _widthUnit = chartContainer.Size.Width / _maxValue; }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); if (Entries == null || Entries.Length == 0) { throw new ArgumentException("Invalid entries data"); } }
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 }); }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); if (MaxValue <= 0 || MaxValue <= MinValue) { throw new ArgumentException("Invalid range value!"); } if (Entries == null || !Entries.Any()) { throw new ArgumentException("Invalid entries!"); } }
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 }); }
protected override void BuildComponents(GdiContainer mainContainer, GdiRectangle chartContainer) { base.BuildComponents(mainContainer, chartContainer); var pie = new GdiPie { Diameter = chartContainer.Size.Height, Entries = Entries, IsDonut = IsDonut, HorizontalAlignment = GdiMapper.ToGdiHorizontalAlign(this.PieAlign), TextColor = TextColor, LabelFormat = LabelFormat, Font = Font }; chartContainer.AddChild(pie); }
protected override void BuildComponents(GdiContainer mainContainer, GdiRectangle chartContainer) { base.BuildComponents(mainContainer, chartContainer); var table = new GdiDataGrid { Size = chartContainer.Size, LineColor = Color.Gray, Rows = Rows, Columns = Columns, MergedCells = MergedCells, Texts = Texts, TextColor = TextColor }; chartContainer.AddChild(table); }
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 }); }
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 }); }
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 }); } }
protected override void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { base.Init(mainContainer, chartContainer); CategoryWidth = chartContainer.Size.Width / Categories.Length; _maxValue = DataSets.SelectMany(x => x.Data).Max(x => x) * (IsOneHundredPercentChart ? 1f : 1.1f); _minValue = DataSets.SelectMany(x => x.Data).Min(x => x) * (IsOneHundredPercentChart ? 1f : 1.1f); if (_minValue > 0) { _minValue = 0; } var maxLength = (Math.Abs(_minValue) + _maxValue); _heightUnit = maxLength == 0 ? 1 : chartContainer.Size.Height / maxLength; _rootY = Padding.Top + (_heightUnit * Math.Abs(_maxValue)); }
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); }
protected virtual void Init(GdiContainer mainContainer, GdiRectangle chartContainer) { }