Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into axis_refactor_v2
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
schaumb committed Oct 30, 2024
2 parents d16cfdc + e658231 commit 0ca3981
Show file tree
Hide file tree
Showing 21 changed files with 178 additions and 58 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-vizzu-dev-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
- name: Build and Publish
run: |
IMAGE="vizzu-dev-desktop"
IMAGE_NAME="vizzu/$IMAGE:0.14"
IMAGE_NAME="vizzu/$IMAGE:0.15"
docker build -t $IMAGE_NAME -f tools/ci/docker/$IMAGE .
docker push $IMAGE_NAME
2 changes: 1 addition & 1 deletion .github/workflows/docker-vizzu-dev-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ jobs:
- name: Build and Publish
run: |
IMAGE="vizzu-dev-wasm"
IMAGE_NAME="vizzu/$IMAGE:0.14"
IMAGE_NAME="vizzu/$IMAGE:0.15"
docker build -t $IMAGE_NAME -f tools/ci/docker/$IMAGE .
docker push $IMAGE_NAME
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,25 @@

### Fixed

- Do not interpolate hiding/showing legend

## [0.15.0] - 2024-10-28

### Fixed

- Markers are the same even if new record added.
- Flying out marker label fixed.
- Axis line hide/show at same time with axis labels/ticks/title.
- Do not draw invisible axis line.
- Do not interpolate hiding/showing legend

### Changed

- Removed 'min' align property from the API which equivalent with the 'none'.
- Changed MarkerId to be a string instead of a number.

### Added

- Add marker top and center position to draw event.

## [0.14.0] - 2024-10-03

Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ docker run -i -t -v .:/workspace vizzu/vizzu-dev-desktop bash
or you can use a specific version of the prebuilt image:

```sh
docker run -i -t -v .:/workspace vizzu/vizzu-dev-desktop:0.14 bash
docker run -i -t -v .:/workspace vizzu/vizzu-dev-desktop:0.15 bash
```

Run the following commands to build and run the `WASM` version's development
Expand All @@ -84,7 +84,7 @@ docker run -i -t -v .:/workspace vizzu/vizzu-dev-wasm bash
or you can use a specific version of the prebuilt image:

```sh
docker run -i -t -v .:/workspace vizzu/vizzu-dev-wasm:0.14 bash
docker run -i -t -v .:/workspace vizzu/vizzu-dev-wasm:0.15 bash
```

