I'm using PlotStyle.Hash for the lines and they break on the hour bar nicely rather than ugly diagonal connections.
But overriding the plot function to paint the space between the bars leaves those with diagonal connections
Is there any way to paint horizontally up to the boundary between the break bars and then paint the next bar horizontally?
Here's the overriding plot method.
Thanks!
Wayne
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max) { base.Plot(graphics, bounds, min, max); if (Bars == null || ChartControl == null) return; SolidBrush brushblue = new SolidBrush(Color.FromArgb(60,Color.Blue)); SolidBrush brushred = new SolidBrush(Color.FromArgb(60,Color.Red)); int barWidth = ChartControl.ChartStyle.GetBarPaintWidth(ChartControl.BarWidth); SmoothingMode oldSmoothingMode = graphics.SmoothingMode; GraphicsPath path = new GraphicsPath(); GraphicsPath path2 = new GraphicsPath(); if(fill) { //Color Long Buy Zone for (int seriesCount = 0; seriesCount < 2; seriesCount++) { int lastX = -1; int lastY = -1; DataSeries series = (DataSeries) Values[seriesCount]; double val = 0; Gui.Chart.Plot plot = Plots[seriesCount]; for (int count = 0; count < ChartControl.BarsPainted; count++) { int idx = ChartControl.LastBarPainted - ChartControl.BarsPainted + 1 + count; if (idx < 0 || idx >= Input.Count || (!ChartControl.ShowBarsRequired && idx < BarsRequired)) continue; val = series.Get(idx); if (val == 0) continue; int x = (int) (ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2 - (ChartControl.BarsPainted - 1) * ChartControl.BarSpace + count * ChartControl.BarSpace) + 1; int y = (int) ((bounds.Y + bounds.Height) - ((val - min ) / Gui.Chart.ChartControl.MaxMinusMin(max, min)) * bounds.Height); if (lastX >= 0) { path.AddLine(lastX - plot.Pen.Width / 2, lastY, x - plot.Pen.Width / 2, y); } lastX = x; lastY = y; } path.Reverse(); } //Color Short Buy Zone for (int seriesCount = 3; seriesCount < 5; seriesCount++) { int lastX = -1; int lastY = -1; DataSeries series = (DataSeries) Values[seriesCount]; double val = 0; Gui.Chart.Plot plot = Plots[seriesCount]; for (int count = 0; count < ChartControl.BarsPainted; count++) { int idx = ChartControl.LastBarPainted - ChartControl.BarsPainted + 1 + count; if (idx < 0 || idx >= Input.Count || (!ChartControl.ShowBarsRequired && idx < BarsRequired)) continue; val = series.Get(idx); if (val == 0) continue; int x = (int) (ChartControl.CanvasRight - ChartControl.BarMarginRight - barWidth / 2 - (ChartControl.BarsPainted - 1) * ChartControl.BarSpace + count * ChartControl.BarSpace) + 1; int y = (int) ((bounds.Y + bounds.Height) - ((val - min ) / Gui.Chart.ChartControl.MaxMinusMin(max, min)) * bounds.Height); if (lastX >= 0) { path2.AddLine(lastX - plot.Pen.Width / 2, lastY, x - plot.Pen.Width / 2, y); } lastX = x; lastY = y; } path2.Reverse(); } } graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.SmoothingMode = oldSmoothingMode; graphics.FillPath(brushblue, path); graphics.FillPath(brushred, path2); }
Comment