; } } //Horizontal if (chartData.ShowHGridLines) { for (float i = bottom ; i > top; i-=hspacing) { string desc = tickCount.ToString(); tickCount+=chartData.YTickSize; g.DrawLine(gridPen, right, i, left-3, i); SizeF textsize = g.MeasureString(desc,baseFont); g.DrawString(desc, baseFont, new SolidBrush(chartData.GridColor), left-textsize.Width - 3, i - (textsize.Height/2)) ; } } } private void DrawLine(ChartLine chartLine) { Pen linePen = new Pen(chartLine.Color); linePen.StartCap = LineCap.Round; linePen.EndCap = LineCap.Round; linePen.Width = chartLine.Width ; linePen.DashStyle = chartLine.LineStyle; PointF[] Values = new PointF[chartLine.Values.Length]; float scale = hspacing / chartData.YTickSize ; for (int i = 0 ; i < chartLine.Values.Length; i++) { float x = left + vspacing * i; Values[i] = new PointF(x, bottom-chartLine.Values[i]*scale); } g.DrawLines(linePen, Values); } private void DrawLegend() { //Draw Legend Box ControlPaint.DrawBorder(g, (Rectangle)legendRect, SystemColors.WindowFrame, ButtonBorderStyle.Solid); LinearGradientBrush b = new LinearGradientBrush(legendRect, backColor, Color.SteelBlue, LinearGradientMode.Horizontal); r.Inflate(-1, -1); g.FillRectangle(b, legendRect); b.Dispose(); float startY = 5; foreach (ChartLine cl in chartData.Lines) { Pen p = new Pen(cl.Color) ; p.Width = p.Width*4; SizeF textsize = g.MeasureString(cl.Title, legendFont); float lineY = startY + textsize.Height / 2 ; g.DrawLine(p, r.X + 7, lineY, r.X + 25, lineY); g.DrawString(cl.Title, legendFont, new SolidBrush(foreColor), r.X + 30, startY); startY += (textsize.Height+2); } } } }
上一页 [1] [2] [3] [4] [5] |