### Building the project
Expand Down
8 changes: 8 additions & 0 deletions src/apps/weblib/ts-api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,19 @@ export interface Logo extends Element {
export interface Area extends Element {
tagName: 'plot-area'
}

/** Marker element position structure helper for tooltip */
export interface MarkerPosition {
top: Point
center: Point
}

/** Plot marker element of the chart representing a data point. */
export interface Marker extends Element {
tagName: 'plot-marker'
categories: Data.Record
values: Data.Record
position: MarkerPosition
/** Unique index of the marker. */
index: string
}
Expand Down
18 changes: 14 additions & 4 deletions src/base/geom/rect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <algorithm>
#include <array>
#include <cmath>
#include <compare>

#include "base/math/floating.h"

Expand Down Expand Up @@ -92,10 +93,19 @@ Rect Rect::intersection(const Rect &rect) const

bool Rect::intersects(const Rect &r) const
{
using Math::Floating::less;
auto isOutside =
less(right(), r.left()) || less(r.right(), left())
|| less(top(), r.bottom()) || less(r.top(), bottom());
using Math::Floating::is_zero;
using std::strong_order;
auto first = strong_order(right(), r.left());
auto second = strong_order(r.right(), left());
auto third = strong_order(top(), r.bottom());
auto fourth = strong_order(r.top(), bottom());

auto isOutside = is_lt(first) || is_lt(second) || is_lt(third)
|| is_lt(fourth)
|| ((is_eq(first) || is_eq(second))
&& !is_zero(width()) && !is_zero(r.width()))
|| ((is_eq(third) || is_eq(fourth))
&& !is_zero(height()) && !is_zero(r.height()));
return !isOutside;
}

Expand Down
37 changes: 26 additions & 11 deletions src/chart/main/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,23 @@ class Events
struct Marker : Element
{
const Gen::Marker &marker;
struct DataPosition
{
Geom::Point top;
Geom::Point center;
} position;

explicit Marker(const Gen::Marker &marker) :
explicit Marker(const Gen::Marker &marker,
const DataPosition &position) :
Element("plot-marker"),
marker(marker)
marker(marker),
position(position)
{}

void appendToJSON(Conv::JSONObj &&jsonObj) const override
{
Element::appendToJSON(
marker.appendToJSON(std::move(jsonObj)));
Element::appendToJSON(marker.appendToJSON(
std::move(jsonObj))("position", position));
}
};

Expand All @@ -268,8 +275,10 @@ class Events
{
bool horizontal;

MarkerGuide(const Gen::Marker &marker, bool horizontal) :
MarkerChild("guide", marker),
MarkerGuide(const Gen::Marker &marker,
const Marker::DataPosition &position,
bool horizontal) :
MarkerChild("guide", marker, position),
horizontal(horizontal)
{}

Expand Down Expand Up @@ -313,15 +322,19 @@ class Events
return std::make_unique<Legend>(properties);
}

static auto marker(const Gen::Marker &marker)
static auto marker(const Gen::Marker &marker,
const Marker::DataPosition &position)
{
return std::make_unique<Marker>(marker);
return std::make_unique<Marker>(marker, position);
}

static auto markerGuide(const Gen::Marker &marker,
const Marker::DataPosition &position,
bool horizontal)
{
return std::make_unique<MarkerGuide>(marker, horizontal);
return std::make_unique<MarkerGuide>(marker,
position,
horizontal);
}

static auto root()
Expand Down Expand Up @@ -362,11 +375,13 @@ class Events
}

static auto markerLabel(const std::string &label,
const Gen::Marker &marker)
const Gen::Marker &marker,
const Marker::DataPosition &position)
{
return std::make_unique<Text<MarkerChild>>(label,
"label",
marker);
marker,
position);
}

