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

The legend of the datapoint corresponding to show_value is polluted when data is generated by a filters-fn combination #257

Open
r-jean-pierre opened this issue Mar 1, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@r-jean-pierre
Copy link

Describe the bug
Only if data is generated by filters-fn, the legend of the first point (show_value) gets extra information from I suppose the underlying-fake-scatterplot

Screenshots
image

while other data points are perfect:
image

yaml

filters:
  - fn: |-
      ({ meta }) => ({
        xs: meta.dailyweek.map((date) => new Date(date)-3600*1000),
        ys: meta.dailyweek_HP.map((value) => value)
      })
@r-jean-pierre r-jean-pierre added the bug Something isn't working label Mar 1, 2023
@dbuezas
Copy link
Owner

dbuezas commented Mar 1, 2023

Interesting, I do add hoverinfo: 'skip' on the "fake" traces used for show_value
https://github.com/dbuezas/lovelace-plotly-graph-card/blob/master/src/parse-config/parse-config.ts#LL208C22-L208C22

Is there anything special in the rest of the yaml?

@r-jean-pierre
Copy link
Author

Interesting, I do add hoverinfo: 'skip' on the "fake" traces used for show_value https://github.com/dbuezas/lovelace-plotly-graph-card/blob/master/src/parse-config/parse-config.ts#LL208C22-L208C22

Is there anything special in the rest of the yaml?

except:
hovermode: "x unified"
and a personal hovertemplate, i really have nothing special

@dbuezas
Copy link
Owner

dbuezas commented Mar 1, 2023

Uhm. The hovertemplate may be overriding it.
I could add an extra property to remove the hovertemplate from the "fake" trace I use for show_value. Can you check if removing "hovertemplate" from the entity makes it disappear?

@r-jean-pierre
Copy link
Author

So, almost sure that it's not related to the templating, here is a minimalistic, but complete, example:

  - type: custom:plotly-graph  # test nrj
    entities:
    - entity: sensor.myenedis_05606946388355
      filters:
        - fn: |-
            ({ meta }) => ({
              xs: meta.dailyweek.map((date) => new Date(date)-3600*1000).reverse(),
              ys: meta.daily.map(value => value).reverse()
            })
      show_value: true
    - entity: sensor.myenedis_05606946388355
      filters:
        - fn: |-
            ({ meta }) => ({
              xs: meta.dailyweek.map((date) => new Date(date)-3600*1000).reverse(),
              ys: meta.daily.map(value => value).reverse()
            })
      show_value: true

    layout:
      hovermode: "x unified"    # -> this option is guilty

    hours_to_show: 180h
    time_offset: -30h

image

if i use the default hovermode, than it is what could be expected:
image
image

@dbuezas
Copy link
Owner

dbuezas commented Mar 2, 2023

Then it looks like it is a plotly bug :/
Just found this: plotly/plotly.js#5516

maybe try with hoverinfo: none instead of skip

@dbuezas
Copy link
Owner

dbuezas commented Mar 2, 2023

Ok, it needs both hoverinfo and hovertemplate

hovertemplate: false
hoverinfo: none

adding these two to an entity makes the tooltip go away, even in x-unified hover mode.

I'll keep this open and fix in the next release by adding those two to the template of the fake trace used for show_value.

In the meanwhile if it bothers you, you could add a second trace with no hoverinfo and template, remove all but the last datapoints and set show_value on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants