Skip to content

Commit

Permalink
Fix common image to work with bar groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake-Madden committed Oct 14, 2023
1 parent 26ede5b commit 3c27beb
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions src/graphs/barchart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,18 +932,11 @@ namespace Wisteria::Graphs

if (bar.GetEffect() == BoxEffect::CommonImage && scaledCommonImg.IsOk())
{
wxRect barRectAdjustedToPlotArea = barRect;
barRectAdjustedToPlotArea.SetLeft(barRect.GetLeft() -
GetPlotAreaBoundingBox().GetLeft());
barRectAdjustedToPlotArea.SetTop(barRect.GetTop() -
(GetPlotAreaBoundingBox().GetTop() +
safe_divide(GetPlotAreaBoundingBox().GetHeight() -
scaledCommonImg.GetHeight(), 2)) );
auto barImage = std::make_shared<Image>(
GraphItemInfo(barBlock.GetSelectionLabel().GetText()).
Pen(GetImageOutlineColor()).
AnchorPoint(wxPoint(lineXStart, lineYStart)),
scaledCommonImg.GetSubImage(barRectAdjustedToPlotArea));
scaledCommonImg.GetSubImage(barRect));
barImage->SetOpacity(bar.GetOpacity());
barImage->SetAnchoring(Anchoring::TopLeftCorner);
barImage->SetShadowType((GetShadowType() != ShadowType::NoDisplay) ?
Expand Down Expand Up @@ -1377,19 +1370,11 @@ namespace Wisteria::Graphs

if (bar.GetEffect() == BoxEffect::CommonImage && scaledCommonImg.IsOk())
{
wxRect barRectAdjustedToPlotArea = barRect;
barRectAdjustedToPlotArea.SetLeft(barRect.GetLeft() -
(GetPlotAreaBoundingBox().GetLeft() +
safe_divide(GetPlotAreaBoundingBox().GetWidth() -
scaledCommonImg.GetWidth(), 2)) );
barRectAdjustedToPlotArea.SetTop(barRect.GetTop() -
(GetPlotAreaBoundingBox().GetTop() +
GetPlotAreaBoundingBox().GetHeight() - scaledCommonImg.GetHeight()));
auto barImage = std::make_shared<Image>(
GraphItemInfo(barBlock.GetSelectionLabel().GetText()).
Pen(GetImageOutlineColor()).
AnchorPoint(wxPoint(lineXStart, lineYEnd)),
scaledCommonImg.GetSubImage(barRectAdjustedToPlotArea));
scaledCommonImg.GetSubImage(barRect));
barImage->SetOpacity(bar.GetOpacity());
barImage->SetAnchoring(Anchoring::TopLeftCorner);
barImage->SetShadowType((GetShadowType() != ShadowType::NoDisplay) ?
Expand Down Expand Up @@ -1805,9 +1790,7 @@ namespace Wisteria::Graphs
scaledCommonImg = GetCommonBoxImage().IsOk() ?
Image::CropImageToRect(
GetCommonBoxImage().GetBitmap(GetCommonBoxImage().GetDefaultSize()).ConvertToImage(),
// add padding for rounding issues
wxSize((maxX->x - minX->x) + ScaleToScreenAndCanvas(5),
(maxY->y - minY->y) + ScaleToScreenAndCanvas(5)), false) :
GetBoundingBox(dc).GetSize(), false) :
wxNullImage;

// draw the bars
Expand Down

0 comments on commit 3c27beb

Please sign in to comment.