Skip to content

Commit 3595e46

Browse files
committed
Merge remote-tracking branch 'origin/axis_refactor_v2' into axis_refactor_v3
2 parents 0ca3a44 + 0ca3981 commit 3595e46

File tree

21 files changed

+178
-58
lines changed

21 files changed

+178
-58
lines changed

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 10 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 14 additions & 4 deletions
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

Lines changed: 26 additions & 11 deletions
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

Lines changed: 1 addition & 1 deletion
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

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

6868
auto guideElement =
69-
Events::Targets::markerGuide(blended.marker, false);
69+
Events::Targets::markerGuide(blended.marker,
70+
blended.dataPosition,
71+
false);
7072

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

8991
auto guideElement =
90-
Events::Targets::markerGuide(blended.marker, true);
92+
Events::Targets::markerGuide(blended.marker,
93+
blended.dataPosition,
94+
true);
9195

9296
if (rootEvents.draw.plot.marker.guide->invoke(
9397
Events::OnLineDrawEvent(*guideElement,
@@ -268,7 +272,8 @@ void MarkerRenderer::draw(Gfx::ICanvas &canvas,
268272
canvas.setLineWidth(*rootStyle.plot.marker.borderWidth);
269273

270274
auto markerElement =
271-
Events::Targets::marker(abstractMarker.marker);
275+
Events::Targets::marker(abstractMarker.marker,
276+
abstractMarker.dataPosition);
272277

273278
auto colorAlpha =
274279
Math::FuzzyBool::And<double>(abstractMarker.enabled, factor);
@@ -369,7 +374,9 @@ void MarkerRenderer::drawLabel(Gfx::ICanvas &canvas,
369374
Gfx::ColorTransform::OverrideColor(
370375
(*labelStyle.filter)(color)*colorAlpha),
371376
*rootEvents.draw.plot.marker.label,
372-
Events::Targets::markerLabel(text, marker));
377+
Events::Targets::markerLabel(text,
378+
marker,
379+
abstractMarker.dataPosition));
373380
}
374381

375382
std::string MarkerRenderer::getLabelText(

src/chart/rendering/markers/abstractmarker.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ AbstractMarker AbstractMarker::create(const DrawingContext &ctx,
2727
switch (shapeType) {
2828
case Gen::ShapeType::rectangle:
2929
return RectangleMarker(marker,
30+
ctx.coordSys,
3031
ctx.getOptions(),
3132
ctx.rootStyle);
3233
case Gen::ShapeType::circle:
@@ -111,6 +112,17 @@ AbstractMarker AbstractMarker::createInterpolated(
111112
return aMarker;
112113
}
113114

115+
void AbstractMarker::setDataPosition(const CoordinateSystem &coordSys)
116+
{
117+
dataPosition = {
118+
this->getLabelPos(Styles::MarkerLabel::Position::top,
119+
coordSys)
120+
.end,
121+
this->getLabelPos(Styles::MarkerLabel::Position::center,
122+
coordSys)
123+
.begin};
124+
}
125+
114126
Geom::Rect AbstractMarker::getBoundary() const
115127
{
116128
return Geom::Rect::Boundary(points);

0 commit comments

Comments
 (0)