private void SetPlotPanel(Graphics g) { // Set form1.PlotPanel: float xOffset = ChartArea.Width / 30.0f; float yOffset = ChartArea.Height / 30.0f; SizeF labelFontSize = g.MeasureString("A", LabelFont); SizeF titleFontSize = g.MeasureString("A", TitleFont); if (Title.ToUpper() == "NO TITLE") { titleFontSize.Width = 8f; titleFontSize.Height = 8f; } float xSpacing = xOffset / 3.0f; float ySpacing = yOffset / 3.0f; SizeF tickFontSize = g.MeasureString("A", TickFont); float tickSpacing = 2f; SizeF yTickSize = g.MeasureString(YLimMin.ToString(), TickFont); for (float yTick = YLimMin + YTickOffset; yTick <= YLimMax; yTick += YTick) { SizeF tempSize = g.MeasureString(yTick.ToString(), TickFont); if (yTickSize.Width < tempSize.Width) { yTickSize = tempSize; } } float leftMargin = xOffset + labelFontSize.Width + xSpacing + yTickSize.Width + tickSpacing; float rightMargin = xOffset; float topMargin = yOffset + titleFontSize.Height + ySpacing; float bottomMargin = yOffset + labelFontSize.Height + ySpacing + tickSpacing + tickFontSize.Height; // Define the plot panel size: int[] panelsize = new int[4]; form1.PlotPanel.Left = ChartArea.X + (int)leftMargin; form1.PlotPanel.Top = ChartArea.Y + (int)topMargin; form1.PlotPanel.Width = ChartArea.Width - (int)leftMargin - 2 * (int)rightMargin; form1.PlotPanel.Height = ChartArea.Height - (int)topMargin - (int)bottomMargin; form1.PlotPanel.BackColor = plotBackColor; }
void SetPlotPanel(Graphics g) { // Set form1.PlotPanel: nfloat xOffset = ChartArea.Width / 30; nfloat yOffset = ChartArea.Height / 30; CGSize labelFontSize = g.MeasureString("A", LabelFont); CGSize titleFontSize = g.MeasureString("A", TitleFont); if (Title.ToUpper() == "NO TITLE") { titleFontSize.Width = 8f; titleFontSize.Height = 8f; } nfloat xSpacing = xOffset / 3.0f; nfloat ySpacing = yOffset / 3.0f; CGSize tickFontSize = g.MeasureString("A", TickFont); float tickSpacing = 2f; CGSize yTickSize = g.MeasureString(YLimMin.ToString(), TickFont); for (float yTick = YLimMin + YTickOffset; yTick <= YLimMax; yTick += YTick) { CGSize tempSize = g.MeasureString(yTick.ToString(), TickFont); if (yTickSize.Width < tempSize.Width) { yTickSize = tempSize; } } var leftMargin = (float)(xOffset + labelFontSize.Width + xSpacing + yTickSize.Width + tickSpacing); nfloat rightMargin = xOffset; var topMargin = (float)(yOffset + titleFontSize.Height + ySpacing); var bottomMargin = (float)(yOffset + labelFontSize.Height + ySpacing + tickSpacing + tickFontSize.Height); // Define the plot panel size: form1.PlotPanel.Left = ChartArea.X + (int)leftMargin; form1.PlotPanel.Top = ChartArea.Y + (int)topMargin; form1.PlotPanel.Width = ChartArea.Width - (int)leftMargin - 2 * (int)rightMargin; form1.PlotPanel.Height = ChartArea.Height - (int)topMargin - (int)bottomMargin; form1.PlotPanel.BackColor = plotBackColor; }
void SetPlotArea(Graphics g) { // Set PlotArea: float xOffset = ChartArea.Width / 30f; float yOffset = ChartArea.Height / 30f; CGSize labelFontSize = g.MeasureString("A", LabelFont); CGSize titleFontSize = g.MeasureString("A", TitleFont); if (Title.ToUpper() == "NO TITLE") { titleFontSize.Width = 8f; titleFontSize.Height = 8f; } float xSpacing = xOffset / 3f; float ySpacing = yOffset / 3f; CGSize tickFontSize = g.MeasureString("A", TickFont); float tickSpacing = 2f; CGSize yTickSize = g.MeasureString(YLimMin.ToString(), TickFont); for (float yTick = YLimMin; yTick <= YLimMax; yTick += YTick) { CGSize tempSize = g.MeasureString(yTick.ToString(), TickFont); if (yTickSize.Width < tempSize.Width) { yTickSize = tempSize; } } var leftMargin = (float)(xOffset + labelFontSize.Width + xSpacing + yTickSize.Width + tickSpacing); float rightMargin = xOffset; var topMargin = (float)(yOffset + titleFontSize.Height + ySpacing); var bottomMargin = (float)(yOffset + labelFontSize.Height + ySpacing + tickSpacing + tickFontSize.Height); if (!IsY2Axis) { // Define the plot area with one Y axis: int plotX = ChartArea.X + (int)leftMargin; int plotY = ChartArea.Y + (int)topMargin; int plotWidth = ChartArea.Width - (int)leftMargin - 2 * (int)rightMargin; int plotHeight = ChartArea.Height - (int)topMargin - (int)bottomMargin; PlotArea = new Rectangle(plotX, plotY, plotWidth, plotHeight); } else { // Define the plot area with Y and Y2 axes: CGSize y2TickSize = g.MeasureString(Y2LimMin.ToString(), TickFont); for (float y2Tick = Y2LimMin; y2Tick <= Y2LimMax; y2Tick += Y2Tick) { CGSize tempSize2 = g.MeasureString(y2Tick.ToString(), TickFont); if (y2TickSize.Width < tempSize2.Width) { y2TickSize = tempSize2; } } rightMargin = (float)(xOffset + labelFontSize.Width + xSpacing + y2TickSize.Width + tickSpacing); int plotX = ChartArea.X + (int)leftMargin; int plotY = ChartArea.Y + (int)topMargin; int plotWidth = ChartArea.Width - (int)leftMargin - (int)rightMargin; int plotHeight = ChartArea.Height - (int)topMargin - (int)bottomMargin; PlotArea = new Rectangle(plotX, plotY, plotWidth, plotHeight); } }