Forum Discussion
Infuence pie chart with variables
Hi everyone,
I'm working on a survey kind of project where there will be a lot of questions that sorts your personality into five types. For example based on what answers the user gives he has 60% personality type 1 35%, type 2 and 5% type 3.
I want to visualize those result into a pie chart. I found some JavaScript based things but I can't seem to influence the results with some variables.
Could someone please help me? :)
Kind regards,
Nurdianna
35 Replies
- InnowijsCommunity Member
Hi Jon,
Hmm.. Weird, I realy did the same steps and it showed me a pie-chart. But maybe I did missed something in my explanation. I've attached the story file so you can look it through. Maybe this will help.
@Owen, you do need a slide to set the variable to a certain value. Otherwize these variables wil be 0.
- OwenHoltSuper Hero
That shouldn't be required for my file as I had given each of the variables an assigned "default value".
I'll look at your .story file but could you also post your JS file and your index.html file?
- InnowijsCommunity Member
- OwenHoltSuper Hero
How are you assigning your web objects path? It appears that this might be where the difference lies.
- InnowijsCommunity Member
I've put the web objects in the same folder as the story file.
- JonEllinorCommunity Member
So what do I need to do to my project to make it work? Or have we not worked that out as yet?
Thanks
- OwenHoltSuper Hero
Very strange. When I use your JS and index file, it works. When I use my files which were copied from what you posted, it doesn't. I noticed a difference in the HTML file in that yours omits the typical opening <html> and <head> tags. I removed those in my file but it did not appear to make a difference. I will need to take some time to compare the JS files as well but I think that must be where there is some additional difference.
However, it works great with your file. Very nice work! - OwenHoltSuper Hero
I think it is the call to the StoryLine player. In the JS code posted above, the call to the player occurs right before getting the values. In the file that works, the call to the SL player occurs 1st in the code and points to the parent window.
var player = window.parent.GetPlayer(); - OwenHoltSuper Hero
Lastly, this works in I.E. but does not seem to be valid for chrome.
- InnowijsCommunity Member
Owen,
I thought about it and I was wondering if you published the project on a webserver or did you opened it local on your PC? Because it contains a extern JS file the project needs to be published online otherwise it would not work.- OwenHoltSuper Hero
That was exactly it. I published to our LMS and it opens fine. However, after modifying my slide to include an input form to change the variables, I ran into an issue where the new numbers are not reflected. I believe it is due to the window.onload = function() command in the code. I wonder if there is another way of triggering the function or delaying when the window loads or refreshing the iframe to get the current data....
Any ideas?
- InnowijsCommunity Member
Peculiar.. We only work with Chrome.. My colleague tested it step by step a few weeks ago and it worked just fine. So I'm really confused why it doesn't work with you guys..
- JonEllinorCommunity Member
Hi guys
Owen, how exactly did you get this to work? What did you do? I am still seeing a blank screen. If you altered the JS code, please could you post it?
Thank you both for your help.
Jon
- InnowijsCommunity Member
Related Content
- 10 months ago
- 10 months ago
- 10 months ago
- 10 months ago