Skip to content

Commit 0ca3981

Browse files
committed
Merge remote-tracking branch 'origin/main' into axis_refactor_v2
# Conflicts: # CHANGELOG.md
2 parents d16cfdc + e658231 commit 0ca3981

21 files changed

+178
-58
lines changed

.github/workflows/docker-vizzu-dev-desktop.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
- name: Build and Publish
2525
run: |
2626
IMAGE="vizzu-dev-desktop"
27-
IMAGE_NAME="vizzu/$IMAGE:0.14"
27+
IMAGE_NAME="vizzu/$IMAGE:0.15"
2828
docker build -t $IMAGE_NAME -f tools/ci/docker/$IMAGE .
2929
docker push $IMAGE_NAME

.github/workflows/docker-vizzu-dev-wasm.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ jobs:
2424
- name: Build and Publish
2525
run: |
2626
IMAGE="vizzu-dev-wasm"
27-
IMAGE_NAME="vizzu/$IMAGE:0.14"
27+
IMAGE_NAME="vizzu/$IMAGE:0.15"
2828
docker build -t $IMAGE_NAME -f tools/ci/docker/$IMAGE .
2929
docker push $IMAGE_NAME

CHANGELOG.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,25 @@
44

55
### Fixed
66

7+
- Do not interpolate hiding/showing legend
8+
9+
## [0.15.0] - 2024-10-28
10+
11+
### Fixed
12+
713
- Markers are the same even if new record added.
14+
- Flying out marker label fixed.
815
- Axis line hide/show at same time with axis labels/ticks/title.
916
- Do not draw invisible axis line.
10-
- Do not interpolate hiding/showing legend
1117

1218
### Changed
1319

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

23+
### Added
24+
25+
- Add marker top and center position to draw event.
1726

1827
## [0.14.0] - 2024-10-03
1928

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ docker run -i -t -v .:/workspace vizzu/vizzu-dev-desktop bash
7070
or you can use a specific version of the prebuilt image:
7171

7272
```sh
73-
docker run -i -t -v .:/workspace vizzu/vizzu-dev-desktop:0.14 bash
73+
docker run -i -t -v .:/workspace vizzu/vizzu-dev-desktop:0.15 bash
7474
```
7575

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

8686
```sh
87-
docker run -i -t -v .:/workspace vizzu/vizzu-dev-wasm:0.14 bash
87+
docker run -i -t -v .:/workspace vizzu/vizzu-dev-wasm:0.15 bash
8888
```
8989

9090
### Building the project

src/apps/weblib/ts-api/events.ts

