Skip to content

Commit 013235f

Browse files
authored
Merge pull request oxyplot#1247 from lauxjpn/fix_issue_1245
Fix issue oxyplot#1245
2 parents 2b701b3 + ccdf9f6 commit 013235f

File tree

4 files changed

+37
-11
lines changed

4 files changed

+37
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ All notable changes to this project will be documented in this file.
4747
- ScatterSeries with DateTimeAxis/TimeSpanAxis (#1132)
4848
- Exporting TextAnnotation with TextColor having 255 alpha to SVG produces opaque text (#1160)
4949
- Chart is not updated when top and bottom are not visible (#1219)
50+
- Candle overlap each candle (#623)
51+
- CandleStick is overlapped when item.open == item.close in the CandleStickAndVolumeSeries (#1245)
5052

5153
## [1.0.0] - 2016-09-11
5254
### Added

CONTRIBUTORS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,5 @@ Vsevolod Kukol <sevo@sevo.org>
115115
Xavier <Xavier@xavier-PC.lsi>
116116
zur003 <Eric.Zurcher@csiro.au>
117117
Markus Ebner
118-
Duncan Robertson <duncanjacobrobertson@gmail.com>
118+
Duncan Robertson <duncanjacobrobertson@gmail.com>
119+
LauXjpn <laucomm@gmail.com>

Source/OxyPlot/Series/FinancialSeries/CandleStickAndVolumeSeries.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,22 @@ public override void Render(IRenderContext rc)
315315

316316
// Body
317317
var openLeft = open + new ScreenVector(-candlewidth * 0.5, 0);
318-
var rect = new OxyRect(openLeft.X, min.Y, candlewidth, max.Y - min.Y);
319-
rc.DrawClippedRectangleAsPolygon(
320-
clippingBar,
321-
rect,
322-
fillColor,
323-
lineColor,
324-
this.StrokeThickness);
318+
319+
if (max.Y - min.Y < 1.0)
320+
{
321+
var leftPoint = new ScreenPoint(openLeft.X - this.StrokeThickness, min.Y);
322+
var rightPoint = new ScreenPoint(openLeft.X + this.StrokeThickness + candlewidth, min.Y);
323+
rc.DrawClippedLine(clippingBar, new[] { leftPoint, rightPoint }, leftPoint.DistanceToSquared(rightPoint), lineColor, this.StrokeThickness, null, LineJoin.Miter, true);
324+
325+
leftPoint = new ScreenPoint(openLeft.X - this.StrokeThickness, max.Y);
326+
rightPoint = new ScreenPoint(openLeft.X + this.StrokeThickness + candlewidth, max.Y);
327+
rc.DrawClippedLine(clippingBar, new[] { leftPoint, rightPoint }, leftPoint.DistanceToSquared(rightPoint), lineColor, this.StrokeThickness, null, LineJoin.Miter, true);
328+
}
329+
else
330+
{
331+
var rect = new OxyRect(openLeft.X, min.Y, candlewidth, max.Y - min.Y);
332+
rc.DrawClippedRectangleAsPolygon(clippingBar, rect, fillColor, lineColor, this.StrokeThickness);
333+
}
325334

326335
// Volume Part
327336
if (this.VolumeAxis == null || this.VolumeStyle == VolumeStyle.None)
@@ -700,4 +709,4 @@ protected OxyRect GetSeparationClippingRect()
700709
return new OxyRect(minX, minY, maxX - minX, maxY - minY);
701710
}
702711
}
703-
}
712+
}

Source/OxyPlot/Series/FinancialSeries/CandleStickSeries.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,22 @@ public override void Render(IRenderContext rc)
159159

160160
// Body
161161
var openLeft = open + new ScreenVector(-candlewidth * 0.5, 0);
162-
var rect = new OxyRect(openLeft.X, min.Y, candlewidth, max.Y - min.Y);
163-
rc.DrawClippedRectangleAsPolygon(clippingRect, rect, fillColor, lineColor, this.StrokeThickness);
162+
163+
if (max.Y - min.Y < 1.0)
164+
{
165+
var leftPoint = new ScreenPoint(openLeft.X - this.StrokeThickness, min.Y);
166+
var rightPoint = new ScreenPoint(openLeft.X + this.StrokeThickness + candlewidth, min.Y);
167+
rc.DrawClippedLine(clippingRect, new[] { leftPoint, rightPoint }, leftPoint.DistanceToSquared(rightPoint), lineColor, this.StrokeThickness, null, LineJoin.Miter, true);
168+
169+
leftPoint = new ScreenPoint(openLeft.X - this.StrokeThickness, max.Y);
170+
rightPoint = new ScreenPoint(openLeft.X + this.StrokeThickness + candlewidth, max.Y);
171+
rc.DrawClippedLine(clippingRect, new[] { leftPoint, rightPoint }, leftPoint.DistanceToSquared(rightPoint), lineColor, this.StrokeThickness, null, LineJoin.Miter, true);
172+
}
173+
else
174+
{
175+
var rect = new OxyRect(openLeft.X, min.Y, candlewidth, max.Y - min.Y);
176+
rc.DrawClippedRectangleAsPolygon(clippingRect, rect, fillColor, lineColor, this.StrokeThickness);
177+
}
164178
}
165179
}
166180

0 commit comments

Comments
 (0)