internal YAxis(Pane owner) : base(owner) { NumberDecimalDigitsAuto = true; MinAuto = true; MaxAuto = true; labelInfo = new YAxisLabelInfo(); LeftAxisRect = new Rectangle(0, 0, 0, 0); RightAxisRect = new Rectangle(0, 0, 0, 0); exponentLabel = new ExponentLabel(this); }
internal YAxis(Pane owner) : base(owner) { NumberDecimalDigitsAuto = true; MinAuto = true; MaxAuto = true; labelInfo = new YAxisLabelInfo(); LeftAxisRect = new Rectangle(0, 0, 0, 0); RightAxisRect = new Rectangle(0, 0, 0, 0); exponentLabel = new ExponentLabel(this); showExtraPriceMark = AppConfig.GetBooleanParam("VerbosePriceMark", false); }
private void DetermineLabelInfo() { RectangleD worldRect = Owner.WorldRect; Rectangle canvasRect = Owner.CanvasRect; double num = Math.Floor(Math.Log10(worldRect.Height)); double num2 = 1.0; if (Math.Abs(num) >= 3.0) { double num3 = Math.Floor((Math.Abs(num) / 3.0)) - 1.0; num2 = Math.Pow(10.0, (Math.Sign(num) * num3) * 3.0); } LabelInfo.Exponent = num2; LabelInfo.MajorStep = Conversion.ScreenToWorld(new SizeD(0.0, Font.Height), worldRect, canvasRect).Height; double y = Math.Ceiling(Math.Log10(LabelInfo.MajorStep)); YAxisLabelInfo labelInfo = LabelInfo; labelInfo.MajorStep /= Math.Pow(10.0, y); if (LabelInfo.MajorStep >= 0.5) { LabelInfo.MajorStep = 1.0; LabelInfo.MinorStep = 0.5; } else if (LabelInfo.MajorStep >= 0.2) { LabelInfo.MajorStep = 0.5; LabelInfo.MinorStep = 0.10000000149011612; } else if (LabelInfo.MajorStep >= 0.1) { LabelInfo.MajorStep = 0.20000000298023224; LabelInfo.MinorStep = 0.10000000149011612; } else { LabelInfo.MajorStep = 0.10000000149011612; LabelInfo.MinorStep = 0.10000000149011612; } YAxisLabelInfo info2 = LabelInfo; info2.MajorStep *= Math.Pow(10.0, y); YAxisLabelInfo info3 = LabelInfo; info3.MinorStep *= Math.Pow(10.0, y); LabelInfo.Max = Math.Ceiling(((worldRect.Y + worldRect.Height) / LabelInfo.MajorStep)) * LabelInfo.MajorStep; LabelInfo.Min = Math.Floor((worldRect.Y / LabelInfo.MajorStep)) * LabelInfo.MajorStep; }
internal void Draw(Graphics g, Rectangle axisRect, YAxisAlignment alignment) { YAxisLabelInfo labelInfo = Owner.LabelInfo; StringFormat stringFormat = YAxis.PrepareStringFormat(alignment); using (stringFormat) { if (((int)Math.Round(labelInfo.Exponent)) != 1) { var ef = new RectangleF(0f, 0f, 0f, 0f); var exponent = (int)labelInfo.Exponent; string str = ""; if (labelInfo.Exponent > 1000000.0) { exponent = (int)(labelInfo.Exponent / 1000000.0); str = "M"; } else if (labelInfo.Exponent > 1000.0) { exponent = (int)(labelInfo.Exponent / 1000.0); str = "K"; } if (labelInfo.Exponent < 1.01E-06) { exponent = (int)((labelInfo.Exponent * 1.01) / 1E-06); str = "u"; } else if (labelInfo.Exponent < 0.00101) { exponent = (int)((labelInfo.Exponent * 1.01) / 0.001); str = "m"; } ef.Size = g.MeasureString("x " + exponent + str, Chart.visualSettings.ExponentLabelFont, ef.Location, stringFormat); if (alignment == YAxisAlignment.Left) { ef.X = (axisRect.Right - ef.Width) - 2f; } else if (alignment == YAxisAlignment.Right) { ef.X = axisRect.Left + 2; } ef.Y = (axisRect.Bottom - ef.Size.Height) - 1f; if (axisRect.Contains(Rectangle.Round(ef))) { var pen = new Pen(Chart.visualSettings.ExponentLabelForeColor); var brush = new SolidBrush(Chart.visualSettings.ExponentLabelBackColor); var brush2 = new SolidBrush(Chart.visualSettings.ExponentLabelTextColor); using (pen) { using (brush) { using (brush2) { g.FillRectangle(brush, ef); g.DrawRectangle(pen, (int)ef.X, (int)ef.Y, (int)ef.Width, (int)ef.Height); g.DrawString("x " + exponent + str, Chart.visualSettings.ExponentLabelFont, brush2, ef, stringFormat); } } } } } } }