+8
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,19 @@ export interface Logo extends Element {
137137
export interface Area extends Element {
138138
tagName: 'plot-area'
139139
}
140+
141+
/** Marker element position structure helper for tooltip */
142+
export interface MarkerPosition {
143+
top: Point
144+
center: Point
145+
}
146+
140147
/** Plot marker element of the chart representing a data point. */
141148
export interface Marker extends Element {
142149
tagName: 'plot-marker'
143150
categories: Data.Record
144151
values: Data.Record
152+
position: MarkerPosition
145153
/** Unique index of the marker. */
146154
index: string
147155
}

src/base/geom/rect.cpp

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <algorithm>
44
#include <array>
55
#include <cmath>
6+
#include <compare>
67

78
#include "base/math/floating.h"
89

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

9394
bool Rect::intersects(const Rect &r) const
9495
{
95-
using Math::Floating::less;
96-
auto isOutside =
97-
less(right(), r.left()) || less(r.right(), left())
98-
|| less(top(), r.bottom()) || less(r.top(), bottom());
96+
using Math::Floating::is_zero;
97+
using std::strong_order;
98+
auto first = strong_order(right(), r.left());
99+
auto second = strong_order(r.right(), left());
100+
auto third = strong_order(top(), r.bottom());
101+
auto fourth = strong_order(r.top(), bottom());
102+
103+
auto isOutside = is_lt(first) || is_lt(second) || is_lt(third)
104+
|| is_lt(fourth)
105+
|| ((is_eq(first) || is_eq(second))
106+
&& !is_zero(width()) && !is_zero(r.width()))
107+
|| ((is_eq(third) || is_eq(fourth))
108+
&& !is_zero(height()) && !is_zero(r.height()));
99109
return !isOutside;
100110
}
101111

src/chart/main/events.h

+26-11
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,23 @@ class Events
247247
struct Marker : Element
248248
{
249249
const Gen::Marker &marker;
250+
struct DataPosition
251+
{
252+
Geom::Point top;
253+
Geom::Point center;
254+
} position;
250255

251-
explicit Marker(const Gen::Marker &marker) :
256+
explicit Marker(const Gen::Marker &marker,
257+
const DataPosition &position) :
252258
Element("plot-marker"),
253-
marker(marker)
259+
marker(marker),
260+
position(position)
254261
{}
255262

256263
void appendToJSON(Conv::JSONObj &&jsonObj) const override
257264
{
258-
Element::appendToJSON(
259-
marker.appendToJSON(std::move(jsonObj)));
265+
Element::appendToJSON(marker.appendToJSON(
266+
std::move(jsonObj))("position", position));
260267
}
261268
};
262269

@@ -268,8 +275,10 @@ class Events
268275
{
269276
bool horizontal;
270277

271-
MarkerGuide(const Gen::Marker &marker, bool horizontal) :
272-
MarkerChild("guide", marker),
278+
MarkerGuide(const Gen::Marker &marker,
279+
const Marker::DataPosition &position,
280+
bool horizontal) :
281+
MarkerChild("guide", marker, position),
273282
horizontal(horizontal)
274283
{}
275284

@@ -313,15 +322,19 @@ class Events
313322
return std::make_unique<Legend>(properties);
314323
}
315324

316-
static auto marker(const Gen::Marker &marker)
325+
static auto marker(const Gen::Marker &marker,
326+
const Marker::DataPosition &position)
317327
{
318-
return std::make_unique<Marker>(marker);
328+
return std::make_unique<Marker>(marker, position);
319329
}
320330

321331
static auto markerGuide(const Gen::Marker &marker,
332+
const Marker::DataPosition &position,
322333
bool horizontal)
323334
{
324-
return std::make_unique<MarkerGuide>(marker, horizontal);
335+
return std::make_unique<MarkerGuide>(marker,
336+
position,
337+
horizontal);
325338
}
326339

327340
static auto root()
@@ -362,11 +375,13 @@ class Events
362375
}
363376

364377
static auto markerLabel(const std::string &label,
365-
const Gen::Marker &marker)
378+
const Gen::Marker &marker,
379+
const Marker::DataPosition &position)
366380
{
367381
return std::make_unique<Text<MarkerChild>>(label,
368382
"label",
369-
marker);
383+
marker,
384+
position);
370385
}
371386

372387
static auto dimLegendLabel(

src/chart/main/version.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
#include "base/app/version.h"
44

5-
const App::Version Vizzu::Main::version(0, 14, 0);
5+
const App::Version Vizzu::Main::version(0, 15, 0);
66

77
const char *const Vizzu::Main::siteUrl = "https://vizzu.io/";

src/chart/rendering/markerrenderer.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ void MarkerRenderer::drawLines(Gfx::ICanvas &canvas,
6767
const Geom::Line line(axisPoint, blended.center);
6868

6969
auto guideElement =
70-
Events::Targets::markerGuide(blended.marker, false);
70+
Events::Targets::markerGuide(blended.marker,
71+
blended.dataPosition,
72+
false);
7173

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

9092
auto guideElement =
91-
Events::Targets::markerGuide(blended.marker, true);
93+
Events::Targets::markerGuide(blended.marker,
94+
blended.dataPosition,
95+
true);
9296

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

264268
auto markerElement =
265-
Events::Targets::marker(abstractMarker.marker);
269+
Events::Targets::marker(abstractMarker.marker,
270+
abstractMarker.dataPosition);
266271

267272
auto colorAlpha =
268273
Math::FuzzyBool::And<double>(abstractMarker.enabled, factor);
@@ -363,7 +368,9 @@ void MarkerRenderer::drawLabel(Gfx::ICanvas &canvas,
363368
Gfx::ColorTransform::OverrideColor(
364369
(*labelStyle.filter)(color)*colorAlpha),
365370
*rootEvents.draw.plot.marker.label,
366-
Events::Targets::markerLabel(text, marker));
371+
Events::Targets::markerLabel(text,
372+
marker,
373+
abstractMarker.dataPosition));
367374
}
368375

