/// <inheritdoc/> public virtual CartesianBounds GetBounds( CartesianChartCore <TDrawingContext> chart, IAxis <TDrawingContext> x, IAxis <TDrawingContext> y) { var seriesLength = 0; var stack = chart.SeriesContext.GetStackPosition(this, GetStackGroup()); var bounds = new CartesianBounds(); foreach (var point in Fetch(chart)) { var secondary = point.SecondaryValue; var primary = point.PrimaryValue; if (stack != null) { primary = stack.StackPoint(point); } var abx = bounds.SecondaryBounds.AppendValue(secondary); var aby = bounds.PrimaryBounds.AppendValue(primary); seriesLength++; } return(bounds); }
public override CartesianBounds GetBounds( CartesianChartCore <TDrawingContext> chart, IAxis <TDrawingContext> x, IAxis <TDrawingContext> y) { var baseBounds = base.GetBounds(chart, x, y); var tick = y.GetTick(chart.ControlSize, baseBounds.PrimaryBounds); return(new CartesianBounds { SecondaryBounds = new Bounds { Max = baseBounds.SecondaryBounds.Max + 0.5, Min = baseBounds.SecondaryBounds.Min - 0.5 }, PrimaryBounds = new Bounds { Max = baseBounds.PrimaryBounds.Max + tick.Value, min = baseBounds.PrimaryBounds.min - tick.Value } }); }
/// <inheritdoc/> public abstract void Measure( CartesianChartCore <TDrawingContext> chart, IAxis <TDrawingContext> x, IAxis <TDrawingContext> y);
public override void Measure( CartesianChartCore <TDrawingContext> chart, IAxis <TDrawingContext> xAxis, IAxis <TDrawingContext> yAxis) { var drawLocation = chart.DrawMaringLocation; var drawMarginSize = chart.DrawMarginSize; var xScale = new ScaleContext(drawLocation, drawMarginSize, xAxis.Orientation, xAxis.DataBounds); var yScale = new ScaleContext(drawLocation, drawMarginSize, yAxis.Orientation, yAxis.DataBounds); float uw = xScale.ScaleToUi(1f) - xScale.ScaleToUi(0f); float uwm = 0.5f * uw; float sw = Stroke?.StrokeWidth ?? 0; float p = yScale.ScaleToUi(unchecked ((float)Pivot)); var pos = chart.SeriesContext.GetColumnPostion(this); var count = chart.SeriesContext.GetColumnSeriesCount(); float cp = 0f; if (!IgnoresColumnPosition && count > 1) { uw = uw / count; uwm = 0.5f * uw; cp = (pos - (count / 2f)) * uw + uwm; } if (uw > MaxColumnWidth) { uw = unchecked ((float)MaxColumnWidth); uwm = uw / 2f; } if (Fill != null) { chart.Canvas.AddPaintTask(Fill); } if (Stroke != null) { chart.Canvas.AddPaintTask(Stroke); } var chartAnimation = new Animation(chart.EasingFunction, chart.AnimationsSpeed); var ts = TransitionsSetter ?? SetDefaultTransitions; foreach (var point in Fetch(chart)) { var x = xScale.ScaleToUi(point.SecondaryValue); var y = yScale.ScaleToUi(point.PrimaryValue); float b = Math.Abs(y - p); if (point.PointContext.Visual == null) { var r = new TVisual { X = x - uwm + cp, Y = p, Width = uw, Height = 0 }; ts(r, chartAnimation); point.PointContext.Visual = r; if (Fill != null) { Fill.AddGeometyToPaintTask(r); } if (Stroke != null) { Stroke.AddGeometyToPaintTask(r); } } var sizedGeometry = point.PointContext.Visual; var cy = point.PrimaryValue > Pivot ? y : y - b; sizedGeometry.X = x - uwm + cp; sizedGeometry.Y = cy; sizedGeometry.Width = uw; sizedGeometry.Height = b; point.PointContext.HoverArea.SetDimensions(x - uwm + cp, cy, uw, b); OnPointMeasured(point, sizedGeometry); chart.MeasuredDrawables.Add(sizedGeometry); } if (HighlightFill != null) { chart.Canvas.AddPaintTask(HighlightFill); } if (HighlightStroke != null) { chart.Canvas.AddPaintTask(HighlightStroke); } }