diff --git a/CHANGELOG.md b/CHANGELOG.md index 030f6e43d..56ac96510 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ### Fixed - Markers are the same even if new record added. +- Axis line hide/show at same time with axis labels/ticks/title. +- Do not draw invisible axis line. + ### Changed diff --git a/src/chart/animator/morph.cpp b/src/chart/animator/morph.cpp index f4e6fcaff..d8f793d4f 100644 --- a/src/chart/animator/morph.cpp +++ b/src/chart/animator/morph.cpp @@ -135,9 +135,6 @@ void Horizontal::transform(const Gen::Plot &source, target.keepAspectRatio, factor); - actual.anyAxisSet = - interpolate(source.anyAxisSet, target.anyAxisSet, factor); - actual.guides.x = interpolate(source.guides.x, target.guides.x, factor); } diff --git a/src/chart/animator/planner.cpp b/src/chart/animator/planner.cpp index 9aa646b88..1378a6cb3 100644 --- a/src/chart/animator/planner.cpp +++ b/src/chart/animator/planner.cpp @@ -436,7 +436,6 @@ bool Planner::needVertical() const || source->axises.at(Gen::ChannelId::size).dimension != target->axises.at(Gen::ChannelId::size) .dimension)) - || source->anyAxisSet != target->anyAxisSet || (source->markerConnectionOrientation != target->markerConnectionOrientation && (source->markerConnectionOrientation.value_or( @@ -474,7 +473,6 @@ bool Planner::needHorizontal() const != target->axises.at(Gen::ChannelId::x).dimension || source->guides.at(Gen::AxisId::x) != target->guides.at(Gen::AxisId::x) - || source->anyAxisSet != target->anyAxisSet || source->keepAspectRatio != target->keepAspectRatio || (source->markerConnectionOrientation != target->markerConnectionOrientation diff --git a/src/chart/generator/guides.cpp b/src/chart/generator/guides.cpp index 0d0657c40..99321f0b9 100644 --- a/src/chart/generator/guides.cpp +++ b/src/chart/generator/guides.cpp @@ -39,13 +39,15 @@ bool GuidesByAxis::operator==(const GuidesByAxis &other) const Guides::Guides(const Options &options) { - auto isCircle = options.geometry.get() == ShapeType::circle; - auto isHorizontal = options.isHorizontal(); const auto &channelX = options.getChannels().at(ChannelId::x); const auto &channelY = options.getChannels().at(ChannelId::y); + if (channelX.isEmpty() && channelY.isEmpty()) return; + auto xIsMeasure = channelX.isMeasure(); auto yIsMeasure = channelY.isMeasure(); auto isPolar = options.coordSystem.get() == CoordSystem::polar; + auto isCircle = options.geometry.get() == ShapeType::circle; + auto isHorizontal = options.isHorizontal(); const auto &xOpt = options.getChannels().at(ChannelId::x); const auto &yOpt = options.getChannels().at(ChannelId::y); diff --git a/src/chart/generator/plot.cpp b/src/chart/generator/plot.cpp index c5772463b..1d2b24c52 100644 --- a/src/chart/generator/plot.cpp +++ b/src/chart/generator/plot.cpp @@ -54,7 +54,6 @@ bool Plot::MarkerInfoContent::operator==( } Plot::Plot(PlotOptionsPtr opts, Styles::Chart style) : - anyAxisSet(opts->getChannels().anyAxisSet()), guides(*opts), options(std::move(opts)), style(std::move(style)) diff --git a/src/chart/generator/plot.h b/src/chart/generator/plot.h index a634591a6..7ba6b1c0f 100644 --- a/src/chart/generator/plot.h +++ b/src/chart/generator/plot.h @@ -53,7 +53,6 @@ class Plot using MarkerInfo = ::Anim::Interpolated; using MarkersInfo = std::map; - Math::FuzzyBool anyAxisSet; Axises axises; Guides guides; Math::FuzzyBool keepAspectRatio; diff --git a/src/chart/generator/plotbuilder.cpp b/src/chart/generator/plotbuilder.cpp index 5a5beba16..baece2ddf 100644 --- a/src/chart/generator/plotbuilder.cpp +++ b/src/chart/generator/plotbuilder.cpp @@ -50,18 +50,18 @@ PlotBuilder::PlotBuilder(const Data::DataTable &dataTable, if (!plot->options->getChannels().anyAxisSet()) { addSpecLayout(subBuckets); calcDimensionAxises(); + calcMeasureAxises(dataTable); normalizeColors(); if (plot->options->geometry != ShapeType::circle) normalizeSizes(); - calcMeasureAxises(dataTable); } else { addSeparation(subBuckets, mainBucketSize); normalizeXY(); calcDimensionAxises(); + calcMeasureAxises(dataTable); normalizeSizes(); normalizeColors(); - calcMeasureAxises(dataTable); addAlignment(subBuckets); } @@ -93,14 +93,12 @@ Buckets PlotBuilder::generateMarkers(std::size_t &mainBucketSize) { const auto &mainIds(plot->getOptions()->mainAxis().dimensions()); auto subIds(plot->getOptions()->subAxis().dimensions()); - - auto all_marker = dataCube.df->get_record_count(); if (!dataCube.empty()) { if (plot->getOptions()->geometry == ShapeType::area) subIds.split_by(mainIds); mainBucketSize = dataCube.combinedSizeOf(mainIds).first; - plot->markers.reserve(all_marker); + plot->markers.reserve(dataCube.df->get_record_count()); } std::multimap map; @@ -186,18 +184,16 @@ PlotBuilder::sortedBuckets(const Buckets &buckets, bool main) const void PlotBuilder::addSpecLayout(Buckets &buckets) { auto geometry = plot->getOptions()->geometry.values[0].value; - if (auto &markers = plot->markers; isConnecting(geometry)) { + if (auto &markers = plot->markers; isConnecting(geometry)) Charts::TableChart::setupVector(markers, true); - } - else if (auto &&size = plot->getOptions()->getChannels().at( - ChannelId::size); - size.isDimension()) { + else if (plot->getOptions() + ->getChannels() + .at(ChannelId::size) + .isDimension()) Charts::TableChart::setupVector(markers); - } else if (!dataCube.empty()) { - buckets.sort(&Marker::sizeId); - - if (geometry == ShapeType::circle) { + if (buckets.sort(&Marker::sizeId); + geometry == ShapeType::circle) { Charts::BubbleChartBuilder::setupVector( *plot->getStyle().plot.marker.circleMaxRadius, buckets); @@ -619,8 +615,10 @@ void PlotBuilder::normalizeColors() cbase.setPos(color.rescale(cbase.getPos())); } - getMeasTrackRange(ChannelId::color) = color; - getMeasTrackRange(ChannelId::lightness) = lightness; + plot->axises.at(ChannelId::color).measure.range = + getMeasTrackRange(ChannelId::color) = color; + plot->axises.at(ChannelId::lightness).measure.range = + getMeasTrackRange(ChannelId::lightness) = lightness; for (auto &value : plot->axises.at(ChannelId::color).dimension) value.second.colorBase = diff --git a/src/chart/rendering/drawaxes.cpp b/src/chart/rendering/drawaxes.cpp index 4b11ff546..53e07b186 100644 --- a/src/chart/rendering/drawaxes.cpp +++ b/src/chart/rendering/drawaxes.cpp @@ -65,27 +65,22 @@ Geom::Line DrawAxes::getAxis(Gen::AxisId axisIndex) const void DrawAxes::drawAxis(Gen::AxisId axisIndex) const { - auto eventTarget = - Events::Targets::axis(axisIndex == Gen::AxisId::x); - - auto lineBaseColor = *rootStyle.plot.getAxis(axisIndex).color; - - if (lineBaseColor.alpha <= 0 || plot->anyAxisSet == false) return; - - auto line = getAxis(axisIndex); - - if (!line.isPoint()) { + if (auto line = getAxis(axisIndex); !line.isPoint()) { auto lineColor = - lineBaseColor - * Math::FuzzyBool::And(plot->anyAxisSet, - plot->guides.at(axisIndex).axis); + *rootStyle.plot.getAxis(axisIndex).color + * static_cast(plot->guides.at(axisIndex).axis); + + if (lineColor.isTransparent()) return; canvas.save(); canvas.setLineColor(lineColor); canvas.setLineWidth(1.0); - if (rootEvents.draw.plot.axis.base->invoke( + if (auto &&eventTarget = + Events::Targets::axis(axisIndex == Gen::AxisId::x); + + rootEvents.draw.plot.axis.base->invoke( Events::OnLineDrawEvent(*eventTarget, {line, true}))) { painter.drawLine(line); diff --git a/src/chart/rendering/markerrenderer.cpp b/src/chart/rendering/markerrenderer.cpp index 6a167dca1..544a2483d 100644 --- a/src/chart/rendering/markerrenderer.cpp +++ b/src/chart/rendering/markerrenderer.cpp @@ -36,26 +36,32 @@ void MarkerRenderer::drawLines(Gfx::ICanvas &canvas, const auto &style = rootStyle.plot.marker.guides; if (style.color->isTransparent() || *style.lineWidth <= 0 - || plot->anyAxisSet == false || !plot->guides.hasAnyGuides()) + || !plot->guides.hasAnyGuides()) return; + auto xLineColor = + *style.color + * static_cast(plot->guides.x.markerGuides); + + auto yLineColor = + *style.color + * static_cast(plot->guides.y.markerGuides); + + auto xLineInvisible = xLineColor.isTransparent(); + auto yLineInvisible = yLineColor.isTransparent(); + + if (xLineInvisible && yLineInvisible) return; + canvas.setLineWidth(*style.lineWidth); auto origo = plot->axises.origo(); - auto xLineColor = *style.color - * Math::FuzzyBool::And(plot->anyAxisSet, - plot->guides.x.markerGuides); - auto yLineColor = *style.color - * Math::FuzzyBool::And(plot->anyAxisSet, - plot->guides.y.markerGuides); - for (const auto &blended : markers) { if (blended.marker.enabled == false || blended.enabled == false) continue; - if (plot->guides.x.markerGuides != false) { + if (!xLineInvisible) { canvas.setLineColor(xLineColor); auto axisPoint = blended.center.xComp() + origo.yComp(); const Geom::Line line(axisPoint, blended.center); @@ -71,7 +77,7 @@ void MarkerRenderer::drawLines(Gfx::ICanvas &canvas, std::move(guideElement)); } } - if (plot->guides.y.markerGuides != false) { + if (!yLineInvisible) { auto center = Geom::Point{blended.center}; center.x = Math::interpolate(center.x, 1.0, diff --git a/test/e2e/test_cases/test_cases.json b/test/e2e/test_cases/test_cases.json index 88d899bce..a8a07116c 100644 --- a/test/e2e/test_cases/test_cases.json +++ b/test/e2e/test_cases/test_cases.json @@ -8,7 +8,7 @@ "refs": ["c5c0df5"] }, "basic_animations/anim_order/rectangle_without_2_carte_bar": { - "refs": ["929dbd0"] + "refs": ["2a487b0"] }, "basic_animations/anim_order/rectangle_without_2_carte_column": { "refs": ["e88e517"] @@ -1340,28 +1340,28 @@ "refs": ["4d42242"] }, "ww_animTiming/without-descartes_orientation/01_w-d_o_r-r-r": { - "refs": ["dd2956b"] + "refs": ["5b50b91"] }, "ww_animTiming/without-descartes_orientation/02_w-d_o_c-r-c": { - "refs": ["d1f7bc4"] + "refs": ["be7a91f"] }, "ww_animTiming/without-descartes_orientation/05_w-d_o_r-c-r": { - "refs": ["c1148ec"] + "refs": ["88424cf"] }, "ww_animTiming/without-descartes_orientation/06_w-d_o_c-c-c": { - "refs": ["2068c64"] + "refs": ["2e3894f"] }, "ww_animTiming/without-descartes_orientation/09_w-d_o_r-a-r": { - "refs": ["1764f6a"] + "refs": ["cd724c7"] }, "ww_animTiming/without-descartes_orientation/10_w-d_o_c-a-c": { - "refs": ["a5256c7"] + "refs": ["7165dfa"] }, "ww_animTiming/without-descartes_orientation/13_w-d_o_r-l-r": { - "refs": ["12843e9"] + "refs": ["750bd0f"] }, "ww_animTiming/without-descartes_orientation/14_w-d_o_c-l-c": { - "refs": ["37b2c36"] + "refs": ["b86538c"] }, "ww_animTiming/without-polar/01_w-p_r-r-r": { "refs": ["0093ba5"] @@ -1673,7 +1673,7 @@ "refs": ["e955812"] }, "ww_animTiming_TESTS/without-descartes_orientation/01_w-d_o_r-r-r": { - "refs": ["cdf5fa6"] + "refs": ["037dda9"] }, "ww_animTiming_TESTS/without-descartes_orientation/02_w-d_o_c-r-c": { "refs": ["4568887"] @@ -1685,13 +1685,13 @@ "refs": ["4210956"] }, "ww_animTiming_TESTS/without-descartes_orientation/09_w-d_o_r-a-r": { - "refs": ["f45ac5b"] + "refs": ["5867a1b"] }, "ww_animTiming_TESTS/without-descartes_orientation/10_w-d_o_c-a-c": { "refs": ["aa0fb41"] }, "ww_animTiming_TESTS/without-descartes_orientation/13_w-d_o_r-l-r": { - "refs": ["42f1324"] + "refs": ["17c98c5"] }, "ww_animTiming_TESTS/without-descartes_orientation/14_w-d_o_c-l-c": { "refs": ["fa9e4f7"] @@ -2891,7 +2891,7 @@ "refs": ["d05bc27"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/rectangle_V1/04a_d-w_rec_Ve1_2c_V1": { - "refs": ["4597f5f"] + "refs": ["b8b060e"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/rectangle_V1/04b_d-w_rec_1c_V1": { "refs": ["3711f84"] @@ -2903,10 +2903,10 @@ "refs": ["6aa98f4"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/rectangle_V1/07a_d-w_rec_Ve1_2c_V1": { - "refs": ["7d74510"] + "refs": ["8d00b71"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/rectangle_V1/08a_d-w_rec_Ve1_2c_V1": { - "refs": ["715db19"] + "refs": ["44c0c9e"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/rectangle_Ve1/04a_d-w_rec_Ve1_1c": { "refs": ["e8b9827"] diff --git a/test/e2e/tests/features.json b/test/e2e/tests/features.json index db6d13e54..757c705f7 100644 --- a/test/e2e/tests/features.json +++ b/test/e2e/tests/features.json @@ -14,7 +14,7 @@ "refs": ["ba17dad"] }, "events/drawing_events": { - "refs": ["6496e1d"] + "refs": ["33e0e4d"] }, "subtitle_caption": { "refs": ["f6dabf0"] diff --git a/test/e2e/tests/features/events/drawing_events.mjs b/test/e2e/tests/features/events/drawing_events.mjs index 7afe87fa2..d126a3c46 100644 --- a/test/e2e/tests/features/events/drawing_events.mjs +++ b/test/e2e/tests/features/events/drawing_events.mjs @@ -108,7 +108,7 @@ function setupEvents(chart) { }) }) chart.on('draw-complete', (e) => { - const reference = 764260241 + const reference = -476544255 receivedEvents.push(e) const result = JSON.stringify(receivedEvents, null, 2) const hash = (str) => @@ -144,8 +144,8 @@ const testSteps = [ data, config: { color: 'Foo', - x: { set: 'Foo', guides: true, ticks: true }, - y: { set: 'Bar', guides: true, ticks: true }, + x: { set: 'Foo', guides: true, ticks: true, axis: true }, + y: { set: 'Bar', guides: true, ticks: true, axis: true }, size: 'Baz', label: 'Baz', title: 'My Chart', diff --git a/test/unit/chart/events.cpp b/test/unit/chart/events.cpp index 03781e198..b6184b80e 100644 --- a/test/unit/chart/events.cpp +++ b/test/unit/chart/events.cpp @@ -411,7 +411,7 @@ const static auto tests = auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-axis-label-draw") == 4u + 5u; check->*events.count("plot-marker-label-draw") == 5u; check->*events.count("plot-marker-draw") == 5u; @@ -427,7 +427,7 @@ const static auto tests = { auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-axis-label-draw") == 3u + 3u; check->*events.count("plot-marker-draw") == 10u; @@ -455,7 +455,7 @@ const static auto tests = chart.getOptions().geometry = circle; auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-marker-draw") == 5u; check->*events.count("plot-marker-guide-draw") == 5u; @@ -490,7 +490,7 @@ const static auto tests = auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-axis-label-draw") == 4u + 5u; check->*events.count("plot-marker-draw") == 10u; @@ -507,7 +507,7 @@ const static auto tests = auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-axis-label-draw") == 4u + 5u; check->*events.count("plot-marker-draw") == 5u; @@ -575,7 +575,7 @@ const static auto tests = { auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-marker-draw") == 10u; for (auto &&[beg, end] = events.equal_range("plot-marker-draw"); @@ -590,7 +590,7 @@ const static auto tests = { auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-marker-draw") == 3u; for (auto &&[beg, end] = events.equal_range("plot-marker-draw"); @@ -614,7 +614,7 @@ const static auto tests = Vizzu::Base::AutoParam{Vizzu::Gen::ChannelExtrema("0%")}; auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-marker-draw") == 28u; for (auto &&[beg, end] = events.equal_range("plot-marker-draw"); @@ -650,7 +650,7 @@ const static auto tests = { auto &&events = get_events(chart); - check->*events.count("plot-axis-draw") == 2u; + check->*events.count("plot-axis-draw") == 1u; check->*events.count("plot-axis-label-draw") == 1u; check->*events.count("plot-axis-title-draw") == 2u; check->*events.count("plot-marker-draw") == 0u;