Skip to content

Commit

Permalink
Wherever the height and width components of a rectangle are used in c…
Browse files Browse the repository at this point in the history
…onjunction with dc.DrawRectangle, 1 needs to be subtracted.

This is because rect.x + rect.width != rect.right (in fact it equals rect.right + 1)

A better fix for #18.
  • Loading branch information
iwbnwif committed Apr 19, 2017
1 parent 86030e1 commit c9c5fdc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/axis/labelaxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,9 @@ void LabelAxis::DrawGridLines(wxDC &dc, wxRect rc)
if (IsVertical())
{
// Vertical axis, so gridlines are horizontal.
wxCoord y = ToGraphics(dc, rc.y, rc.height, value);
wxCoord y = ToGraphics(dc, rc.y, rc.height - 1, value);

if (y == rc.y || y == (rc.y + rc.height))
if (y == rc.y || y == (rc.y + rc.height - 1))
continue;

dc.DrawLine(rc.x + 1, y, rc.x + rc.width - 1, y);
Expand All @@ -311,9 +311,9 @@ void LabelAxis::DrawGridLines(wxDC &dc, wxRect rc)
else
{
// Horizontal axis, so gridlines are vertical.
wxCoord x = ToGraphics(dc, rc.x, rc.width, value);
wxCoord x = ToGraphics(dc, rc.x, rc.width - 1, value);

if (x == rc.x || x == (rc.x + rc.width))
if (x == rc.x || x == (rc.x + rc.width - 1))
continue;

dc.DrawLine(x, rc.y + 1, x, rc.y + rc.height - 1);
Expand Down
8 changes: 3 additions & 5 deletions src/axisplot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ void AxisPlot::DrawAxesArray(wxDC &dc, wxRect rc, AxisArray *axes, bool vertical
void AxisPlot::DrawAxes(wxDC &dc, wxRect &rc, wxRect rcData)
{
if (m_leftAxes.Count() != 0) {
wxRect rcLeftAxes(rc.x, rcData.y, (rcData.x - rc.x), rcData.height);
wxRect rcLeftAxes(rc.x, rcData.y, (rcData.x - rc.x), rcData.height - 1);
DrawAxesArray(dc, rcLeftAxes, &m_leftAxes, true);
}
if (m_rightAxes.Count() != 0) {
Expand All @@ -448,7 +448,7 @@ void AxisPlot::DrawAxes(wxDC &dc, wxRect &rc, wxRect rcData)
DrawAxesArray(dc, rcTopAxes, &m_topAxes, false);
}
if (m_bottomAxes.Count() != 0) {
wxRect rcBottomAxes(rcData.x, rcData.y + rcData.height, rcData.width, (rc.y + rc.height - rcData.y - rcData.height - 1));
wxRect rcBottomAxes(rcData.x, rcData.y + rcData.height - 1, rcData.width, (rc.y + rc.height - rcData.y - rcData.height - 1));
DrawAxesArray(dc, rcBottomAxes, &m_bottomAxes, false);
}
}
Expand Down Expand Up @@ -491,9 +491,7 @@ void AxisPlot::DrawBackground(ChartDC& cdc, wxRect rc)
// Calculate the rectangle where the actual data is plotted.
CalcDataArea(dc, rc, rcPlot, rcLegend);

// Draw the background of the plot area.
// Is there a bug in dc.DrawRectangle? It seems the rectangle is 1 pixel smaller in height than it should be.
m_dataBackground->Draw(dc, wxRect(rcPlot.x, rcPlot.y, rcPlot.width, rcPlot.height + 1));
m_dataBackground->Draw(dc, rcPlot);
// m_background->Draw(dc, rcPlot);

// Draw all static items.
Expand Down

0 comments on commit c9c5fdc

Please sign in to comment.