esnet / react-timeseries-charts

Declarative and modular timeseries charting components for React
http://software.es.net/react-timeseries-charts
Other
859 stars 283 forks source link

Label in EventChart #410

Open ctcoder5 opened 5 years ago

ctcoder5 commented 5 years ago

❔Question

Is there a prop/setting/approach to display the label of an EventChart at all times instead of just on mouse over? I am utilizing the EventChart very similar to the Outage Events sample on your site.

pondjs: "0.8.10" react-timeseries-charts: "0.15.5"

Your Environment

Software Name/Version
react-timeseries-charts 0.15.5
Browser Chrome
Operating System windows 10
alexandresebrao commented 4 years ago

I want to switch from english to portuguese, any help?

molzahn-sio commented 4 years ago

@ctcoder5 Any luck in the meantime? I'm currently running into the same necessity and I'm still looking for a solution.

@alexandresebrao I added a suggestion to your topic in #413

brandly commented 4 years ago

the label is displayed here:

https://github.com/esnet/react-timeseries-charts/blob/c36d4034fd219101be1e52d9240aeeff8c124c42/src/components/EventChart.js#L124-L134

but that only gets set if isHover:

https://github.com/esnet/react-timeseries-charts/blob/c36d4034fd219101be1e52d9240aeeff8c124c42/src/components/EventChart.js#L112-L114

so i don't think this is possible with the current API

molzahn-sio commented 4 years ago

The documentation says "experimental state" so I assume the EventChart will feature such options when its complete.

For the time being I'm looking into workarounds. Thanks for the code line in that regard.

brandly commented 4 years ago

@pjm17971 what if the label prop, as a function, took both the event and state? then, you could remove the if (isHover) block highlighted in my last comment.

that way, you could still only show labels on hover if you'd like, but it would support @ctcoder5's use case as well.

this also mirrors the parameters passed to the style prop on EventChart. https://github.com/esnet/react-timeseries-charts/blob/c36d4034fd219101be1e52d9240aeeff8c124c42/src/components/EventChart.js#L89

i'd be happy to send a PR, if you like this idea.

pjm17971 commented 4 years ago

@brandly I think that would work, so long as if the label prop was not a function it behaves the way it does now. Can you send a PR? Thanks!