static auto dimLegendLabel(
Expand Down
2 changes: 1 addition & 1 deletion src/chart/main/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

#include "base/app/version.h"

const App::Version Vizzu::Main::version(0, 14, 0);
const App::Version Vizzu::Main::version(0, 15, 0);

const char *const Vizzu::Main::siteUrl = "https://vizzu.io/";
15 changes: 11 additions & 4 deletions src/chart/rendering/markerrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ void MarkerRenderer::drawLines(Gfx::ICanvas &canvas,
const Geom::Line line(axisPoint, blended.center);

auto guideElement =
Events::Targets::markerGuide(blended.marker, false);
Events::Targets::markerGuide(blended.marker,
blended.dataPosition,
false);

if (rootEvents.draw.plot.marker.guide->invoke(
Events::OnLineDrawEvent(*guideElement,
Expand All @@ -88,7 +90,9 @@ void MarkerRenderer::drawLines(Gfx::ICanvas &canvas,
const Geom::Line line(center, axisPoint);

auto guideElement =
Events::Targets::markerGuide(blended.marker, true);
Events::Targets::markerGuide(blended.marker,
blended.dataPosition,
true);

if (rootEvents.draw.plot.marker.guide->invoke(
Events::OnLineDrawEvent(*guideElement,
Expand Down Expand Up @@ -262,7 +266,8 @@ void MarkerRenderer::draw(Gfx::ICanvas &canvas,
canvas.setLineWidth(*rootStyle.plot.marker.borderWidth);

auto markerElement =
Events::Targets::marker(abstractMarker.marker);
Events::Targets::marker(abstractMarker.marker,
abstractMarker.dataPosition);

auto colorAlpha =
Math::FuzzyBool::And<double>(abstractMarker.enabled, factor);
Expand Down Expand Up @@ -363,7 +368,9 @@ void MarkerRenderer::drawLabel(Gfx::ICanvas &canvas,
Gfx::ColorTransform::OverrideColor(
(*labelStyle.filter)(color)*colorAlpha),
*rootEvents.draw.plot.marker.label,
Events::Targets::markerLabel(text, marker));
Events::Targets::markerLabel(text,
marker,
abstractMarker.dataPosition));
}

std::string MarkerRenderer::getLabelText(
Expand Down
12 changes: 12 additions & 0 deletions src/chart/rendering/markers/abstractmarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ AbstractMarker AbstractMarker::create(const DrawingContext &ctx,
switch (shapeType) {
case Gen::ShapeType::rectangle:
return RectangleMarker(marker,
ctx.coordSys,
ctx.getOptions(),
ctx.rootStyle);
case Gen::ShapeType::circle:
Expand Down Expand Up @@ -132,6 +133,17 @@ AbstractMarker AbstractMarker::createInterpolated(
return aMarker;
}

void AbstractMarker::setDataPosition(const CoordinateSystem &coordSys)
{
dataPosition = {
this->getLabelPos(Styles::MarkerLabel::Position::top,
coordSys)
.end,
this->getLabelPos(Styles::MarkerLabel::Position::center,
coordSys)
.begin};
}

Geom::Rect AbstractMarker::getBoundary() const
{
return Geom::Rect::Boundary(points);
Expand Down
3 changes: 3 additions & 0 deletions src/chart/rendering/markers/abstractmarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class AbstractMarker
Geom::Point center;
Geom::Rect dataRect;
double radius{};
Events::Targets::Marker::DataPosition dataPosition;

[[nodiscard]] Geom::Rect getBoundary() const;
[[nodiscard]] Geom::Line getLine() const;
Expand All @@ -51,6 +52,8 @@ class AbstractMarker
const Gen::Marker &marker,
const Gen::ShapeType &shapeType,
::Anim::InterpolateIndex lineIndex);

void setDataPosition(const CoordinateSystem &coordSys);
};

class SingleDrawMarker : public AbstractMarker
Expand Down
2 changes: 2 additions & 0 deletions src/chart/rendering/markers/circlemarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ CircleMarker::CircleMarker(const Gen::Marker &marker,
dataRect.pos = pos;
dataRect.size = Geom::Size();
radius = fabs(coordSys.verConvert(r));

setDataPosition(coordSys);
}

}
2 changes: 2 additions & 0 deletions src/chart/rendering/markers/connectingmarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ ConnectingMarker::ConnectingMarker(const DrawingContext &ctx,

dataRect.pos = isLine ? points[2] : points[1];
dataRect.size = Geom::Size{points[2] - dataRect.pos};

setDataPosition(ctx.coordSys);
}

const Gen::Marker *ConnectingMarker::getPrev(
Expand Down
3 changes: 3 additions & 0 deletions src/chart/rendering/markers/rectanglemarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Vizzu::Draw
{

RectangleMarker::RectangleMarker(const Gen::Marker &marker,
const CoordinateSystem &coordSys,
const Gen::Options &options,
const Styles::Chart &style) :
SingleDrawMarker(marker, options, Gen::ShapeType::rectangle)
Expand Down Expand Up @@ -83,6 +84,8 @@ RectangleMarker::RectangleMarker(const Gen::Marker &marker,
dataRect.pos = points[0];
dataRect.size = Geom::Size{points[2] - points[0]};
radius = 0;

setDataPosition(coordSys);
}

}
1 change: 1 addition & 0 deletions src/chart/rendering/markers/rectanglemarker.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class RectangleMarker : public SingleDrawMarker
{
public:
RectangleMarker(const Gen::Marker &marker,
const CoordinateSystem &coordSys,
const Gen::Options &options,
const Styles::Chart &style);
};
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/tests/features.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"refs": ["ba17dad"]
},
"events/drawing_events": {
"refs": ["33e0e4d"]
"refs": ["c3169b0"]
},
"subtitle_caption": {
"refs": ["f6dabf0"]
Expand Down
Loading

0 comments on commit 0ca3981

Please sign in to comment.