369376
std::string MarkerRenderer::getLabelText(

src/chart/rendering/markers/abstractmarker.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ AbstractMarker AbstractMarker::create(const DrawingContext &ctx,
4747
switch (shapeType) {
4848
case Gen::ShapeType::rectangle:
4949
return RectangleMarker(marker,
50+
ctx.coordSys,
5051
ctx.getOptions(),
5152
ctx.rootStyle);
5253
case Gen::ShapeType::circle:
@@ -132,6 +133,17 @@ AbstractMarker AbstractMarker::createInterpolated(
132133
return aMarker;
133134
}
134135

136+
void AbstractMarker::setDataPosition(const CoordinateSystem &coordSys)
137+
{
138+
dataPosition = {
139+
this->getLabelPos(Styles::MarkerLabel::Position::top,
140+
coordSys)
141+
.end,
142+
this->getLabelPos(Styles::MarkerLabel::Position::center,
143+
coordSys)
144+
.begin};
145+
}
146+
135147
Geom::Rect AbstractMarker::getBoundary() const
136148
{
137149
return Geom::Rect::Boundary(points);

src/chart/rendering/markers/abstractmarker.h

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class AbstractMarker
3535
Geom::Point center;
3636
Geom::Rect dataRect;
3737
double radius{};
38+
Events::Targets::Marker::DataPosition dataPosition;
3839

3940
[[nodiscard]] Geom::Rect getBoundary() const;
4041
[[nodiscard]] Geom::Line getLine() const;
@@ -51,6 +52,8 @@ class AbstractMarker
5152
const Gen::Marker &marker,
5253
const Gen::ShapeType &shapeType,
5354
::Anim::InterpolateIndex lineIndex);
55+
56+
void setDataPosition(const CoordinateSystem &coordSys);
5457
};
5558

5659
class SingleDrawMarker : public AbstractMarker

src/chart/rendering/markers/circlemarker.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ CircleMarker::CircleMarker(const Gen::Marker &marker,
3838
dataRect.pos = pos;
3939
dataRect.size = Geom::Size();
4040
radius = fabs(coordSys.verConvert(r));
41+
42+
setDataPosition(coordSys);
4143
}
4244

4345
}

src/chart/rendering/markers/connectingmarker.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ ConnectingMarker::ConnectingMarker(const DrawingContext &ctx,
158158

159159
dataRect.pos = isLine ? points[2] : points[1];
160160
dataRect.size = Geom::Size{points[2] - dataRect.pos};
161+
162+
setDataPosition(ctx.coordSys);
161163
}
162164

163165
const Gen::Marker *ConnectingMarker::getPrev(

src/chart/rendering/markers/rectanglemarker.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace Vizzu::Draw
1616
{
1717

1818
RectangleMarker::RectangleMarker(const Gen::Marker &marker,
19+
const CoordinateSystem &coordSys,
1920
const Gen::Options &options,
2021
const Styles::Chart &style) :
2122
SingleDrawMarker(marker, options, Gen::ShapeType::rectangle)
@@ -83,6 +84,8 @@ RectangleMarker::RectangleMarker(const Gen::Marker &marker,
8384
dataRect.pos = points[0];
8485
dataRect.size = Geom::Size{points[2] - points[0]};
8586
radius = 0;
87+
88+
setDataPosition(coordSys);
8689
}
8790

8891
}

src/chart/rendering/markers/rectanglemarker.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class RectangleMarker : public SingleDrawMarker
1010
{
1111
public:
1212
RectangleMarker(const Gen::Marker &marker,
13+
const CoordinateSystem &coordSys,
1314
const Gen::Options &options,
1415
const Styles::Chart &style);
1516
};

test/e2e/tests/features.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"refs": ["ba17dad"]
1515
},
1616
"events/drawing_events": {
17-
"refs": ["33e0e4d"]
17+
"refs": ["c3169b0"]
1818
},
1919
"subtitle_caption": {
2020
"refs": ["f6dabf0"]

0 commit comments

Comments
 (0)