internal override void Draw(ChartGraphics g, int[] xValues, int[] stackValues, int lastPlotType) { g.Pen = new Pen(color, lineWidth); g.Color = color; double [] values = source.Values; int ax = 0, ay = 0, py; int nx = 0, ny = 0; for (int i = 0; i < xValues.Length; i++) { py = 0; nx = xValues[i]; ny = g.GetY(values[i]); if (!Double.IsNaN(values[i])) { if (stacked) { py = stackValues[i]; ny += (stackValues[i] == Int32.MinValue ? Int32.MinValue : stackValues[i]); } if (visible) { if (nx > ax + 1) // More than one pixel hop, draw intermediate pixels too { // For each pixel between nx and ax, calculate the y, plot the line int co = (ny - ay) / (nx - ax); int j = (ax > 0 ? ax : 1); // Skip 0 for (j = ax; j <= nx; j++) { if (ay != Int32.MinValue && ny != Int32.MinValue) { g.DrawLine(j, py, j, (co * (j - ax) + ay)); } } } else if (nx != 0 && py != Int32.MinValue && ny != Int32.MinValue) { g.DrawLine(nx, py, nx, ny); } } } // Special case with NaN doubles stackValues[i] = ny; ax = nx; ay = ny; } }
internal override void Draw(ChartGraphics g, int[] xValues, int[] stackValues, int lastPlotType) { g.Pen = new Pen(color, lineWidth); g.Color = color; double[] values = source.Values; int ax = 0, ay = 0; int nx = 0, ny = 0; for (int i = 0; i < xValues.Length; i++) { nx = xValues[i]; ny = g.GetY(values[i]); if (stacked && ny != Int32.MinValue) { ny += stackValues[i]; } if (visible && ny != Double.NaN && nx != 0 && ay != Int32.MinValue && ny != Int32.MinValue) { g.DrawLine(ax, ay, nx, ny); } stackValues[i] = ny; ax = nx; ay = ny; } //g.Pen = new Pen(); }
internal override void Draw(ChartGraphics g, int[] xValues, int[] stackValues, int lastPlotType) { g.Color = color; g.Pen = new Pen(color, lineWidth); int ax, ay, nx, ny; // Get X positions if (xVal1 == Int64.MinValue) { ax = g.MinX; } else if (xVal1 == Int64.MaxValue) { ax = g.MaxX; } else { ax = g.GetX(xVal1); } if (xVal2 == Int64.MinValue) { nx = g.MinX; } else if (xVal2 == Int64.MaxValue) { nx = g.MaxX; } else { nx = g.GetX(xVal2); } // Get Y positions if (yVal1 == Double.MinValue) { ay = g.MinY; } else if (yVal1 == Double.MaxValue) { ay = g.MaxY; } else { ay = g.GetY(yVal1); } if (yVal2 == Double.MinValue) { ny = g.MinY; } else if (yVal2 == Double.MaxValue) { ny = g.MaxY; } else { ny = g.GetY(yVal2); } // Draw the line if (visible) { g.DrawLine(ax, ay, nx, ny); } // Set the stackvalues int rx = nx - ax; if (rx != 0) { double rc = ((ny - ay) * 1.0d) / rx; for (int i = 0; i < xValues.Length; i++) { if (xValues[i] < ax || xValues[i] > nx) { stackValues[i] = 0; } else if (ay == ny) { stackValues[i] = ay; } else { stackValues[i] = (int)(rc * (xValues[i] - ax) + ay); } } } //g.Pen = ( new Pen( ); }