public override void CalculateOffsets() { if (!customViewPortEnabled) { CalculateLegendOffsets(offset); var offsetLeft = offset.Left; var offsetTop = offset.Top; var offsetRight = offset.Right; var offsetBottom = offset.Bottom; // offsets for y-labels if (AxisLeft.NeedsOffset) { offsetLeft += AxisLeft.GetRequiredWidthSpace(axisRendererLeft .AxisLabelPaint); } if (AxisRight.NeedsOffset) { offsetRight += AxisRight.GetRequiredWidthSpace(axisRendererRight.AxisLabelPaint); } if (XAxis.IsEnabled && XAxis.IsDrawLabelsEnabled) { float xLabelHeight = XAxis.LabelRotatedHeight + XAxis.YOffset; // offsets for x-labels if (XAxis.Position == XAxis.XAxisPosition.Bottom) { offsetBottom += xLabelHeight; } else if (XAxis.Position == XAxis.XAxisPosition.Top) { offsetTop += xLabelHeight; } else if (XAxis.Position == XAxis.XAxisPosition.BottomInside) { offsetBottom += xLabelHeight; offsetTop += xLabelHeight; } } offsetTop += ExtraTopOffset; offsetRight += ExtraRightOffset; offsetBottom += ExtraBottomOffset; offsetLeft += ExtraLeftOffset; float minOffset = MinOffset.DpToPixel(); ViewPortHandler.RestrainViewPort( Math.Max(minOffset, offsetLeft), Math.Max(minOffset, offsetTop), Math.Max(minOffset, offsetRight), Math.Max(minOffset, offsetBottom)); } PrepareOffsetMatrix(); PrepareValuePxMatrix(); }
private void MultipleAxes1_Load(object sender, EventArgs e) { double[] xs = Generate.Consecutive(51); double[] ys1 = Generate.Sin(51, mult: 1e3); double[] ys2 = Generate.Cos(51, mult: 1e-3); // customize styling of the default axes interactivePlot1.Plot.AxisLeft.Label = "Primary Y Axis"; interactivePlot1.Plot.AxisLeft.Color = Colors.Red; interactivePlot1.Plot.AxisBottom.Label = "Primary X Axis"; interactivePlot1.Plot.AxisTop.Label = "Multiple Y Axis Demo"; // appears as title // create scatter plots and give them to different Y axis indexes var scatter1 = interactivePlot1.Plot.PlotScatter(xs, ys1); scatter1.YAxisIndex = 0; scatter1.Color = Colors.Red; var scatter2 = interactivePlot1.Plot.PlotScatter(xs, ys2); scatter2.YAxisIndex = 1; scatter2.Color = Colors.Blue; // add a second Y axis var secondYAxis = new AxisLeft() { Label = "Secondary Y Axis", YAxisIndex = 1, Color = Colors.Blue }; interactivePlot1.Plot.AddAxis(secondYAxis); }
protected override void CalculateOffsets() { if (!customViewPortEnabled) { var offset = CalculateLegendOffsets(); var offsetLeft = (float)offset.Left; var offsetRight = (float)offset.Right; var offsetTop = (float)offset.Top; var offsetBottom = (float)offset.Bottom; // offsets for y-labels if (AxisLeft.NeedsOffset) { offsetLeft += AxisLeft.RequiredSize().Width; } if (AxisRight.NeedsOffset) { offsetRight += AxisRight.RequiredSize().Width; } if (XAxis.IsEnabled && XAxis.IsDrawLabelsEnabled) { var xlabelheight = XAxis.LabelRotatedHeight + XAxis.YOffset; // offsets for x-labels if (XAxis.Position == XAxis.XAxisPosition.Bottom) { offsetBottom += xlabelheight; } else if (XAxis.Position == XAxis.XAxisPosition.Top) { offsetTop += xlabelheight; } else if (XAxis.Position == XAxis.XAxisPosition.BothSided) { offsetBottom += xlabelheight; offsetTop += xlabelheight; } } offsetTop += ExtraTopOffset; offsetRight += ExtraRightOffset; offsetBottom += ExtraBottomOffset; offsetLeft += ExtraLeftOffset; var minOffset = MinOffset; ViewPortHandler.RestrainViewPort( Math.Max(minOffset, offsetLeft), Math.Max(minOffset, offsetTop), Math.Max(minOffset, offsetRight), Math.Max(minOffset, offsetBottom)); } PrepareOffsetMatrix(); PrepareValuePxMatrix(); }
private void AddYLeft_Click(object sender, EventArgs e) { var newAxis = new AxisLeft() { Color = Renderer.Color.Random(), Label = "Additional Axis" }; interactivePlot1.Plot.Axes.Add(newAxis); interactivePlot1.Render(); }
protected override void CalcMinMax() { if (FitBars) { XAxis.Calculate(data.xMin - Data.BarWidth / 2f, data.xMax + data.BarWidth / 2f); } else { XAxis.Calculate(data.xMin, data.xMax); } // calculate axis range (min / max) according to provided data AxisLeft.Calculate(data.GetYMin(Components.YAxisDependency.Left), data.GetYMax(Components.YAxisDependency.Left)); AxisRight.Calculate(data.GetYMin(Components.YAxisDependency.Right), data.GetYMax(Components.YAxisDependency.Right)); }