- This topic is empty.
-
AuthorPosts
-
May 23, 2018 at 12:41 pm #271599NopelTGParticipant
I have a graph bar, when hovering I want some data to be displayed, but I can’t make it happen.
When hovering eg. first blue I want to display text in HiddenBox1, first green other and so …
When hovering bar is changing to orange to see that is the hovered bar.Code is here:
https://codepen.io/LucBaetsle/pen/GdapJKThanks in advance
May 23, 2018 at 9:37 pm #271607BeverleyhParticipantUnfortunately there’s too much code in the demo to expect folks here to comfortably view and troubleshoot, and on quick inspection, I don’t see anything that would suggest you’ve attempted to do anything with the hover boxes yourself.
To attract helpful responses you can do two things;
- Strip back the demo to something much more basic – one or two bars, minus all the extra visual fluff. We only need a very simplified codebase of HTML and CSS – get rid of superfluous styling – solid, basic blocks and standard fonts are fine.
-
Show us what you’ve tried already in CSS or JavaScript.
You should also check the forums for previous, similar questions and answers. Only yesterday there was a thread asking about showing and hiding docs on hover so you may find what you’re looking for there.
May 23, 2018 at 11:52 pm #271612JeroenRParticipantWith the current HTML structure you can’t achieve something like this with just CSS. If you want to do it with CSS only, then you’ll have to move the hidden DIV’s to somewhere in the ancestor structure of the items you’re hovering.
Leaving the structure like it is now, you can do something with javascript (I’ve added jQuery) and then you can do something like this: https://codepen.io/jeroenreijs/pen/ELzwRvThe hovering is causing some flickering, you can solve that by changing the CSS, but I think you’ll get the idea by this.
May 24, 2018 at 7:58 am #271625NopelTGParticipantI adjusted the JQuery a bit, but I only get the data that comes above the bar into the HiddenBox below.
When I enter other data; I’m not able to see.https://codepen.io/LucBaetsle/pen/GdapJK
It displays Luc or Karl in the colored bar, but not in yellow box below
May 24, 2018 at 12:53 pm #271647JeroenRParticipantIn your codepen, jQuery is not included, so that raises an error.
Second, the p element is set todisplay: none;
, line 353 in your CSS. So actually when jQuery has been included, the thing works, you just won’t see it because of the CSS.May 24, 2018 at 10:10 pm #271673NopelTGParticipantJeroenR:
When I click “Edit on CodePen”. I can see code in JQuery. When I remove p {display … then the both names are visual fr om the beginning.
GreetZ
May 25, 2018 at 12:12 am #271675BeverleyhParticipantYou need to include the jQuery library too… in the pen’s JS settings.
May 25, 2018 at 11:03 am #271699NopelTGParticipantI included the library into HTML. But still showing the data, like Luc and Karl on the bar and not in the yellow box.
If I remove p {display .. then I get Luc and Karl into the bar and in the yellow box together with the data.I only want Luc, Karl in the yellow box and not the value when hovering the bar
May 27, 2018 at 11:43 pm #271780JeroenRParticipantWhen you want all paragraphs to hide, but one, it is useful to use a classname to override the
display: none;
.
So I have used a classname ‘show’, to show a paragraph which uses that classname.Also, at first we took the whole textual value of the listitem, but if you only want the name, you can search for the paragraph inside that list item and just take that value.
These are the two changes I’ve made:https://codepen.io/anon/pen/aKodWQ
I think this is what you want to have?
May 28, 2018 at 9:36 am #271784NopelTGParticipantJeroenR, yes, this is it. It works fine within CodePen. But why doesn’t the hoverbox show up when I put files into the website. I entered also following in html page
script type=”text/javascript” src=”BarGraph.js”
May 30, 2018 at 12:26 am #271845JeroenRParticipantI’m not sure. It’s impossible to guess. But when you have put the script of the codepen in the file BarGraph.js, make sure you load jQuery as well in your website and before the BarGraph.
Also, check if the reference to that javascript file is right, follow the link to it and see if it doesn’t reach a 404 or something.
Because usually you place your script files in another directory than your pages. Not necessary, just a way of working. -
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.