Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chart): Time Series set showMaxLabel as null for time xAxis #20627

Merged
merged 3 commits into from
Aug 2, 2022

Conversation

Antonio-RiveroMartnez
Copy link
Member

SUMMARY

  • Apache Echarts has showMaxLabel option set to false by default for time axis (https://github.com/apache/echarts/blob/master/src/coord/axisDefault.ts#L178), so we need to override it for our time series charts in order to not be fixed with hidden and instead let the library determine whether to show the label of the max tick
  • Add AxisType enum so we stop comparing agains raw strings when checking xAxis type

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

BEFORE:
error

AFTER:
test

TESTING INSTRUCTIONS

  1. Go to a time series line chart with monthly data from the example datasets
  2. Chose month time grain
  3. Expected results: last month should show on X axis

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Jul 6, 2022

Codecov Report

Merging #20627 (3169da9) into master (8d4994a) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##           master   #20627      +/-   ##
==========================================
- Coverage   66.85%   66.85%   -0.01%     
==========================================
  Files        1753     1753              
  Lines       65825    65827       +2     
  Branches     7006     7007       +1     
==========================================
  Hits        44010    44010              
- Misses      20030    20031       +1     
- Partials     1785     1786       +1     
Flag Coverage Δ
javascript 51.95% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...gin-chart-echarts/src/Timeseries/transformProps.ts 54.65% <0.00%> (-1.31%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d4994a...3169da9. Read the comment docs.

@Antonio-RiveroMartnez Antonio-RiveroMartnez force-pushed the FIX-49973 branch 2 times, most recently from 4d489ea to 9fe79a1 Compare July 7, 2022 18:15
@rusackas
Copy link
Member

rusackas commented Jul 7, 2022

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2022

@rusackas Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2022

@rusackas Ephemeral environment creation failed. Please check the Actions logs for details.

@rusackas
Copy link
Member

rusackas commented Jul 7, 2022

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2022

@rusackas Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 7, 2022

@rusackas Ephemeral environment creation failed. Please check the Actions logs for details.

@Antonio-RiveroMartnez
Copy link
Member Author

🏷️ preset-patch

@@ -326,13 +327,23 @@ export default function transformProps(
rotate: xAxisLabelRotation,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rotate: xAxisLabelRotation,
rotate: xAxisLabelRotation,
Suggested change
rotate: xAxisLabelRotation,
rotate: xAxisLabelRotation,
showLabel: xAxisType === AxisType.time ? null : false,

looks like we can use one line to meet the requirement 🤔

Copy link
Member Author

@Antonio-RiveroMartnez Antonio-RiveroMartnez Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do that you will be overriding default values for other axis types to false. Which might not be the desire output and might impact how other axis behave?. I would rather let the defaults for other types be set in Echarts and respect their criteria and being explicit to overriding only when/where we need to.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This point makes sense. Another I'm curious why not set showMaxLabel option here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How so? I mean, setting showMaxLabel here (in this initial declaration) is precisely what I avoid doing so we don't override the defaults for other types (this initial value gets used for all xAxis types). 🤔

Copy link
Member Author

@Antonio-RiveroMartnez Antonio-RiveroMartnez Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, you made me realize I call it showLabel and not showMaxLabel with my second commit. Let me fix that ASAP

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another suggestion is we can try to set FEATURE_GENERIC_CHART_AXES=true to see if it also works.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may be mistaken, however, based on this from the README:

A new feature flag GENERIC_CHART_AXES has been added that makes it possible to
  use a non-temporal x-axis on the ECharts Timeseries chart
  ([#17917](https://github.com/apache/superset/pull/17917)). When enabled, a new
  control "X Axis" is added to the control panel of ECharts line, area, bar, step and
  scatter charts, which makes it possible to use categorical or numerical x-axes on
  those charts.

If that's true those are exactly the axis types we don't want to include with these changes. Nonetheless, let me try setting it as true and see if it actually fix the issue by itself.

Copy link
Member Author

@Antonio-RiveroMartnez Antonio-RiveroMartnez Jul 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephenLYZ enabling that flag we get the last month to show but the chart looks off to me and the format is not correct:

Changes from this PR:
PR

No changes + Flag enabled:
Flag

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That second one does look odd... is there a way to solve for that? If there's no 0 month, it seems like that shouldn't be on the X axis.

Copy link
Member Author

@Antonio-RiveroMartnez Antonio-RiveroMartnez Jul 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the misunderstanding. I was showing the result for the approach mentioned above about enabling the flag (with no code changes).

So the first image shows the chart with the code changes in this PR

@stephenLYZ
Copy link
Member

/testenv up FEATURE_GENERIC_CHART_AXES=true

@github-actions
Copy link
Contributor

@stephenLYZ Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

@stephenLYZ Ephemeral environment creation failed. Please check the Actions logs for details.

-Apache echarts has this option as false by default for time axis, so we need to override it for our charts so it's uto determined and not fixed to hidden.
- Add AxisType enum so we stop comparing agains raw strings when checking xAxis type
- set the showMaxLabel option directly without using merge
 - Rename the property to showMaxLabel as it was originally
@rusackas
Copy link
Member

rusackas commented Aug 2, 2022

/testenv up FEATURE_GENERIC_CHART_AXES=true

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

@rusackas Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

@rusackas Ephemeral environment creation failed. Please check the Actions logs for details.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

@rusackas Container image not yet published for this PR. Please try again when build is complete.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 2, 2022

@rusackas Ephemeral environment creation failed. Please check the Actions logs for details.

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ephemeral environments are obviously flaky here, but based on the code/screenshots/discussion, I think we're OK here.

@rusackas rusackas merged commit 9362e27 into apache:master Aug 2, 2022
@Antonio-RiveroMartnez Antonio-RiveroMartnez deleted the FIX-49973 branch August 2, 2022 21:15
@villebro
Copy link
Member

@Antonio-RiveroMartnez I've noticed that this PR has caused time series charts to show weird max labels when the chart is wide enough:
image

Removing showMaxLabel: null resolves it:
image

IIRC, setting showMaxLabel: null makes it behave the same as if it was set to showMaxLabel: true. Therefore, I believe we should revert this change and consider alternative solutions for solving the problem this initially tried to fix.

Ping also reviewers @rusackas and @diegomedina248

@Antonio-RiveroMartnez
Copy link
Member Author

Hey @villebro , thanks for the catch 🙌 , I'm more than happy reverting the changes if they are causing issues.

showMaxLabel: null means ECharts automatically determine whether or not the label should display, while setting it to true would force the label to show all the time. For time series, it's set to false by default, that's why we tried to bypass such wrong behavior by setting it to null and rely on such auto computation.

Now, I might be wrong, but finding a new approach might get us to address the issue directly on ECharts, since it is the one in charge for how to render such labels.

@rusackas
Copy link
Member

rusackas commented Apr 6, 2023

I just happened to stumble upon this thread. It doesn't look like this was reverted, in case this is causing any further issues/complaints (cc @yousoph for good measure)

@yousoph
Copy link
Member

yousoph commented Apr 7, 2023

Oh! Thanks, yeah I don't think we reverted it or fixed the extra timestamp label. We'll take a look

@mpostelnicu
Copy link

if possible, please revert this in 2.1.1 because of the extra timestamp label displayed at the end

@rusackas
Copy link
Member

The issue is labelled for 2.1 already, but I'll CC @Antonio-RiveroMartnez and @eschutho for good measure. I'm not sure if it's easier at this point to revert or to fix forward, so I'll leave the choice to them.

eschutho added a commit to preset-io/superset that referenced this pull request Aug 15, 2023
jinghua-qa pushed a commit to preset-io/superset that referenced this pull request Aug 16, 2023
michael-s-molina pushed a commit that referenced this pull request Aug 17, 2023
mpostelnicu pushed a commit to devgateway/ocmoldova-superset that referenced this pull request Aug 31, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 labels Mar 13, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels Preset-Patch size/S 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants